pb_field_iter_begin:
  157|   661k|{
  158|   661k|    memset(iter, 0, sizeof(*iter));
  159|       |
  160|   661k|    iter->descriptor = desc;
  161|   661k|    iter->message = message;
  162|       |
  163|   661k|    return load_descriptor_values(iter);
  164|   661k|}
pb_field_iter_begin_extension:
  167|   171k|{
  168|   171k|    const pb_msgdesc_t *msg = (const pb_msgdesc_t*)extension->type->arg;
  169|   171k|    bool status;
  170|       |
  171|   171k|    uint32_t word0 = PB_PROGMEM_READU32(msg->field_info[0]);
  ------------------
  |  |  155|   171k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  172|   171k|    if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  297|   171k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|   171k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  293|   171k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (172:9): [True: 0, False: 171k]
  ------------------
  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|   171k|    else
  180|   171k|    {
  181|   171k|        status = pb_field_iter_begin(iter, msg, extension->dest);
  182|   171k|    }
  183|       |
  184|   171k|    iter->pSize = &extension->found;
  185|   171k|    return status;
  186|   171k|}
pb_field_iter_next:
  189|  1.68M|{
  190|  1.68M|    advance_iterator(iter);
  191|  1.68M|    (void)load_descriptor_values(iter);
  192|  1.68M|    return iter->index != 0;
  193|  1.68M|}
pb_field_iter_find:
  196|  7.11M|{
  197|  7.11M|    if (iter->tag == tag)
  ------------------
  |  Branch (197:9): [True: 3.89M, False: 3.22M]
  ------------------
  198|  3.89M|    {
  199|  3.89M|        return true; /* Nothing to do, correct field already. */
  200|  3.89M|    }
  201|  3.22M|    else if (tag > iter->descriptor->largest_tag)
  ------------------
  |  Branch (201:14): [True: 976k, False: 2.24M]
  ------------------
  202|   976k|    {
  203|   976k|        return false;
  204|   976k|    }
  205|  2.24M|    else
  206|  2.24M|    {
  207|  2.24M|        pb_size_t start = iter->index;
  208|  2.24M|        uint32_t fieldinfo;
  209|       |
  210|  2.24M|        if (tag < iter->tag)
  ------------------
  |  Branch (210:13): [True: 657k, False: 1.58M]
  ------------------
  211|   657k|        {
  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|   657k|            iter->index = iter->descriptor->field_count;
  216|   657k|        }
  217|       |
  218|  2.24M|        do
  219|  32.2M|        {
  220|       |            /* Advance iterator but don't load values yet */
  221|  32.2M|            advance_iterator(iter);
  222|       |
  223|       |            /* Do fast check for tag number match */
  224|  32.2M|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  155|  32.2M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  225|       |
  226|  32.2M|            if (((fieldinfo >> 2) & 0x3F) == (tag & 0x3F))
  ------------------
  |  Branch (226:17): [True: 2.30M, False: 29.9M]
  ------------------
  227|  2.30M|            {
  228|       |                /* Good candidate, check further */
  229|  2.30M|                (void)load_descriptor_values(iter);
  230|       |
  231|  2.30M|                if (iter->tag == tag &&
  ------------------
  |  Branch (231:21): [True: 2.11M, False: 186k]
  ------------------
  232|  2.30M|                    PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  299|  2.11M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  2.11M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                                  PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  268|  2.11M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (232:21): [True: 2.09M, False: 22.4k]
  ------------------
  233|  2.09M|                {
  234|       |                    /* Found it */
  235|  2.09M|                    return true;
  236|  2.09M|                }
  237|  2.30M|            }
  238|  32.2M|        } while (iter->index != start);
  ------------------
  |  Branch (238:18): [True: 30.0M, False: 155k]
  ------------------
  239|       |
  240|       |        /* Searched all the way back to start, and found nothing. */
  241|   155k|        (void)load_descriptor_values(iter);
  242|   155k|        return false;
  243|  2.24M|    }
  244|  7.11M|}
pb_field_iter_find_extension:
  247|  23.7k|{
  248|  23.7k|    if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  299|  23.7k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  23.7k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  268|  23.7k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (248:9): [True: 0, False: 23.7k]
  ------------------
  249|      0|    {
  250|      0|        return true;
  251|      0|    }
  252|  23.7k|    else
  253|  23.7k|    {
  254|  23.7k|        pb_size_t start = iter->index;
  255|  23.7k|        uint32_t fieldinfo;
  256|       |
  257|  23.7k|        do
  258|   130k|        {
  259|       |            /* Advance iterator but don't load values yet */
  260|   130k|            advance_iterator(iter);
  261|       |
  262|       |            /* Do fast check for field type */
  263|   130k|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  155|   130k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  264|       |
  265|   130k|            if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  299|   130k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   130k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  268|   130k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (265:17): [True: 3.27k, False: 127k]
  ------------------
  266|  3.27k|            {
  267|  3.27k|                return load_descriptor_values(iter);
  268|  3.27k|            }
  269|   130k|        } while (iter->index != start);
  ------------------
  |  Branch (269:18): [True: 106k, False: 20.4k]
  ------------------
  270|       |
  271|       |        /* Searched all the way back to start, and found nothing. */
  272|  20.4k|        (void)load_descriptor_values(iter);
  273|  20.4k|        return false;
  274|  23.7k|    }
  275|  23.7k|}
pb_field_iter_begin_const:
  291|  88.6k|{
  292|  88.6k|    return pb_field_iter_begin(iter, desc, pb_const_cast(message));
  293|  88.6k|}
pb_field_iter_begin_extension_const:
  296|  2.56k|{
  297|  2.56k|    return pb_field_iter_begin_extension(iter, (pb_extension_t*)pb_const_cast(extension));
  298|  2.56k|}
pb_default_field_callback:
  301|  76.3k|{
  302|  76.3k|    if (field->data_size == sizeof(pb_callback_t))
  ------------------
  |  Branch (302:9): [True: 76.3k, False: 0]
  ------------------
  303|  76.3k|    {
  304|  76.3k|        pb_callback_t *pCallback = (pb_callback_t*)field->pData;
  305|       |
  306|  76.3k|        if (pCallback != NULL)
  ------------------
  |  Branch (306:13): [True: 76.3k, False: 0]
  ------------------
  307|  76.3k|        {
  308|  76.3k|            if (istream != NULL && pCallback->funcs.decode != NULL)
  ------------------
  |  Branch (308:17): [True: 76.3k, False: 0]
  |  Branch (308:36): [True: 5.46k, False: 70.8k]
  ------------------
  309|  5.46k|            {
  310|  5.46k|                return pCallback->funcs.decode(istream, field, &pCallback->arg);
  311|  5.46k|            }
  312|       |
  313|  70.8k|            if (ostream != NULL && pCallback->funcs.encode != NULL)
  ------------------
  |  Branch (313:17): [True: 0, False: 70.8k]
  |  Branch (313:36): [True: 0, False: 0]
  ------------------
  314|      0|            {
  315|      0|                return pCallback->funcs.encode(ostream, field, &pCallback->arg);
  316|      0|            }
  317|  70.8k|        }
  318|  76.3k|    }
  319|       |
  320|  70.8k|    return true; /* Success, but didn't do anything */
  321|       |
  322|  76.3k|}
pb_common.c:load_descriptor_values:
    9|  4.82M|{
   10|  4.82M|    uint32_t word0;
   11|  4.82M|    uint32_t data_offset;
   12|  4.82M|    int_least8_t size_offset;
   13|       |
   14|  4.82M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (14:9): [True: 202k, False: 4.62M]
  ------------------
   15|   202k|        return false;
   16|       |
   17|  4.62M|    word0 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  155|  4.62M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   18|  4.62M|    iter->type = (pb_type_t)((word0 >> 8) & 0xFF);
   19|       |
   20|  4.62M|    switch(word0 & 3)
   21|  4.62M|    {
   22|   453k|        case 0: {
  ------------------
  |  Branch (22:9): [True: 453k, False: 4.17M]
  ------------------
   23|       |            /* 1-word format */
   24|   453k|            iter->array_size = 1;
   25|   453k|            iter->tag = (pb_size_t)((word0 >> 2) & 0x3F);
   26|   453k|            size_offset = (int_least8_t)((word0 >> 24) & 0x0F);
   27|   453k|            data_offset = (word0 >> 16) & 0xFF;
   28|   453k|            iter->data_size = (pb_size_t)((word0 >> 28) & 0x0F);
   29|   453k|            break;
   30|      0|        }
   31|       |
   32|  3.68M|        case 1: {
  ------------------
  |  Branch (32:9): [True: 3.68M, False: 939k]
  ------------------
   33|       |            /* 2-word format */
   34|  3.68M|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  155|  3.68M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   35|       |
   36|  3.68M|            iter->array_size = (pb_size_t)((word0 >> 16) & 0x0FFF);
   37|  3.68M|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 28) << 6));
   38|  3.68M|            size_offset = (int_least8_t)((word0 >> 28) & 0x0F);
   39|  3.68M|            data_offset = word1 & 0xFFFF;
   40|  3.68M|            iter->data_size = (pb_size_t)((word1 >> 16) & 0x0FFF);
   41|  3.68M|            break;
   42|      0|        }
   43|       |
   44|   409k|        case 2: {
  ------------------
  |  Branch (44:9): [True: 409k, False: 4.21M]
  ------------------
   45|       |            /* 4-word format */
   46|   409k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  155|   409k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   47|   409k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  155|   409k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   48|   409k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  155|   409k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   49|       |
   50|   409k|            iter->array_size = (pb_size_t)(word0 >> 16);
   51|   409k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   52|   409k|            size_offset = (int_least8_t)(word1 & 0xFF);
   53|   409k|            data_offset = word2;
   54|   409k|            iter->data_size = (pb_size_t)word3;
   55|   409k|            break;
   56|      0|        }
   57|       |
   58|  76.1k|        default: {
  ------------------
  |  Branch (58:9): [True: 76.1k, False: 4.54M]
  ------------------
   59|       |            /* 8-word format */
   60|  76.1k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  155|  76.1k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   61|  76.1k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  155|  76.1k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   62|  76.1k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  155|  76.1k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   63|  76.1k|            uint32_t word4 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 4]);
  ------------------
  |  |  155|  76.1k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   64|       |
   65|  76.1k|            iter->array_size = (pb_size_t)word4;
   66|  76.1k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   67|  76.1k|            size_offset = (int_least8_t)(word1 & 0xFF);
   68|  76.1k|            data_offset = word2;
   69|  76.1k|            iter->data_size = (pb_size_t)word3;
   70|  76.1k|            break;
   71|      0|        }
   72|  4.62M|    }
   73|       |
   74|  4.62M|    if (!iter->message)
  ------------------
  |  Branch (74:9): [True: 0, False: 4.62M]
  ------------------
   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.62M|    else
   81|  4.62M|    {
   82|  4.62M|        iter->pField = (char*)iter->message + data_offset;
   83|       |
   84|  4.62M|        if (size_offset)
  ------------------
  |  Branch (84:13): [True: 1.29M, False: 3.32M]
  ------------------
   85|  1.29M|        {
   86|  1.29M|            iter->pSize = (char*)iter->pField - size_offset;
   87|  1.29M|        }
   88|  3.32M|        else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  298|  3.32M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  3.32M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  285|  6.65M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (88:18): [True: 92.2k, False: 3.23M]
  ------------------
   89|  3.32M|                 (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  297|  92.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  92.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                               (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  292|   184k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (89:19): [True: 44.8k, False: 47.4k]
  ------------------
   90|  92.2k|                  PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  297|  47.4k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  47.4k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                                PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  293|  47.4k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (90:19): [True: 0, False: 47.4k]
  ------------------
   91|  44.8k|        {
   92|       |            /* Fixed count array */
   93|  44.8k|            iter->pSize = &iter->array_size;
   94|  44.8k|        }
   95|  3.28M|        else
   96|  3.28M|        {
   97|  3.28M|            iter->pSize = NULL;
   98|  3.28M|        }
   99|       |
  100|  4.62M|        if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  297|  4.62M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  4.62M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  293|  9.25M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (100:13): [True: 0, False: 4.62M]
  |  Branch (100:57): [True: 0, False: 0]
  ------------------
  101|      0|        {
  102|      0|            iter->pData = *(void**)iter->pField;
  103|      0|        }
  104|  4.62M|        else
  105|  4.62M|        {
  106|  4.62M|            iter->pData = iter->pField;
  107|  4.62M|        }
  108|  4.62M|    }
  109|       |
  110|  4.62M|    if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  300|  4.62M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|  4.62M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  4.62M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|  9.25M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 671k, False: 3.95M]
  |  |  ------------------
  |  |  301|  4.62M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|  3.95M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  3.95M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|  3.95M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 54.2k, False: 3.89M]
  |  |  ------------------
  ------------------
  111|   725k|    {
  112|   725k|        iter->submsg_desc = iter->descriptor->submsg_info[iter->submessage_index];
  113|   725k|    }
  114|  3.89M|    else
  115|  3.89M|    {
  116|  3.89M|        iter->submsg_desc = NULL;
  117|  3.89M|    }
  118|       |
  119|  4.62M|    return true;
  120|  4.62M|}
pb_common.c:advance_iterator:
  123|  34.0M|{
  124|  34.0M|    iter->index++;
  125|       |
  126|  34.0M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (126:9): [True: 1.00M, False: 33.0M]
  ------------------
  127|  1.00M|    {
  128|       |        /* Restart */
  129|  1.00M|        iter->index = 0;
  130|  1.00M|        iter->field_info_index = 0;
  131|  1.00M|        iter->submessage_index = 0;
  132|  1.00M|        iter->required_field_index = 0;
  133|  1.00M|    }
  134|  33.0M|    else
  135|  33.0M|    {
  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|  33.0M|        uint32_t prev_descriptor = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  155|  33.0M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  143|  33.0M|        pb_type_t prev_type = (prev_descriptor >> 8) & 0xFF;
  144|  33.0M|        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|  33.0M|        iter->field_info_index = (pb_size_t)(iter->field_info_index + descriptor_len);
  151|  33.0M|        iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  298|  33.0M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  33.0M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  282|  33.0M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  152|  33.0M|        iter->submessage_index = (pb_size_t)(iter->submessage_index + PB_LTYPE_IS_SUBMSG(prev_type));
  ------------------
  |  |  300|  33.0M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|  33.0M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  33.0M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|  66.1M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 3.94M, False: 29.1M]
  |  |  ------------------
  |  |  301|  33.0M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|  29.1M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  29.1M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|  29.1M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 132k, False: 29.0M]
  |  |  ------------------
  ------------------
  153|  33.0M|    }
  154|  34.0M|}
pb_common.c:pb_const_cast:
  278|  91.1k|{
  279|       |    /* Note: this casts away const, in order to use the common field iterator
  280|       |     * logic for both encoding and decoding. The cast is done using union
  281|       |     * to avoid spurious compiler warnings. */
  282|  91.1k|    union {
  283|  91.1k|        void *p1;
  284|  91.1k|        const void *p2;
  285|  91.1k|    } t;
  286|  91.1k|    t.p2 = p;
  287|  91.1k|    return t.p1;
  288|  91.1k|}

pb_read:
   83|  5.52M|{
   84|  5.52M|    if (count == 0)
  ------------------
  |  Branch (84:9): [True: 265k, False: 5.25M]
  ------------------
   85|   265k|        return true;
   86|       |
   87|  5.25M|#ifndef PB_BUFFER_ONLY
   88|  5.25M|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (88:6): [True: 382k, False: 4.87M]
  |  Branch (88:21): [True: 88.2k, False: 294k]
  ------------------
   89|  88.2k|	{
   90|       |		/* Skip input bytes */
   91|  88.2k|		pb_byte_t tmp[16];
   92|   435k|		while (count > 16)
  ------------------
  |  Branch (92:10): [True: 346k, False: 88.2k]
  ------------------
   93|   346k|		{
   94|   346k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (94:8): [True: 0, False: 346k]
  ------------------
   95|      0|				return false;
   96|       |			
   97|   346k|			count -= 16;
   98|   346k|		}
   99|       |		
  100|  88.2k|		return pb_read(stream, tmp, count);
  101|  88.2k|	}
  102|  5.17M|#endif
  103|       |
  104|  5.17M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (104:9): [True: 225, False: 5.17M]
  ------------------
  105|    225|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  894|    225|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|    225|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 225]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  106|       |    
  107|  5.17M|#ifndef PB_BUFFER_ONLY
  108|  5.17M|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (108:9): [True: 0, False: 5.17M]
  ------------------
  109|      0|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  110|       |#else
  111|       |    if (!buf_read(stream, buf, count))
  112|       |        return false;
  113|       |#endif
  114|       |    
  115|  5.17M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (115:9): [True: 0, False: 5.17M]
  ------------------
  116|      0|        stream->bytes_left = 0;
  117|  5.17M|    else
  118|  5.17M|        stream->bytes_left -= count;
  119|       |
  120|  5.17M|    return true;
  121|  5.17M|}
pb_istream_from_buffer:
  144|   110k|{
  145|   110k|    pb_istream_t stream;
  146|       |    /* Cast away the const from buf without a compiler error.  We are
  147|       |     * careful to use it only in a const manner in the callbacks.
  148|       |     */
  149|   110k|    union {
  150|   110k|        void *state;
  151|   110k|        const void *c_state;
  152|   110k|    } state;
  153|       |#ifdef PB_BUFFER_ONLY
  154|       |    stream.callback = NULL;
  155|       |#else
  156|   110k|    stream.callback = &buf_read;
  157|   110k|#endif
  158|   110k|    state.c_state = buf;
  159|   110k|    stream.state = state.state;
  160|   110k|    stream.bytes_left = msglen;
  161|   110k|#ifndef PB_NO_ERRMSG
  162|   110k|    stream.errmsg = NULL;
  163|   110k|#endif
  164|   110k|    return stream;
  165|   110k|}
pb_decode_varint32:
  238|  1.22M|{
  239|  1.22M|    return pb_decode_varint32_eof(stream, dest, NULL);
  240|  1.22M|}
pb_decode_varint:
  244|  4.95M|{
  245|  4.95M|    pb_byte_t byte;
  246|  4.95M|    uint_fast8_t bitpos = 0;
  247|  4.95M|    uint64_t result = 0;
  248|       |    
  249|  4.95M|    do
  250|  6.23M|    {
  251|  6.23M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (251:13): [True: 46, False: 6.23M]
  ------------------
  252|     46|            return false;
  253|       |
  254|  6.23M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (254:13): [True: 51.0k, False: 6.18M]
  |  Branch (254:29): [True: 25, False: 51.0k]
  ------------------
  255|     25|            PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  894|     25|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     25|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  256|       |
  257|  6.23M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  258|  6.23M|        bitpos = (uint_fast8_t)(bitpos + 7);
  259|  6.23M|    } while (byte & 0x80);
  ------------------
  |  Branch (259:14): [True: 1.27M, False: 4.95M]
  ------------------
  260|       |    
  261|  4.95M|    *dest = result;
  262|  4.95M|    return true;
  263|  4.95M|}
pb_decode_tag:
  292|  7.67M|{
  293|  7.67M|    uint32_t temp;
  294|  7.67M|    *eof = false;
  295|  7.67M|    *wire_type = (pb_wire_type_t) 0;
  296|  7.67M|    *tag = 0;
  297|       |    
  298|  7.67M|    if (!pb_decode_varint32_eof(stream, &temp, eof))
  ------------------
  |  Branch (298:9): [True: 1.36k, False: 7.67M]
  ------------------
  299|  1.36k|    {
  300|  1.36k|        return false;
  301|  1.36k|    }
  302|       |    
  303|  7.67M|    *tag = temp >> 3;
  304|  7.67M|    *wire_type = (pb_wire_type_t)(temp & 7);
  305|  7.67M|    return true;
  306|  7.67M|}
pb_skip_field:
  309|  1.12M|{
  310|  1.12M|    switch (wire_type)
  311|  1.12M|    {
  312|   627k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (312:9): [True: 627k, False: 496k]
  ------------------
  313|  79.8k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (313:9): [True: 79.8k, False: 1.04M]
  ------------------
  314|   267k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (314:9): [True: 267k, False: 855k]
  ------------------
  315|   149k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (315:9): [True: 149k, False: 974k]
  ------------------
  316|    108|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  894|    108|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|    108|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 108]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (316:9): [True: 108, False: 1.12M]
  ------------------
  317|  1.12M|    }
  318|  1.12M|}
pb_make_string_substream:
  363|   425k|{
  364|   425k|    uint32_t size;
  365|   425k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (365:9): [True: 76, False: 425k]
  ------------------
  366|     76|        return false;
  367|       |    
  368|   425k|    *substream = *stream;
  369|   425k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (369:9): [True: 78, False: 425k]
  ------------------
  370|     78|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  894|     78|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     78|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 78]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  371|       |    
  372|   425k|    substream->bytes_left = (size_t)size;
  373|   425k|    stream->bytes_left -= (size_t)size;
  374|   425k|    return true;
  375|   425k|}
pb_close_string_substream:
  378|   425k|{
  379|   425k|    if (substream->bytes_left) {
  ------------------
  |  Branch (379:9): [True: 27.2k, False: 398k]
  ------------------
  380|  27.2k|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (380:13): [True: 0, False: 27.2k]
  ------------------
  381|      0|            return false;
  382|  27.2k|    }
  383|       |
  384|   425k|    stream->state = substream->state;
  385|       |
  386|   425k|#ifndef PB_NO_ERRMSG
  387|   425k|    stream->errmsg = substream->errmsg;
  388|   425k|#endif
  389|   425k|    return true;
  390|   425k|}
pb_decode_ex:
 1155|  2.98k|{
 1156|  2.98k|    bool status;
 1157|       |
 1158|  2.98k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  100|  2.98k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1158:9): [True: 2.98k, False: 0]
  ------------------
 1159|  2.98k|    {
 1160|  2.98k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1161|  2.98k|    }
 1162|      0|    else
 1163|      0|    {
 1164|      0|      pb_istream_t substream;
 1165|      0|      if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1165:11): [True: 0, False: 0]
  ------------------
 1166|      0|        return false;
 1167|       |
 1168|      0|      status = pb_decode_inner(&substream, fields, dest_struct, flags);
 1169|       |
 1170|      0|      if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1170:11): [True: 0, False: 0]
  ------------------
 1171|      0|        return false;
 1172|      0|    }
 1173|       |    
 1174|       |#ifdef PB_ENABLE_MALLOC
 1175|       |    if (!status)
 1176|       |        pb_release(fields, dest_struct);
 1177|       |#endif
 1178|       |    
 1179|  2.98k|    return status;
 1180|  2.98k|}
pb_decode:
 1183|  5.12k|{
 1184|  5.12k|    bool status;
 1185|       |
 1186|  5.12k|    status = pb_decode_inner(stream, fields, dest_struct, 0);
 1187|       |
 1188|       |#ifdef PB_ENABLE_MALLOC
 1189|       |    if (!status)
 1190|       |        pb_release(fields, dest_struct);
 1191|       |#endif
 1192|       |
 1193|  5.12k|    return status;
 1194|  5.12k|}
pb_release:
 1337|  8.11k|{
 1338|       |    /* Nothing to release without PB_ENABLE_MALLOC. */
 1339|  8.11k|    PB_UNUSED(fields);
  ------------------
  |  |  143|  8.11k|#define PB_UNUSED(x) (void)(x)
  ------------------
 1340|  8.11k|    PB_UNUSED(dest_struct);
  ------------------
  |  |  143|  8.11k|#define PB_UNUSED(x) (void)(x)
  ------------------
 1341|  8.11k|}
pb_decode_bool:
 1347|   219k|{
 1348|   219k|    uint32_t value;
 1349|   219k|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1349:9): [True: 12, False: 219k]
  ------------------
 1350|     12|        return false;
 1351|       |
 1352|   219k|    *(bool*)dest = (value != 0);
 1353|   219k|    return true;
 1354|   219k|}
pb_decode_svarint:
 1357|   187k|{
 1358|   187k|    pb_uint64_t value;
  ------------------
  |  |   58|   187k|#define pb_uint64_t uint64_t
  ------------------
 1359|   187k|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1359:9): [True: 25, False: 187k]
  ------------------
 1360|     25|        return false;
 1361|       |    
 1362|   187k|    if (value & 1)
  ------------------
  |  Branch (1362:9): [True: 32.3k, False: 155k]
  ------------------
 1363|  32.3k|        *dest = (pb_int64_t)(~(value >> 1));
 1364|   155k|    else
 1365|   155k|        *dest = (pb_int64_t)(value >> 1);
 1366|       |    
 1367|   187k|    return true;
 1368|   187k|}
pb_decode_fixed32:
 1371|   337k|{
 1372|   337k|    union {
 1373|   337k|        uint32_t fixed32;
 1374|   337k|        pb_byte_t bytes[4];
 1375|   337k|    } u;
 1376|       |
 1377|   337k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1377:9): [True: 16, False: 337k]
  ------------------
 1378|     16|        return false;
 1379|       |
 1380|   337k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1381|       |    /* fast path - if we know that we're on little endian, assign directly */
 1382|   337k|    *(uint32_t*)dest = u.fixed32;
 1383|       |#else
 1384|       |    *(uint32_t*)dest = ((uint32_t)u.bytes[0] << 0) |
 1385|       |                       ((uint32_t)u.bytes[1] << 8) |
 1386|       |                       ((uint32_t)u.bytes[2] << 16) |
 1387|       |                       ((uint32_t)u.bytes[3] << 24);
 1388|       |#endif
 1389|   337k|    return true;
 1390|   337k|}
pb_decode_fixed64:
 1394|   225k|{
 1395|   225k|    union {
 1396|   225k|        uint64_t fixed64;
 1397|   225k|        pb_byte_t bytes[8];
 1398|   225k|    } u;
 1399|       |
 1400|   225k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1400:9): [True: 15, False: 225k]
  ------------------
 1401|     15|        return false;
 1402|       |
 1403|   225k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1404|       |    /* fast path - if we know that we're on little endian, assign directly */
 1405|   225k|    *(uint64_t*)dest = u.fixed64;
 1406|       |#else
 1407|       |    *(uint64_t*)dest = ((uint64_t)u.bytes[0] << 0) |
 1408|       |                       ((uint64_t)u.bytes[1] << 8) |
 1409|       |                       ((uint64_t)u.bytes[2] << 16) |
 1410|       |                       ((uint64_t)u.bytes[3] << 24) |
 1411|       |                       ((uint64_t)u.bytes[4] << 32) |
 1412|       |                       ((uint64_t)u.bytes[5] << 40) |
 1413|       |                       ((uint64_t)u.bytes[6] << 48) |
 1414|       |                       ((uint64_t)u.bytes[7] << 56);
 1415|       |#endif
 1416|   225k|    return true;
 1417|   225k|}
pb_decode.c:buf_read:
   70|  16.8M|{
   71|  16.8M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   72|  16.8M|    stream->state = (pb_byte_t*)stream->state + count;
   73|       |    
   74|  16.8M|    if (buf != NULL)
  ------------------
  |  Branch (74:9): [True: 16.5M, False: 294k]
  ------------------
   75|  16.5M|    {
   76|  16.5M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   77|  16.5M|    }
   78|       |    
   79|  16.8M|    return true;
   80|  16.8M|}
pb_decode.c:pb_decode_varint32_eof:
  172|  8.89M|{
  173|  8.89M|    pb_byte_t byte;
  174|  8.89M|    uint32_t result;
  175|       |    
  176|  8.89M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (176:9): [True: 1.41k, False: 8.89M]
  ------------------
  177|  1.41k|    {
  178|  1.41k|        if (stream->bytes_left == 0)
  ------------------
  |  Branch (178:13): [True: 1.41k, False: 0]
  ------------------
  179|  1.41k|        {
  180|  1.41k|            if (eof)
  ------------------
  |  Branch (180:17): [True: 1.28k, False: 133]
  ------------------
  181|  1.28k|            {
  182|  1.28k|                *eof = true;
  183|  1.28k|            }
  184|  1.41k|        }
  185|       |
  186|  1.41k|        return false;
  187|  1.41k|    }
  188|       |    
  189|  8.89M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (189:9): [True: 7.54M, False: 1.34M]
  ------------------
  190|  7.54M|    {
  191|       |        /* Quick case, 1 byte value */
  192|  7.54M|        result = byte;
  193|  7.54M|    }
  194|  1.34M|    else
  195|  1.34M|    {
  196|       |        /* Multibyte case */
  197|  1.34M|        uint_fast8_t bitpos = 7;
  198|  1.34M|        result = byte & 0x7F;
  199|       |        
  200|  1.34M|        do
  201|  1.76M|        {
  202|  1.76M|            if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (202:17): [True: 36, False: 1.76M]
  ------------------
  203|     36|                return false;
  204|       |            
  205|  1.76M|            if (bitpos >= 32)
  ------------------
  |  Branch (205:17): [True: 34.3k, False: 1.72M]
  ------------------
  206|  34.3k|            {
  207|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  208|  34.3k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (208:44): [True: 29.7k, False: 4.62k]
  ------------------
  209|  34.3k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (209:41): [True: 3.75k, False: 30.5k]
  ------------------
  210|  34.3k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (210:27): [True: 30.5k, False: 7]
  |  Branch (210:50): [True: 30.5k, False: 45]
  ------------------
  211|       |
  212|  34.3k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (212:21): [True: 2, False: 34.3k]
  |  Branch (212:37): [True: 51, False: 34.2k]
  ------------------
  213|     53|                {
  214|     53|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  894|     53|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     53|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 53]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  215|     53|                }
  216|  34.3k|            }
  217|  1.72M|            else if (bitpos == 28)
  ------------------
  |  Branch (217:22): [True: 21.2k, False: 1.70M]
  ------------------
  218|  21.2k|            {
  219|  21.2k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (219:21): [True: 8.83k, False: 12.3k]
  |  Branch (219:43): [True: 11, False: 8.82k]
  ------------------
  220|     11|                {
  221|     11|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  894|     11|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     11|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  222|     11|                }
  223|  21.1k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  224|  21.1k|            }
  225|  1.70M|            else
  226|  1.70M|            {
  227|  1.70M|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  228|  1.70M|            }
  229|  1.76M|            bitpos = (uint_fast8_t)(bitpos + 7);
  230|  1.76M|        } while (byte & 0x80);
  ------------------
  |  Branch (230:18): [True: 412k, False: 1.34M]
  ------------------
  231|  1.34M|   }
  232|       |   
  233|  8.89M|   *dest = result;
  234|  8.89M|   return true;
  235|  8.89M|}
pb_decode.c:pb_readbyte:
  126|  16.8M|{
  127|  16.8M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (127:9): [True: 215, False: 16.8M]
  ------------------
  128|    215|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  894|    215|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|    215|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 215]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  129|       |
  130|  16.8M|#ifndef PB_BUFFER_ONLY
  131|  16.8M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (131:9): [True: 1.28k, False: 16.8M]
  ------------------
  132|  1.28k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  894|  1.28k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|  1.28k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 1.28k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  133|       |#else
  134|       |    *buf = *(const pb_byte_t*)stream->state;
  135|       |    stream->state = (pb_byte_t*)stream->state + 1;
  136|       |#endif
  137|       |
  138|  16.8M|    stream->bytes_left--;
  139|       |    
  140|  16.8M|    return true;    
  141|  16.8M|}
pb_decode.c:pb_skip_varint:
  267|   627k|{
  268|   627k|    pb_byte_t byte;
  269|   627k|    do
  270|  3.68M|    {
  271|  3.68M|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (271:13): [True: 74, False: 3.68M]
  ------------------
  272|     74|            return false;
  273|  3.68M|    } while (byte & 0x80);
  ------------------
  |  Branch (273:14): [True: 3.05M, False: 626k]
  ------------------
  274|   626k|    return true;
  275|   627k|}
pb_decode.c:pb_skip_string:
  278|   267k|{
  279|   267k|    uint32_t length;
  280|   267k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (280:9): [True: 49, False: 267k]
  ------------------
  281|     49|        return false;
  282|       |    
  283|   267k|    if ((size_t)length != length)
  ------------------
  |  Branch (283:9): [True: 0, False: 267k]
  ------------------
  284|      0|    {
  285|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  286|      0|    }
  287|       |
  288|   267k|    return pb_read(stream, NULL, (size_t)length);
  289|   267k|}
pb_decode.c:pb_decode_inner:
  991|   317k|{
  992|   317k|    uint32_t extension_range_start = 0;
  993|   317k|    pb_extension_t *extensions = NULL;
  994|       |
  995|       |    /* 'fixed_count_field' and 'fixed_count_size' track position of a repeated fixed
  996|       |     * count field. This can only handle _one_ repeated fixed count field that
  997|       |     * is unpacked and unordered among other (non repeated fixed count) fields.
  998|       |     */
  999|   317k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  313|   317k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
 1000|   317k|    pb_size_t fixed_count_size = 0;
 1001|   317k|    pb_size_t fixed_count_total_size = 0;
 1002|       |
 1003|   317k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1004|   317k|    const uint32_t allbits = ~(uint32_t)0;
 1005|   317k|    pb_field_iter_t iter;
 1006|       |
 1007|   317k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1007:9): [True: 152k, False: 164k]
  ------------------
 1008|   152k|    {
 1009|   152k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |   99|   152k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1009:13): [True: 12.3k, False: 140k]
  ------------------
 1010|  12.3k|        {
 1011|  12.3k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1011:17): [True: 0, False: 12.3k]
  ------------------
 1012|      0|                PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1013|  12.3k|        }
 1014|   152k|    }
 1015|       |
 1016|  7.43M|    while (stream->bytes_left)
  ------------------
  |  Branch (1016:12): [True: 7.12M, False: 314k]
  ------------------
 1017|  7.12M|    {
 1018|  7.12M|        uint32_t tag;
 1019|  7.12M|        pb_wire_type_t wire_type;
 1020|  7.12M|        bool eof;
 1021|       |
 1022|  7.12M|        if (!pb_decode_tag(stream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1022:13): [True: 1.36k, False: 7.11M]
  ------------------
 1023|  1.36k|        {
 1024|  1.36k|            if (eof)
  ------------------
  |  Branch (1024:17): [True: 1.28k, False: 85]
  ------------------
 1025|  1.28k|                break;
 1026|     85|            else
 1027|     85|                return false;
 1028|  1.36k|        }
 1029|       |
 1030|  7.11M|        if (tag == 0)
  ------------------
  |  Branch (1030:13): [True: 61, False: 7.11M]
  ------------------
 1031|     61|        {
 1032|     61|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  101|     61|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1032:15): [True: 0, False: 61]
  ------------------
 1033|      0|          {
 1034|      0|            break;
 1035|      0|          }
 1036|     61|          else
 1037|     61|          {
 1038|     61|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  894|     61|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     61|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 61]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1039|     61|          }
 1040|     61|        }
 1041|       |
 1042|  7.11M|        if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  299|  5.98M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  5.98M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  268|  5.98M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1042:13): [True: 1.13M, False: 5.98M]
  |  Branch (1042:48): [True: 250, False: 5.98M]
  ------------------
 1043|  1.13M|        {
 1044|       |            /* No match found, check if it matches an extension. */
 1045|  1.13M|            if (extension_range_start == 0)
  ------------------
  |  Branch (1045:17): [True: 23.7k, False: 1.10M]
  ------------------
 1046|  23.7k|            {
 1047|  23.7k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1047:21): [True: 3.27k, False: 20.4k]
  ------------------
 1048|  3.27k|                {
 1049|  3.27k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1050|  3.27k|                    extension_range_start = iter.tag;
 1051|  3.27k|                }
 1052|       |
 1053|  23.7k|                if (!extensions)
  ------------------
  |  Branch (1053:21): [True: 21.2k, False: 2.51k]
  ------------------
 1054|  21.2k|                {
 1055|  21.2k|                    extension_range_start = (uint32_t)-1;
 1056|  21.2k|                }
 1057|  23.7k|            }
 1058|       |
 1059|  1.13M|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1059:17): [True: 163k, False: 969k]
  ------------------
 1060|   163k|            {
 1061|   163k|                size_t pos = stream->bytes_left;
 1062|       |
 1063|   163k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1063:21): [True: 59, False: 162k]
  ------------------
 1064|     59|                    return false;
 1065|       |
 1066|   162k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1066:21): [True: 8.22k, False: 154k]
  ------------------
 1067|  8.22k|                {
 1068|       |                    /* The field was handled */
 1069|  8.22k|                    continue;
 1070|  8.22k|                }
 1071|   162k|            }
 1072|       |
 1073|       |            /* No match found, skip data */
 1074|  1.12M|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1074:17): [True: 327, False: 1.12M]
  ------------------
 1075|    327|                return false;
 1076|  1.12M|            continue;
 1077|  1.12M|        }
 1078|       |
 1079|       |        /* If a repeated fixed count field was found, get size from
 1080|       |         * 'fixed_count_field' as there is no counter contained in the struct.
 1081|       |         */
 1082|  5.98M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  298|  5.98M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  5.98M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  285|  11.9M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1082:13): [True: 37.1k, False: 5.94M]
  |  Branch (1082:57): [True: 3.55k, False: 33.5k]
  ------------------
 1083|  3.55k|        {
 1084|  3.55k|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1084:17): [True: 3.31k, False: 237]
  ------------------
 1085|       |                /* If the new fixed count field does not match the previous one,
 1086|       |                 * check that the previous one is NULL or that it finished
 1087|       |                 * receiving all the expected data.
 1088|       |                 */
 1089|  3.31k|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  313|  6.62k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1089:21): [True: 1.80k, False: 1.50k]
  ------------------
 1090|  3.31k|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1090:21): [True: 3, False: 1.80k]
  ------------------
 1091|      3|                {
 1092|      3|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  894|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1093|      3|                }
 1094|       |
 1095|  3.31k|                fixed_count_field = iter.index;
 1096|  3.31k|                fixed_count_size = 0;
 1097|  3.31k|                fixed_count_total_size = iter.array_size;
 1098|  3.31k|            }
 1099|       |
 1100|  3.54k|            iter.pSize = &fixed_count_size;
 1101|  3.54k|        }
 1102|       |
 1103|  5.98M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  298|  5.98M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  5.98M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  282|  11.9M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1103:13): [True: 5.50M, False: 481k]
  ------------------
 1104|  5.98M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  204|  5.50M|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1104:16): [True: 5.50M, False: 0]
  ------------------
 1105|  5.50M|        {
 1106|  5.50M|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1107|  5.50M|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1108|  5.50M|        }
 1109|       |
 1110|  5.98M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1110:13): [True: 1.15k, False: 5.98M]
  ------------------
 1111|  1.15k|            return false;
 1112|  5.98M|    }
 1113|       |
 1114|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1115|   315k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  313|   631k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1115:9): [True: 1.45k, False: 314k]
  ------------------
 1116|   315k|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1116:9): [True: 5, False: 1.44k]
  ------------------
 1117|      5|    {
 1118|      5|        PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  894|      5|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      5|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1119|      5|    }
 1120|       |
 1121|       |    /* Check that all required fields were present. */
 1122|   315k|    {
 1123|   315k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1124|       |
 1125|   315k|        if (req_field_count > 0)
  ------------------
  |  Branch (1125:13): [True: 143k, False: 172k]
  ------------------
 1126|   143k|        {
 1127|   143k|            pb_size_t i;
 1128|       |
 1129|   143k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  204|   143k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1129:17): [True: 0, False: 143k]
  ------------------
 1130|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  204|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1131|       |
 1132|       |            /* Check the whole words */
 1133|   143k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1133:25): [True: 0, False: 143k]
  ------------------
 1134|      0|            {
 1135|      0|                if (fields_seen.bitfield[i] != allbits)
  ------------------
  |  Branch (1135:21): [True: 0, False: 0]
  ------------------
 1136|      0|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1137|      0|            }
 1138|       |
 1139|       |            /* Check the remaining bits (if any) */
 1140|   143k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1140:17): [True: 143k, False: 0]
  ------------------
 1141|   143k|            {
 1142|   143k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1142:21): [True: 313, False: 142k]
  ------------------
 1143|   143k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1144|    313|                {
 1145|    313|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  894|    313|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|    313|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 313]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1146|    313|                }
 1147|   143k|            }
 1148|   143k|        }
 1149|   315k|    }
 1150|       |
 1151|   315k|    return true;
 1152|   315k|}
pb_decode.c:pb_message_set_to_defaults:
  952|   102k|{
  953|   102k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   49|   102k|#define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
  954|   102k|    uint32_t tag = 0;
  955|   102k|    pb_wire_type_t wire_type = PB_WT_VARINT;
  956|   102k|    bool eof;
  957|       |
  958|   102k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (958:9): [True: 96.6k, False: 5.55k]
  ------------------
  959|  96.6k|    {
  960|  96.6k|        defstream = pb_istream_from_buffer(iter->descriptor->default_value, (size_t)-1);
  961|  96.6k|        if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (961:13): [True: 0, False: 96.6k]
  ------------------
  962|      0|            return false;
  963|  96.6k|    }
  964|       |
  965|   102k|    do
  966|   888k|    {
  967|   888k|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (967:13): [True: 0, False: 888k]
  ------------------
  968|      0|            return false;
  969|       |
  970|   888k|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (970:13): [True: 825k, False: 62.3k]
  |  Branch (970:25): [True: 455k, False: 370k]
  ------------------
  971|   455k|        {
  972|       |            /* We have a default value for this field in the defstream */
  973|   455k|            if (!decode_field(&defstream, wire_type, iter))
  ------------------
  |  Branch (973:17): [True: 0, False: 455k]
  ------------------
  974|      0|                return false;
  975|   455k|            if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (975:17): [True: 0, False: 455k]
  ------------------
  976|      0|                return false;
  977|       |
  978|   455k|            if (iter->pSize)
  ------------------
  |  Branch (978:17): [True: 222k, False: 232k]
  ------------------
  979|   222k|                *(bool*)iter->pSize = false;
  980|   455k|        }
  981|   888k|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (981:14): [True: 785k, False: 102k]
  ------------------
  982|       |
  983|   102k|    return true;
  984|   102k|}
pb_decode.c:pb_field_set_to_default:
  870|   888k|{
  871|   888k|    pb_type_t type;
  872|   888k|    type = field->type;
  873|       |
  874|   888k|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  299|   888k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   888k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  268|   888k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (874:9): [True: 8.11k, False: 879k]
  ------------------
  875|  8.11k|    {
  876|  8.11k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  877|  13.6k|        while (ext != NULL)
  ------------------
  |  Branch (877:16): [True: 5.55k, False: 8.11k]
  ------------------
  878|  5.55k|        {
  879|  5.55k|            pb_field_iter_t ext_iter;
  880|  5.55k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (880:17): [True: 5.55k, False: 0]
  ------------------
  881|  5.55k|            {
  882|  5.55k|                ext->found = false;
  883|  5.55k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (883:21): [True: 0, False: 5.55k]
  ------------------
  884|      0|                    return false;
  885|  5.55k|            }
  886|  5.55k|            ext = ext->next;
  887|  5.55k|        }
  888|  8.11k|    }
  889|   879k|    else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  297|   879k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|   879k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  292|   879k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (889:14): [True: 827k, False: 52.3k]
  ------------------
  890|   827k|    {
  891|   827k|        bool init_data = true;
  892|   827k|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  298|   827k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   827k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  283|  1.65M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (892:13): [True: 238k, False: 588k]
  |  Branch (892:52): [True: 238k, False: 0]
  ------------------
  893|   238k|        {
  894|       |            /* Set has_field to false. Still initialize the optional field
  895|       |             * itself also. */
  896|   238k|            *(bool*)field->pSize = false;
  897|   238k|        }
  898|   588k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  298|   588k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   588k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  285|  1.17M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (898:18): [True: 143k, False: 445k]
  ------------------
  899|   588k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  298|   445k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   445k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|   445k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (899:18): [True: 24.3k, False: 420k]
  ------------------
  900|   167k|        {
  901|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
  902|       |               ONEOF: Set which_field to 0. */
  903|   167k|            *(pb_size_t*)field->pSize = 0;
  904|   167k|            init_data = false;
  905|   167k|        }
  906|       |
  907|   827k|        if (init_data)
  ------------------
  |  Branch (907:13): [True: 659k, False: 167k]
  ------------------
  908|   659k|        {
  909|   659k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  300|  1.31M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|   659k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|   659k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|  1.31M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 62.3k, False: 597k]
  |  |  ------------------
  |  |  301|  1.31M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|   597k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|   597k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|   597k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 0, False: 597k]
  |  |  ------------------
  ------------------
  910|   659k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (910:18): [True: 24.3k, False: 38.0k]
  ------------------
  911|  62.3k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (911:18): [True: 0, False: 38.0k]
  ------------------
  912|  62.3k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (912:18): [True: 0, False: 38.0k]
  ------------------
  913|  24.3k|            {
  914|       |                /* Initialize submessage to defaults.
  915|       |                 * Only needed if it has default values
  916|       |                 * or callback/submessage fields. */
  917|  24.3k|                pb_field_iter_t submsg_iter;
  918|  24.3k|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (918:21): [True: 24.3k, False: 0]
  ------------------
  919|  24.3k|                {
  920|  24.3k|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (920:25): [True: 0, False: 24.3k]
  ------------------
  921|      0|                        return false;
  922|  24.3k|                }
  923|  24.3k|            }
  924|   635k|            else
  925|   635k|            {
  926|       |                /* Initialize to zeros */
  927|   635k|                memset(field->pData, 0, (size_t)field->data_size);
  928|   635k|            }
  929|   659k|        }
  930|   827k|    }
  931|  52.3k|    else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  297|  52.3k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  52.3k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  293|  52.3k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (931:14): [True: 0, False: 52.3k]
  ------------------
  932|      0|    {
  933|       |        /* Initialize the pointer to NULL. */
  934|      0|        *(void**)field->pField = NULL;
  935|       |
  936|       |        /* Initialize array count to 0. */
  937|      0|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  298|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  285|      0|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (937:13): [True: 0, False: 0]
  ------------------
  938|      0|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  298|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|      0|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (938:13): [True: 0, False: 0]
  ------------------
  939|      0|        {
  940|      0|            *(pb_size_t*)field->pSize = 0;
  941|      0|        }
  942|      0|    }
  943|  52.3k|    else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  297|  52.3k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  52.3k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  294|  52.3k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (943:14): [True: 52.3k, False: 0]
  ------------------
  944|  52.3k|    {
  945|       |        /* Don't overwrite callback */
  946|  52.3k|    }
  947|       |
  948|   888k|    return true;
  949|   888k|}
pb_decode.c:decode_extension:
  848|   163k|{
  849|   163k|    size_t pos = stream->bytes_left;
  850|       |    
  851|   325k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (851:12): [True: 163k, False: 162k]
  |  Branch (851:33): [True: 163k, False: 0]
  ------------------
  852|   163k|    {
  853|   163k|        bool status;
  854|   163k|        if (extension->type->decode)
  ------------------
  |  Branch (854:13): [True: 0, False: 163k]
  ------------------
  855|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  856|   163k|        else
  857|   163k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  858|       |
  859|   163k|        if (!status)
  ------------------
  |  Branch (859:13): [True: 59, False: 162k]
  ------------------
  860|     59|            return false;
  861|       |        
  862|   162k|        extension = extension->next;
  863|   162k|    }
  864|       |    
  865|   162k|    return true;
  866|   163k|}
pb_decode.c:default_extension_decoder:
  831|   163k|{
  832|   163k|    pb_field_iter_t iter;
  833|       |
  834|   163k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (834:9): [True: 0, False: 163k]
  ------------------
  835|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  836|       |
  837|   163k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (837:9): [True: 154k, False: 8.28k]
  |  Branch (837:28): [True: 0, False: 8.28k]
  ------------------
  838|   154k|        return true;
  839|       |
  840|  8.28k|    extension->found = true;
  841|  8.28k|    return decode_field(stream, wire_type, &iter);
  842|   163k|}
pb_decode.c:decode_field:
  799|  6.45M|{
  800|       |#ifdef PB_ENABLE_MALLOC
  801|       |    /* When decoding an oneof field, check if there is old data that must be
  802|       |     * released first. */
  803|       |    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  804|       |    {
  805|       |        if (!pb_release_union_field(stream, field))
  806|       |            return false;
  807|       |    }
  808|       |#endif
  809|       |
  810|  6.45M|    switch (PB_ATYPE(field->type))
  ------------------
  |  |  297|  6.45M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  6.45M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
  811|  6.45M|    {
  812|  6.37M|        case PB_ATYPE_STATIC:
  ------------------
  |  |  292|  6.37M|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (812:9): [True: 6.37M, False: 76.3k]
  ------------------
  813|  6.37M|            return decode_static_field(stream, wire_type, field);
  814|       |        
  815|      0|        case PB_ATYPE_POINTER:
  ------------------
  |  |  293|      0|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (815:9): [True: 0, False: 6.45M]
  ------------------
  816|      0|            return decode_pointer_field(stream, wire_type, field);
  817|       |        
  818|  76.3k|        case PB_ATYPE_CALLBACK:
  ------------------
  |  |  294|  76.3k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (818:9): [True: 76.3k, False: 6.37M]
  ------------------
  819|  76.3k|            return decode_callback_field(stream, wire_type, field);
  820|       |        
  821|      0|        default:
  ------------------
  |  Branch (821:9): [True: 0, False: 6.45M]
  ------------------
  822|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  823|  6.45M|    }
  824|  6.45M|}
pb_decode.c:decode_static_field:
  468|  6.37M|{
  469|  6.37M|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  298|  6.37M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  6.37M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  470|  6.37M|    {
  471|  5.68M|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  282|  5.68M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (471:9): [True: 5.68M, False: 689k]
  ------------------
  472|  5.68M|            return decode_basic_field(stream, wire_type, field);
  473|       |            
  474|   430k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  283|   430k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (474:9): [True: 430k, False: 5.94M]
  ------------------
  475|   430k|            if (field->pSize != NULL)
  ------------------
  |  Branch (475:17): [True: 430k, False: 0]
  ------------------
  476|   430k|                *(bool*)field->pSize = true;
  477|   430k|            return decode_basic_field(stream, wire_type, field);
  478|       |    
  479|  29.8k|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  285|  29.8k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (479:9): [True: 29.8k, False: 6.34M]
  ------------------
  480|  29.8k|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (480:17): [True: 21.6k, False: 8.25k]
  ------------------
  481|  29.8k|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  299|  21.6k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  21.6k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  247|  21.6k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (481:20): [True: 10.3k, False: 11.2k]
  ------------------
  482|  10.3k|            {
  483|       |                /* Packed array */
  484|  10.3k|                bool status = true;
  485|  10.3k|                pb_istream_t substream;
  486|  10.3k|                pb_size_t *size = (pb_size_t*)field->pSize;
  487|  10.3k|                field->pData = (char*)field->pField + field->data_size * (*size);
  488|       |
  489|  10.3k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (489:21): [True: 50, False: 10.3k]
  ------------------
  490|     50|                    return false;
  491|       |
  492|  42.8k|                while (substream.bytes_left > 0 && *size < field->array_size)
  ------------------
  |  Branch (492:24): [True: 32.5k, False: 10.2k]
  |  Branch (492:52): [True: 32.5k, False: 24]
  ------------------
  493|  32.5k|                {
  494|  32.5k|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (494:25): [True: 20, False: 32.5k]
  ------------------
  495|     20|                    {
  496|     20|                        status = false;
  497|     20|                        break;
  498|     20|                    }
  499|  32.5k|                    (*size)++;
  500|  32.5k|                    field->pData = (char*)field->pData + field->data_size;
  501|  32.5k|                }
  502|       |
  503|  10.3k|                if (substream.bytes_left != 0)
  ------------------
  |  Branch (503:21): [True: 43, False: 10.2k]
  ------------------
  504|     43|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  894|     43|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     43|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 43]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  505|  10.2k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (505:21): [True: 0, False: 10.2k]
  ------------------
  506|      0|                    return false;
  507|       |
  508|  10.2k|                return status;
  509|  10.2k|            }
  510|  19.5k|            else
  511|  19.5k|            {
  512|       |                /* Repeated field */
  513|  19.5k|                pb_size_t *size = (pb_size_t*)field->pSize;
  514|  19.5k|                field->pData = (char*)field->pField + field->data_size * (*size);
  515|       |
  516|  19.5k|                if ((*size)++ >= field->array_size)
  ------------------
  |  Branch (516:21): [True: 2, False: 19.5k]
  ------------------
  517|      2|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  894|      2|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      2|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  518|       |
  519|  19.5k|                return decode_basic_field(stream, wire_type, field);
  520|  19.5k|            }
  521|       |
  522|   229k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  287|   229k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (522:9): [True: 229k, False: 6.14M]
  ------------------
  523|   229k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  300|   458k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|   229k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|   229k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|   458k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 175k, False: 53.3k]
  |  |  ------------------
  |  |  301|   458k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|  53.3k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  53.3k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|  53.3k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 53.3k, False: 0]
  |  |  ------------------
  ------------------
  524|   229k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (524:17): [True: 105k, False: 123k]
  ------------------
  525|   105k|            {
  526|       |                /* We memset to zero so that any callbacks are set to NULL.
  527|       |                 * This is because the callbacks might otherwise have values
  528|       |                 * from some other union field.
  529|       |                 * If callbacks are needed inside oneof field, use .proto
  530|       |                 * option submsg_callback to have a separate callback function
  531|       |                 * that can set the fields before submessage is decoded.
  532|       |                 * pb_dec_submessage() will set any default values. */
  533|   105k|                memset(field->pData, 0, (size_t)field->data_size);
  534|       |
  535|       |                /* Set default values for the submessage fields. */
  536|   105k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (536:21): [True: 59.9k, False: 45.2k]
  ------------------
  537|   105k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (537:21): [True: 0, False: 45.2k]
  ------------------
  538|   105k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (538:21): [True: 0, False: 45.2k]
  ------------------
  539|  59.9k|                {
  540|  59.9k|                    pb_field_iter_t submsg_iter;
  541|  59.9k|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (541:25): [True: 59.9k, False: 0]
  ------------------
  542|  59.9k|                    {
  543|  59.9k|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (543:29): [True: 0, False: 59.9k]
  ------------------
  544|      0|                            PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  545|  59.9k|                    }
  546|  59.9k|                }
  547|   105k|            }
  548|   229k|            *(pb_size_t*)field->pSize = field->tag;
  549|       |
  550|   229k|            return decode_basic_field(stream, wire_type, field);
  551|       |
  552|      0|        default:
  ------------------
  |  Branch (552:9): [True: 0, False: 6.37M]
  ------------------
  553|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  554|  6.37M|    }
  555|  6.37M|}
pb_decode.c:decode_basic_field:
  397|  6.39M|{
  398|  6.39M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  299|  6.39M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  6.39M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  399|  6.39M|    {
  400|   219k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  239|   219k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (400:9): [True: 219k, False: 6.17M]
  ------------------
  401|   219k|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (401:17): [True: 1.71k, False: 217k]
  |  Branch (401:46): [True: 12, False: 1.70k]
  ------------------
  402|     12|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  894|     12|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     12|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  403|       |
  404|   219k|            return pb_dec_bool(stream, field);
  405|       |
  406|  4.41M|        case PB_LTYPE_VARINT:
  ------------------
  |  |  240|  4.41M|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (406:9): [True: 4.41M, False: 1.97M]
  ------------------
  407|  4.77M|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  241|  4.77M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (407:9): [True: 352k, False: 6.04M]
  ------------------
  408|  4.95M|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  242|  4.95M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (408:9): [True: 187k, False: 6.20M]
  ------------------
  409|  4.95M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (409:17): [True: 22.8k, False: 4.93M]
  |  Branch (409:46): [True: 71, False: 22.7k]
  ------------------
  410|     71|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  894|     71|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     71|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 71]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  411|       |
  412|  4.95M|            return pb_dec_varint(stream, field);
  413|       |
  414|   337k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  243|   337k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (414:9): [True: 337k, False: 6.05M]
  ------------------
  415|   337k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (415:17): [True: 5.51k, False: 331k]
  |  Branch (415:45): [True: 22, False: 5.48k]
  ------------------
  416|     22|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  894|     22|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     22|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  417|       |
  418|   337k|            return pb_decode_fixed32(stream, field->pData);
  419|       |
  420|   225k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  244|   225k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (420:9): [True: 225k, False: 6.17M]
  ------------------
  421|   225k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (421:17): [True: 2.62k, False: 223k]
  |  Branch (421:45): [True: 11, False: 2.61k]
  ------------------
  422|     11|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  894|     11|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     11|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  423|       |
  424|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  425|       |            if (field->data_size == sizeof(float))
  426|       |            {
  427|       |                return pb_decode_double_as_float(stream, (float*)field->pData);
  428|       |            }
  429|       |#endif
  430|       |
  431|       |#ifdef PB_WITHOUT_64BIT
  432|       |            PB_RETURN_ERROR(stream, "invalid data_size");
  433|       |#else
  434|   225k|            return pb_decode_fixed64(stream, field->pData);
  435|      0|#endif
  436|       |
  437|  70.5k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  251|  70.5k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (437:9): [True: 70.5k, False: 6.32M]
  ------------------
  438|  70.5k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (438:17): [True: 11, False: 70.5k]
  ------------------
  439|     11|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  894|     11|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     11|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  440|       |
  441|  70.5k|            return pb_dec_bytes(stream, field);
  442|       |
  443|   211k|        case PB_LTYPE_STRING:
  ------------------
  |  |  255|   211k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (443:9): [True: 211k, False: 6.18M]
  ------------------
  444|   211k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (444:17): [True: 10, False: 211k]
  ------------------
  445|     10|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  894|     10|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     10|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  446|       |
  447|   211k|            return pb_dec_string(stream, field);
  448|       |
  449|   292k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  259|   292k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (449:9): [True: 292k, False: 6.10M]
  ------------------
  450|   345k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  264|   345k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (450:9): [True: 53.3k, False: 6.34M]
  ------------------
  451|   345k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (451:17): [True: 19, False: 345k]
  ------------------
  452|     19|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  894|     19|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     19|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  453|       |
  454|   345k|            return pb_dec_submessage(stream, field);
  455|       |
  456|  28.8k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  274|  28.8k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (456:9): [True: 28.8k, False: 6.36M]
  ------------------
  457|  28.8k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (457:17): [True: 6, False: 28.8k]
  ------------------
  458|      6|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  894|      6|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      6|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  459|       |
  460|  28.8k|            return pb_dec_fixed_length_bytes(stream, field);
  461|       |
  462|      0|        default:
  ------------------
  |  Branch (462:9): [True: 0, False: 6.39M]
  ------------------
  463|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  464|  6.39M|    }
  465|  6.39M|}
pb_decode.c:pb_dec_bool:
 1421|   219k|{
 1422|   219k|    return pb_decode_bool(stream, (bool*)field->pData);
 1423|   219k|}
pb_decode.c:pb_dec_varint:
 1426|  4.95M|{
 1427|  4.95M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  299|  4.95M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  4.95M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  241|  4.95M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1427:9): [True: 352k, False: 4.60M]
  ------------------
 1428|   352k|    {
 1429|   352k|        pb_uint64_t value, clamped;
  ------------------
  |  |   58|   352k|#define pb_uint64_t uint64_t
  ------------------
 1430|   352k|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1430:13): [True: 21, False: 352k]
  ------------------
 1431|     21|            return false;
 1432|       |
 1433|       |        /* Cast to the proper field size, while checking for overflows */
 1434|   352k|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1434:13): [True: 172k, False: 180k]
  ------------------
 1435|   172k|            clamped = *(pb_uint64_t*)field->pData = value;
 1436|   180k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1436:18): [True: 158k, False: 21.7k]
  ------------------
 1437|   158k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1438|  21.7k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1438:18): [True: 10.8k, False: 10.9k]
  ------------------
 1439|  10.8k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1440|  10.9k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1440:18): [True: 10.9k, False: 0]
  ------------------
 1441|  10.9k|            clamped = *(uint_least8_t*)field->pData = (uint_least8_t)value;
 1442|      0|        else
 1443|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1444|       |
 1445|   352k|        if (clamped != value)
  ------------------
  |  Branch (1445:13): [True: 114, False: 352k]
  ------------------
 1446|    114|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  894|    114|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|    114|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 114]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1447|       |
 1448|   352k|        return true;
 1449|   352k|    }
 1450|  4.60M|    else
 1451|  4.60M|    {
 1452|  4.60M|        pb_uint64_t value;
  ------------------
  |  |   58|  4.60M|#define pb_uint64_t uint64_t
  ------------------
 1453|  4.60M|        pb_int64_t svalue;
  ------------------
  |  |   57|  4.60M|#define pb_int64_t int64_t
  ------------------
 1454|  4.60M|        pb_int64_t clamped;
  ------------------
  |  |   57|  4.60M|#define pb_int64_t int64_t
  ------------------
 1455|       |
 1456|  4.60M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  299|  4.60M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  4.60M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  242|  4.60M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1456:13): [True: 187k, False: 4.41M]
  ------------------
 1457|   187k|        {
 1458|   187k|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1458:17): [True: 25, False: 187k]
  ------------------
 1459|     25|                return false;
 1460|   187k|        }
 1461|  4.41M|        else
 1462|  4.41M|        {
 1463|  4.41M|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1463:17): [True: 25, False: 4.41M]
  ------------------
 1464|     25|                return false;
 1465|       |
 1466|       |            /* See issue 97: Google's C++ protobuf allows negative varint values to
 1467|       |            * be cast as int32_t, instead of the int64_t that should be used when
 1468|       |            * encoding. Nanopb versions before 0.2.5 had a bug in encoding. In order to
 1469|       |            * not break decoding of such messages, we cast <=32 bit fields to
 1470|       |            * int32_t first to get the sign correct.
 1471|       |            */
 1472|  4.41M|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1472:17): [True: 195k, False: 4.22M]
  ------------------
 1473|   195k|                svalue = (pb_int64_t)value;
 1474|  4.22M|            else
 1475|  4.22M|                svalue = (int32_t)value;
 1476|  4.41M|        }
 1477|       |
 1478|       |        /* Cast to the proper field size, while checking for overflows */
 1479|  4.60M|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1479:13): [True: 280k, False: 4.32M]
  ------------------
 1480|   280k|            clamped = *(pb_int64_t*)field->pData = svalue;
 1481|  4.32M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1481:18): [True: 4.28M, False: 43.0k]
  ------------------
 1482|  4.28M|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1483|  43.0k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1483:18): [True: 21.5k, False: 21.5k]
  ------------------
 1484|  21.5k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1485|  21.5k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1485:18): [True: 21.5k, False: 0]
  ------------------
 1486|  21.5k|            clamped = *(int_least8_t*)field->pData = (int_least8_t)svalue;
 1487|      0|        else
 1488|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1489|       |
 1490|  4.60M|        if (clamped != svalue)
  ------------------
  |  Branch (1490:13): [True: 93, False: 4.60M]
  ------------------
 1491|     93|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  894|     93|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     93|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 93]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1492|       |
 1493|  4.60M|        return true;
 1494|  4.60M|    }
 1495|  4.95M|}
pb_decode.c:pb_dec_bytes:
 1498|  70.5k|{
 1499|  70.5k|    uint32_t size;
 1500|  70.5k|    size_t alloc_size;
 1501|  70.5k|    pb_bytes_array_t *dest;
 1502|       |    
 1503|  70.5k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1503:9): [True: 2, False: 70.5k]
  ------------------
 1504|      2|        return false;
 1505|       |    
 1506|  70.5k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  313|  70.5k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1506:9): [True: 18, False: 70.5k]
  ------------------
 1507|     18|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  894|     18|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     18|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1508|       |    
 1509|  70.5k|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  377|  70.5k|#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes))
  ------------------
 1510|  70.5k|    if (size > alloc_size)
  ------------------
  |  Branch (1510:9): [True: 0, False: 70.5k]
  ------------------
 1511|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1512|       |    
 1513|  70.5k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  297|  70.5k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  70.5k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  293|  70.5k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1513:9): [True: 0, False: 70.5k]
  ------------------
 1514|      0|    {
 1515|      0|#ifndef PB_ENABLE_MALLOC
 1516|      0|        PB_RETURN_ERROR(stream, "no malloc support");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1517|       |#else
 1518|       |        if (stream->bytes_left < size)
 1519|       |            PB_RETURN_ERROR(stream, "end-of-stream");
 1520|       |
 1521|       |        if (!allocate_field(stream, field->pData, alloc_size, 1))
 1522|       |            return false;
 1523|       |        dest = *(pb_bytes_array_t**)field->pData;
 1524|       |#endif
 1525|      0|    }
 1526|  70.5k|    else
 1527|  70.5k|    {
 1528|  70.5k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1528:13): [True: 35, False: 70.5k]
  ------------------
 1529|     35|            PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  894|     35|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     35|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 35]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1530|  70.5k|        dest = (pb_bytes_array_t*)field->pData;
 1531|  70.5k|    }
 1532|       |
 1533|  70.5k|    dest->size = (pb_size_t)size;
 1534|  70.5k|    return pb_read(stream, dest->bytes, (size_t)size);
 1535|  70.5k|}
pb_decode.c:pb_dec_string:
 1538|   211k|{
 1539|   211k|    uint32_t size;
 1540|   211k|    size_t alloc_size;
 1541|   211k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1542|       |
 1543|   211k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1543:9): [True: 5, False: 211k]
  ------------------
 1544|      5|        return false;
 1545|       |
 1546|   211k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1546:9): [True: 1, False: 211k]
  ------------------
 1547|      1|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  894|      1|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      1|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1548|       |
 1549|       |    /* Space for null terminator */
 1550|   211k|    alloc_size = (size_t)(size + 1);
 1551|       |
 1552|   211k|    if (alloc_size < size)
  ------------------
  |  Branch (1552:9): [True: 0, False: 211k]
  ------------------
 1553|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1554|       |
 1555|   211k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  297|   211k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|   211k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  293|   211k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1555:9): [True: 0, False: 211k]
  ------------------
 1556|      0|    {
 1557|      0|#ifndef PB_ENABLE_MALLOC
 1558|      0|        PB_RETURN_ERROR(stream, "no malloc support");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1559|       |#else
 1560|       |        if (stream->bytes_left < size)
 1561|       |            PB_RETURN_ERROR(stream, "end-of-stream");
 1562|       |
 1563|       |        if (!allocate_field(stream, field->pData, alloc_size, 1))
 1564|       |            return false;
 1565|       |        dest = *(pb_byte_t**)field->pData;
 1566|       |#endif
 1567|      0|    }
 1568|   211k|    else
 1569|   211k|    {
 1570|   211k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1570:13): [True: 88, False: 211k]
  ------------------
 1571|     88|            PB_RETURN_ERROR(stream, "string overflow");
  ------------------
  |  |  894|     88|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     88|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 88]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1572|   211k|    }
 1573|       |    
 1574|   211k|    dest[size] = 0;
 1575|       |
 1576|   211k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1576:9): [True: 9, False: 211k]
  ------------------
 1577|      9|        return false;
 1578|       |
 1579|       |#ifdef PB_VALIDATE_UTF8
 1580|       |    if (!pb_validate_utf8((const char*)dest))
 1581|       |        PB_RETURN_ERROR(stream, "invalid utf8");
 1582|       |#endif
 1583|       |
 1584|   211k|    return true;
 1585|   211k|}
pb_decode.c:pb_dec_submessage:
 1588|   345k|{
 1589|   345k|    bool status = true;
 1590|   345k|    bool submsg_consumed = false;
 1591|   345k|    pb_istream_t substream;
 1592|       |
 1593|   345k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1593:9): [True: 104, False: 345k]
  ------------------
 1594|    104|        return false;
 1595|       |    
 1596|   345k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1596:9): [True: 0, False: 345k]
  ------------------
 1597|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1598|       |    
 1599|       |    /* Submessages can have a separate message-level callback that is called
 1600|       |     * before decoding the message. Typically it is used to set callback fields
 1601|       |     * inside oneofs. */
 1602|   345k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  299|   345k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   345k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  264|   691k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1602:9): [True: 53.3k, False: 292k]
  |  Branch (1602:58): [True: 53.3k, False: 0]
  ------------------
 1603|  53.3k|    {
 1604|       |        /* Message callback is stored right before pSize. */
 1605|  53.3k|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
 1606|  53.3k|        if (callback->funcs.decode)
  ------------------
  |  Branch (1606:13): [True: 53.3k, False: 0]
  ------------------
 1607|  53.3k|        {
 1608|  53.3k|            status = callback->funcs.decode(&substream, field, &callback->arg);
 1609|       |
 1610|  53.3k|            if (substream.bytes_left == 0)
  ------------------
  |  Branch (1610:17): [True: 36.5k, False: 16.8k]
  ------------------
 1611|  36.5k|            {
 1612|  36.5k|                submsg_consumed = true;
 1613|  36.5k|            }
 1614|  53.3k|        }
 1615|  53.3k|    }
 1616|       |
 1617|       |    /* Now decode the submessage contents */
 1618|   345k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1618:9): [True: 345k, False: 0]
  |  Branch (1618:19): [True: 309k, False: 36.5k]
  ------------------
 1619|   309k|    {
 1620|   309k|        unsigned int flags = 0;
 1621|       |
 1622|       |        /* Static required/optional fields are already initialized by top-level
 1623|       |         * pb_decode(), no need to initialize them again. */
 1624|   309k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  297|   309k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|   309k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  292|   618k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1624:13): [True: 309k, False: 0]
  ------------------
 1625|   309k|            PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  298|   309k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   309k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  285|   309k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1625:13): [True: 303k, False: 5.42k]
  ------------------
 1626|   303k|        {
 1627|   303k|            flags = PB_DECODE_NOINIT;
  ------------------
  |  |   99|   303k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1628|   303k|        }
 1629|       |
 1630|   309k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1631|   309k|    }
 1632|       |    
 1633|   345k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1633:9): [True: 0, False: 345k]
  ------------------
 1634|      0|        return false;
 1635|       |
 1636|   345k|    return status;
 1637|   345k|}
pb_decode.c:pb_dec_fixed_length_bytes:
 1640|  28.8k|{
 1641|  28.8k|    uint32_t size;
 1642|       |
 1643|  28.8k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1643:9): [True: 4, False: 28.8k]
  ------------------
 1644|      4|        return false;
 1645|       |
 1646|  28.8k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  313|  28.8k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1646:9): [True: 29, False: 28.8k]
  ------------------
 1647|     29|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  894|     29|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     29|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 29]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1648|       |
 1649|  28.8k|    if (size == 0)
  ------------------
  |  Branch (1649:9): [True: 16.9k, False: 11.8k]
  ------------------
 1650|  16.9k|    {
 1651|       |        /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */
 1652|  16.9k|        memset(field->pData, 0, (size_t)field->data_size);
 1653|  16.9k|        return true;
 1654|  16.9k|    }
 1655|       |
 1656|  11.8k|    if (size != field->data_size)
  ------------------
  |  Branch (1656:9): [True: 43, False: 11.8k]
  ------------------
 1657|     43|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  894|     43|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     43|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 43]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1658|       |
 1659|  11.8k|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1660|  11.8k|}
pb_decode.c:decode_callback_field:
  753|  76.3k|{
  754|  76.3k|    if (!field->descriptor->field_callback)
  ------------------
  |  Branch (754:9): [True: 0, False: 76.3k]
  ------------------
  755|      0|        return pb_skip_field(stream, wire_type);
  756|       |
  757|  76.3k|    if (wire_type == PB_WT_STRING)
  ------------------
  |  Branch (757:9): [True: 69.6k, False: 6.70k]
  ------------------
  758|  69.6k|    {
  759|  69.6k|        pb_istream_t substream;
  760|  69.6k|        size_t prev_bytes_left;
  761|       |        
  762|  69.6k|        if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (762:13): [True: 0, False: 69.6k]
  ------------------
  763|      0|            return false;
  764|       |        
  765|  69.6k|        do
  766|  69.6k|        {
  767|  69.6k|            prev_bytes_left = substream.bytes_left;
  768|  69.6k|            if (!field->descriptor->field_callback(&substream, NULL, field))
  ------------------
  |  Branch (768:17): [True: 0, False: 69.6k]
  ------------------
  769|      0|            {
  770|      0|                PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "callback failed");
  ------------------
  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  Branch (890:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  771|      0|                return false;
  772|      0|            }
  773|  69.6k|        } while (substream.bytes_left > 0 && substream.bytes_left < prev_bytes_left);
  ------------------
  |  Branch (773:18): [True: 27.2k, False: 42.4k]
  |  Branch (773:46): [True: 0, False: 27.2k]
  ------------------
  774|       |        
  775|  69.6k|        if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (775:13): [True: 0, False: 69.6k]
  ------------------
  776|      0|            return false;
  777|       |
  778|  69.6k|        return true;
  779|  69.6k|    }
  780|  6.70k|    else
  781|  6.70k|    {
  782|       |        /* Copy the single scalar value to stack.
  783|       |         * This is required so that we can limit the stream length,
  784|       |         * which in turn allows to use same callback for packed and
  785|       |         * not-packed fields. */
  786|  6.70k|        pb_istream_t substream;
  787|  6.70k|        pb_byte_t buffer[10];
  788|  6.70k|        size_t size = sizeof(buffer);
  789|       |        
  790|  6.70k|        if (!read_raw_value(stream, wire_type, buffer, &size))
  ------------------
  |  Branch (790:13): [True: 0, False: 6.70k]
  ------------------
  791|      0|            return false;
  792|  6.70k|        substream = pb_istream_from_buffer(buffer, size);
  793|       |        
  794|  6.70k|        return field->descriptor->field_callback(&substream, NULL, field);
  795|  6.70k|    }
  796|  76.3k|}
pb_decode.c:read_raw_value:
  324|  6.70k|{
  325|  6.70k|    size_t max_size = *size;
  326|  6.70k|    switch (wire_type)
  327|  6.70k|    {
  328|  5.72k|        case PB_WT_VARINT:
  ------------------
  |  Branch (328:9): [True: 5.72k, False: 980]
  ------------------
  329|  5.72k|            *size = 0;
  330|  5.72k|            do
  331|  16.9k|            {
  332|  16.9k|                (*size)++;
  333|  16.9k|                if (*size > max_size)
  ------------------
  |  Branch (333:21): [True: 0, False: 16.9k]
  ------------------
  334|      0|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  335|       |
  336|  16.9k|                if (!pb_read(stream, buf, 1))
  ------------------
  |  Branch (336:21): [True: 0, False: 16.9k]
  ------------------
  337|      0|                    return false;
  338|  16.9k|            } while (*buf++ & 0x80);
  ------------------
  |  Branch (338:22): [True: 11.2k, False: 5.72k]
  ------------------
  339|  5.72k|            return true;
  340|       |            
  341|    437|        case PB_WT_64BIT:
  ------------------
  |  Branch (341:9): [True: 437, False: 6.26k]
  ------------------
  342|    437|            *size = 8;
  343|    437|            return pb_read(stream, buf, 8);
  344|       |        
  345|    543|        case PB_WT_32BIT:
  ------------------
  |  Branch (345:9): [True: 543, False: 6.15k]
  ------------------
  346|    543|            *size = 4;
  347|    543|            return pb_read(stream, buf, 4);
  348|       |        
  349|      0|        case PB_WT_STRING:
  ------------------
  |  Branch (349:9): [True: 0, False: 6.70k]
  ------------------
  350|       |            /* Calling read_raw_value with a PB_WT_STRING is an error.
  351|       |             * Explicitly handle this case and fallthrough to default to avoid
  352|       |             * compiler warnings.
  353|       |             */
  354|       |
  355|      0|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (355:9): [True: 0, False: 6.70k]
  ------------------
  356|  6.70k|    }
  357|  6.70k|}

pb_ostream_from_buffer:
   64|  2.56k|{
   65|  2.56k|    pb_ostream_t stream;
   66|       |#ifdef PB_BUFFER_ONLY
   67|       |    /* In PB_BUFFER_ONLY configuration the callback pointer is just int*.
   68|       |     * NULL pointer marks a sizing field, so put a non-NULL value to mark a buffer stream.
   69|       |     */
   70|       |    static const int marker = 0;
   71|       |    stream.callback = &marker;
   72|       |#else
   73|  2.56k|    stream.callback = &buf_write;
   74|  2.56k|#endif
   75|  2.56k|    stream.state = buf;
   76|  2.56k|    stream.max_size = bufsize;
   77|  2.56k|    stream.bytes_written = 0;
   78|  2.56k|#ifndef PB_NO_ERRMSG
   79|  2.56k|    stream.errmsg = NULL;
   80|  2.56k|#endif
   81|  2.56k|    return stream;
   82|  2.56k|}
pb_write:
   85|   479k|{
   86|   479k|    if (count > 0 && stream->callback != NULL)
  ------------------
  |  Branch (86:9): [True: 466k, False: 13.3k]
  |  Branch (86:22): [True: 321k, False: 145k]
  ------------------
   87|   321k|    {
   88|   321k|        if (stream->bytes_written + count < stream->bytes_written ||
  ------------------
  |  Branch (88:13): [True: 0, False: 321k]
  ------------------
   89|   321k|            stream->bytes_written + count > stream->max_size)
  ------------------
  |  Branch (89:13): [True: 0, False: 321k]
  ------------------
   90|      0|        {
   91|      0|            PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   92|      0|        }
   93|       |
   94|       |#ifdef PB_BUFFER_ONLY
   95|       |        if (!buf_write(stream, buf, count))
   96|       |            PB_RETURN_ERROR(stream, "io error");
   97|       |#else        
   98|   321k|        if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (98:13): [True: 0, False: 321k]
  ------------------
   99|      0|            PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  100|   321k|#endif
  101|   321k|    }
  102|       |    
  103|   479k|    stream->bytes_written += count;
  104|   479k|    return true;
  105|   479k|}
pb_encode:
  513|  40.8k|{
  514|  40.8k|    pb_field_iter_t iter;
  515|  40.8k|    if (!pb_field_iter_begin_const(&iter, fields, src_struct))
  ------------------
  |  Branch (515:9): [True: 7.49k, False: 33.3k]
  ------------------
  516|  7.49k|        return true; /* Empty message type */
  517|       |    
  518|   307k|    do {
  519|   307k|        if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  299|   307k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   307k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  268|   307k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (519:13): [True: 2.56k, False: 305k]
  ------------------
  520|  2.56k|        {
  521|       |            /* Special case for the extension field placeholder */
  522|  2.56k|            if (!encode_extension_field(stream, &iter))
  ------------------
  |  Branch (522:17): [True: 0, False: 2.56k]
  ------------------
  523|      0|                return false;
  524|  2.56k|        }
  525|   305k|        else
  526|   305k|        {
  527|       |            /* Regular field */
  528|   305k|            if (!encode_field(stream, &iter))
  ------------------
  |  Branch (528:17): [True: 0, False: 305k]
  ------------------
  529|      0|                return false;
  530|   305k|        }
  531|   307k|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (531:14): [True: 274k, False: 33.3k]
  ------------------
  532|       |    
  533|  33.3k|    return true;
  534|  33.3k|}
pb_encode_varint:
  608|   427k|{
  609|   427k|    if (value <= 0x7F)
  ------------------
  |  Branch (609:9): [True: 357k, False: 70.7k]
  ------------------
  610|   357k|    {
  611|       |        /* Fast path: single byte */
  612|   357k|        pb_byte_t byte = (pb_byte_t)value;
  613|   357k|        return pb_write(stream, &byte, 1);
  614|   357k|    }
  615|  70.7k|    else
  616|  70.7k|    {
  617|       |#ifdef PB_WITHOUT_64BIT
  618|       |        return pb_encode_varint_32(stream, value, 0);
  619|       |#else
  620|  70.7k|        return pb_encode_varint_32(stream, (uint32_t)value, (uint32_t)(value >> 32));
  621|  70.7k|#endif
  622|  70.7k|    }
  623|   427k|}
pb_encode_svarint:
  626|  21.4k|{
  627|  21.4k|    pb_uint64_t zigzagged;
  ------------------
  |  |   46|  21.4k|#define pb_uint64_t uint64_t
  ------------------
  628|  21.4k|    pb_uint64_t mask = ((pb_uint64_t)-1) >> 1; /* Satisfy clang -fsanitize=integer */
  ------------------
  |  |   46|  21.4k|#define pb_uint64_t uint64_t
  ------------------
  629|  21.4k|    if (value < 0)
  ------------------
  |  Branch (629:9): [True: 9.76k, False: 11.7k]
  ------------------
  630|  9.76k|        zigzagged = ~(((pb_uint64_t)value & mask) << 1);
  631|  11.7k|    else
  632|  11.7k|        zigzagged = (pb_uint64_t)value << 1;
  633|       |    
  634|  21.4k|    return pb_encode_varint(stream, zigzagged);
  635|  21.4k|}
pb_encode_fixed32:
  638|  19.2k|{
  639|  19.2k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
  640|       |    /* Fast path if we know that we're on little endian */
  641|  19.2k|    return pb_write(stream, (const pb_byte_t*)value, 4);
  642|       |#else
  643|       |    uint32_t val = *(const uint32_t*)value;
  644|       |    pb_byte_t bytes[4];
  645|       |    bytes[0] = (pb_byte_t)(val & 0xFF);
  646|       |    bytes[1] = (pb_byte_t)((val >> 8) & 0xFF);
  647|       |    bytes[2] = (pb_byte_t)((val >> 16) & 0xFF);
  648|       |    bytes[3] = (pb_byte_t)((val >> 24) & 0xFF);
  649|       |    return pb_write(stream, bytes, 4);
  650|       |#endif
  651|  19.2k|}
pb_encode_fixed64:
  655|  10.2k|{
  656|  10.2k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
  657|       |    /* Fast path if we know that we're on little endian */
  658|  10.2k|    return pb_write(stream, (const pb_byte_t*)value, 8);
  659|       |#else
  660|       |    uint64_t val = *(const uint64_t*)value;
  661|       |    pb_byte_t bytes[8];
  662|       |    bytes[0] = (pb_byte_t)(val & 0xFF);
  663|       |    bytes[1] = (pb_byte_t)((val >> 8) & 0xFF);
  664|       |    bytes[2] = (pb_byte_t)((val >> 16) & 0xFF);
  665|       |    bytes[3] = (pb_byte_t)((val >> 24) & 0xFF);
  666|       |    bytes[4] = (pb_byte_t)((val >> 32) & 0xFF);
  667|       |    bytes[5] = (pb_byte_t)((val >> 40) & 0xFF);
  668|       |    bytes[6] = (pb_byte_t)((val >> 48) & 0xFF);
  669|       |    bytes[7] = (pb_byte_t)((val >> 56) & 0xFF);
  670|       |    return pb_write(stream, bytes, 8);
  671|       |#endif
  672|  10.2k|}
pb_encode_tag:
  676|   200k|{
  677|   200k|    pb_uint64_t tag = ((pb_uint64_t)field_number << 3) | wiretype;
  ------------------
  |  |   46|   200k|#define pb_uint64_t uint64_t
  ------------------
  678|   200k|    return pb_encode_varint(stream, tag);
  679|   200k|}
pb_encode_tag_for_field:
  682|   191k|{
  683|   191k|    pb_wire_type_t wiretype;
  684|   191k|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  299|   191k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   191k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  685|   191k|    {
  686|  2.69k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  239|  2.69k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (686:9): [True: 2.69k, False: 189k]
  ------------------
  687|  77.3k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  240|  77.3k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (687:9): [True: 74.6k, False: 117k]
  ------------------
  688|   116k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  241|   116k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (688:9): [True: 39.1k, False: 152k]
  ------------------
  689|   132k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  242|   132k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (689:9): [True: 15.6k, False: 176k]
  ------------------
  690|   132k|            wiretype = PB_WT_VARINT;
  691|   132k|            break;
  692|       |        
  693|  10.4k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  243|  10.4k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (693:9): [True: 10.4k, False: 181k]
  ------------------
  694|  10.4k|            wiretype = PB_WT_32BIT;
  695|  10.4k|            break;
  696|       |        
  697|  8.31k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  244|  8.31k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (697:9): [True: 8.31k, False: 183k]
  ------------------
  698|  8.31k|            wiretype = PB_WT_64BIT;
  699|  8.31k|            break;
  700|       |        
  701|  3.39k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  251|  3.39k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (701:9): [True: 3.39k, False: 188k]
  ------------------
  702|  17.8k|        case PB_LTYPE_STRING:
  ------------------
  |  |  255|  17.8k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (702:9): [True: 14.4k, False: 177k]
  ------------------
  703|  36.9k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  259|  36.9k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (703:9): [True: 19.1k, False: 172k]
  ------------------
  704|  36.9k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  264|  36.9k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (704:9): [True: 0, False: 191k]
  ------------------
  705|  41.0k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  274|  41.0k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (705:9): [True: 4.07k, False: 187k]
  ------------------
  706|  41.0k|            wiretype = PB_WT_STRING;
  707|  41.0k|            break;
  708|       |        
  709|      0|        default:
  ------------------
  |  Branch (709:9): [True: 0, False: 191k]
  ------------------
  710|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  711|   191k|    }
  712|       |    
  713|   191k|    return pb_encode_tag(stream, wiretype, field->tag);
  714|   191k|}
pb_encode_string:
  717|  21.9k|{
  718|  21.9k|    if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (718:9): [True: 0, False: 21.9k]
  ------------------
  719|      0|        return false;
  720|       |    
  721|  21.9k|    return pb_write(stream, buffer, size);
  722|  21.9k|}
pb_encode_submessage:
  725|  19.1k|{
  726|       |    /* First calculate the message size using a non-writing substream. */
  727|  19.1k|    pb_ostream_t substream = PB_OSTREAM_SIZING;
  ------------------
  |  |  116|  19.1k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  728|  19.1k|    size_t size;
  729|  19.1k|    bool status;
  730|       |    
  731|  19.1k|    if (!pb_encode(&substream, fields, src_struct))
  ------------------
  |  Branch (731:9): [True: 0, False: 19.1k]
  ------------------
  732|      0|    {
  733|      0|#ifndef PB_NO_ERRMSG
  734|      0|        stream->errmsg = substream.errmsg;
  735|      0|#endif
  736|      0|        return false;
  737|      0|    }
  738|       |    
  739|  19.1k|    size = substream.bytes_written;
  740|       |    
  741|  19.1k|    if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (741:9): [True: 0, False: 19.1k]
  ------------------
  742|      0|        return false;
  743|       |    
  744|  19.1k|    if (stream->callback == NULL)
  ------------------
  |  Branch (744:9): [True: 0, False: 19.1k]
  ------------------
  745|      0|        return pb_write(stream, NULL, size); /* Just sizing */
  746|       |    
  747|  19.1k|    if (stream->bytes_written + size > stream->max_size)
  ------------------
  |  Branch (747:9): [True: 0, False: 19.1k]
  ------------------
  748|      0|        PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  749|       |        
  750|       |    /* Use a substream to verify that a callback doesn't write more than
  751|       |     * what it did the first time. */
  752|  19.1k|    substream.callback = stream->callback;
  753|  19.1k|    substream.state = stream->state;
  754|  19.1k|    substream.max_size = size;
  755|  19.1k|    substream.bytes_written = 0;
  756|  19.1k|#ifndef PB_NO_ERRMSG
  757|  19.1k|    substream.errmsg = NULL;
  758|  19.1k|#endif
  759|       |    
  760|  19.1k|    status = pb_encode(&substream, fields, src_struct);
  761|       |    
  762|  19.1k|    stream->bytes_written += substream.bytes_written;
  763|  19.1k|    stream->state = substream.state;
  764|  19.1k|#ifndef PB_NO_ERRMSG
  765|  19.1k|    stream->errmsg = substream.errmsg;
  766|  19.1k|#endif
  767|       |    
  768|  19.1k|    if (substream.bytes_written != size)
  ------------------
  |  Branch (768:9): [True: 0, False: 19.1k]
  ------------------
  769|      0|        PB_RETURN_ERROR(stream, "submsg size changed");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  770|       |    
  771|  19.1k|    return status;
  772|  19.1k|}
pb_encode.c:buf_write:
   54|   321k|{
   55|   321k|    pb_byte_t *dest = (pb_byte_t*)stream->state;
   56|   321k|    stream->state = dest + count;
   57|       |    
   58|   321k|    memcpy(dest, buf, count * sizeof(pb_byte_t));
   59|       |    
   60|   321k|    return true;
   61|   321k|}
pb_encode.c:encode_extension_field:
  488|  2.56k|{
  489|  2.56k|    const pb_extension_t *extension = *(const pb_extension_t* const *)field->pData;
  490|       |
  491|  5.12k|    while (extension)
  ------------------
  |  Branch (491:12): [True: 2.56k, False: 2.56k]
  ------------------
  492|  2.56k|    {
  493|  2.56k|        bool status;
  494|  2.56k|        if (extension->type->encode)
  ------------------
  |  Branch (494:13): [True: 0, False: 2.56k]
  ------------------
  495|      0|            status = extension->type->encode(stream, extension);
  496|  2.56k|        else
  497|  2.56k|            status = default_extension_encoder(stream, extension);
  498|       |
  499|  2.56k|        if (!status)
  ------------------
  |  Branch (499:13): [True: 0, False: 2.56k]
  ------------------
  500|      0|            return false;
  501|       |        
  502|  2.56k|        extension = extension->next;
  503|  2.56k|    }
  504|       |    
  505|  2.56k|    return true;
  506|  2.56k|}
pb_encode.c:default_extension_encoder:
  475|  2.56k|{
  476|  2.56k|    pb_field_iter_t iter;
  477|       |
  478|  2.56k|    if (!pb_field_iter_begin_extension_const(&iter, extension))
  ------------------
  |  Branch (478:9): [True: 0, False: 2.56k]
  ------------------
  479|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  480|       |
  481|  2.56k|    return encode_field(stream, &iter);
  482|  2.56k|}
pb_encode.c:encode_field:
  419|   307k|{
  420|       |    /* Check field presence */
  421|   307k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  298|   307k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   307k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|   307k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (421:9): [True: 7.69k, False: 300k]
  ------------------
  422|  7.69k|    {
  423|  7.69k|        if (*(const pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (423:13): [True: 6.96k, False: 730]
  ------------------
  424|  6.96k|        {
  425|       |            /* Different type oneof field */
  426|  6.96k|            return true;
  427|  6.96k|        }
  428|  7.69k|    }
  429|   300k|    else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  298|   300k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   300k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  283|   300k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (429:14): [True: 66.6k, False: 233k]
  ------------------
  430|  66.6k|    {
  431|  66.6k|        if (field->pSize)
  ------------------
  |  Branch (431:13): [True: 66.6k, False: 0]
  ------------------
  432|  66.6k|        {
  433|  66.6k|            if (safe_read_bool(field->pSize) == false)
  ------------------
  |  Branch (433:17): [True: 60.5k, False: 6.15k]
  ------------------
  434|  60.5k|            {
  435|       |                /* Missing optional field */
  436|  60.5k|                return true;
  437|  60.5k|            }
  438|  66.6k|        }
  439|      0|        else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  297|      0|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|      0|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  292|      0|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (439:18): [True: 0, False: 0]
  ------------------
  440|      0|        {
  441|       |            /* Proto3 singular field */
  442|      0|            if (pb_check_proto3_default_value(field))
  ------------------
  |  Branch (442:17): [True: 0, False: 0]
  ------------------
  443|      0|                return true;
  444|      0|        }
  445|  66.6k|    }
  446|       |
  447|   240k|    if (!field->pData)
  ------------------
  |  Branch (447:9): [True: 0, False: 240k]
  ------------------
  448|      0|    {
  449|      0|        if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  298|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  282|      0|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (449:13): [True: 0, False: 0]
  ------------------
  450|      0|            PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  451|       |
  452|       |        /* Pointer field set to NULL */
  453|      0|        return true;
  454|      0|    }
  455|       |
  456|       |    /* Then encode field contents */
  457|   240k|    if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  297|   240k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|   240k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  294|   240k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (457:9): [True: 0, False: 240k]
  ------------------
  458|      0|    {
  459|      0|        return encode_callback_field(stream, field);
  460|      0|    }
  461|   240k|    else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  298|   240k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   240k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  285|   240k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (461:14): [True: 53.8k, False: 186k]
  ------------------
  462|  53.8k|    {
  463|  53.8k|        return encode_array(stream, field);
  464|  53.8k|    }
  465|   186k|    else
  466|   186k|    {
  467|   186k|        return encode_basic_field(stream, field);
  468|   186k|    }
  469|   240k|}
pb_encode.c:safe_read_bool:
  116|  69.3k|{
  117|  69.3k|    const char *p = (const char *)pSize;
  118|  69.3k|    size_t i;
  119|   130k|    for (i = 0; i < sizeof(bool); i++)
  ------------------
  |  Branch (119:17): [True: 69.3k, False: 61.4k]
  ------------------
  120|  69.3k|    {
  121|  69.3k|        if (p[i] != 0)
  ------------------
  |  Branch (121:13): [True: 7.94k, False: 61.4k]
  ------------------
  122|  7.94k|            return true;
  123|  69.3k|    }
  124|  61.4k|    return false;
  125|  69.3k|}
pb_encode.c:encode_array:
  129|  53.8k|{
  130|  53.8k|    pb_size_t i;
  131|  53.8k|    pb_size_t count;
  132|  53.8k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  133|  53.8k|    size_t size;
  134|  53.8k|#endif
  135|       |
  136|  53.8k|    count = *(pb_size_t*)field->pSize;
  137|       |
  138|  53.8k|    if (count == 0)
  ------------------
  |  Branch (138:9): [True: 43.8k, False: 9.94k]
  ------------------
  139|  43.8k|        return true;
  140|       |
  141|  9.94k|    if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  297|  9.94k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  9.94k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  293|  19.8k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (141:9): [True: 9.94k, False: 0]
  |  Branch (141:54): [True: 0, False: 9.94k]
  ------------------
  142|      0|        PB_RETURN_ERROR(stream, "array max size exceeded");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  143|       |    
  144|  9.94k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  145|       |    /* We always pack arrays if the datatype allows it. */
  146|  9.94k|    if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  299|  9.94k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  9.94k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  247|  9.94k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (146:9): [True: 8.45k, False: 1.49k]
  ------------------
  147|  8.45k|    {
  148|  8.45k|        if (!pb_encode_tag(stream, PB_WT_STRING, field->tag))
  ------------------
  |  Branch (148:13): [True: 0, False: 8.45k]
  ------------------
  149|      0|            return false;
  150|       |        
  151|       |        /* Determine the total size of packed array. */
  152|  8.45k|        if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  299|  8.45k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  8.45k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  243|  8.45k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (152:13): [True: 3.02k, False: 5.42k]
  ------------------
  153|  3.02k|        {
  154|  3.02k|            size = 4 * (size_t)count;
  155|  3.02k|        }
  156|  5.42k|        else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  299|  5.42k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  5.42k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  244|  5.42k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (156:18): [True: 562, False: 4.86k]
  ------------------
  157|    562|        {
  158|    562|            size = 8 * (size_t)count;
  159|    562|        }
  160|  4.86k|        else
  161|  4.86k|        { 
  162|  4.86k|            pb_ostream_t sizestream = PB_OSTREAM_SIZING;
  ------------------
  |  |  116|  4.86k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  163|  4.86k|            void *pData_orig = field->pData;
  164|  27.8k|            for (i = 0; i < count; i++)
  ------------------
  |  Branch (164:25): [True: 23.0k, False: 4.86k]
  ------------------
  165|  23.0k|            {
  166|  23.0k|                if (!pb_enc_varint(&sizestream, field))
  ------------------
  |  Branch (166:21): [True: 0, False: 23.0k]
  ------------------
  167|      0|                    PB_RETURN_ERROR(stream, PB_GET_ERROR(&sizestream));
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  |  Branch (890:92): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  168|  23.0k|                field->pData = (char*)field->pData + field->data_size;
  169|  23.0k|            }
  170|  4.86k|            field->pData = pData_orig;
  171|  4.86k|            size = sizestream.bytes_written;
  172|  4.86k|        }
  173|       |        
  174|  8.45k|        if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (174:13): [True: 0, False: 8.45k]
  ------------------
  175|      0|            return false;
  176|       |        
  177|  8.45k|        if (stream->callback == NULL)
  ------------------
  |  Branch (177:13): [True: 0, False: 8.45k]
  ------------------
  178|      0|            return pb_write(stream, NULL, size); /* Just sizing.. */
  179|       |        
  180|       |        /* Write the data */
  181|  42.2k|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (181:21): [True: 33.7k, False: 8.45k]
  ------------------
  182|  33.7k|        {
  183|  33.7k|            if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  299|  33.7k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  33.7k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  243|  67.5k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  299|  24.9k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  24.9k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  244|  24.9k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (183:17): [True: 8.86k, False: 24.9k]
  |  Branch (183:62): [True: 1.92k, False: 23.0k]
  ------------------
  184|  10.7k|            {
  185|  10.7k|                if (!pb_enc_fixed(stream, field))
  ------------------
  |  Branch (185:21): [True: 0, False: 10.7k]
  ------------------
  186|      0|                    return false;
  187|  10.7k|            }
  188|  23.0k|            else
  189|  23.0k|            {
  190|  23.0k|                if (!pb_enc_varint(stream, field))
  ------------------
  |  Branch (190:21): [True: 0, False: 23.0k]
  ------------------
  191|      0|                    return false;
  192|  23.0k|            }
  193|       |
  194|  33.7k|            field->pData = (char*)field->pData + field->data_size;
  195|  33.7k|        }
  196|  8.45k|    }
  197|  1.49k|    else /* Unpacked fields */
  198|  1.49k|#endif
  199|  1.49k|    {
  200|  6.97k|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (200:21): [True: 5.47k, False: 1.49k]
  ------------------
  201|  5.47k|        {
  202|       |            /* Normally the data is stored directly in the array entries, but
  203|       |             * for pointer-type string and bytes fields, the array entries are
  204|       |             * actually pointers themselves also. So we have to dereference once
  205|       |             * more to get to the actual data. */
  206|  5.47k|            if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  297|  5.47k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  5.47k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  293|  10.9k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (206:17): [True: 0, False: 5.47k]
  ------------------
  207|  5.47k|                (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  299|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  255|      0|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (207:18): [True: 0, False: 0]
  ------------------
  208|      0|                 PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  299|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                               PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  251|      0|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (208:18): [True: 0, False: 0]
  ------------------
  209|      0|            {
  210|      0|                bool status;
  211|      0|                void *pData_orig = field->pData;
  212|      0|                field->pData = *(void* const*)field->pData;
  213|       |
  214|      0|                if (!field->pData)
  ------------------
  |  Branch (214:21): [True: 0, False: 0]
  ------------------
  215|      0|                {
  216|       |                    /* Null pointer in array is treated as empty string / bytes */
  217|      0|                    status = pb_encode_tag_for_field(stream, field) &&
  ------------------
  |  Branch (217:30): [True: 0, False: 0]
  ------------------
  218|      0|                             pb_encode_varint(stream, 0);
  ------------------
  |  Branch (218:30): [True: 0, False: 0]
  ------------------
  219|      0|                }
  220|      0|                else
  221|      0|                {
  222|      0|                    status = encode_basic_field(stream, field);
  223|      0|                }
  224|       |
  225|      0|                field->pData = pData_orig;
  226|       |
  227|      0|                if (!status)
  ------------------
  |  Branch (227:21): [True: 0, False: 0]
  ------------------
  228|      0|                    return false;
  229|      0|            }
  230|  5.47k|            else
  231|  5.47k|            {
  232|  5.47k|                if (!encode_basic_field(stream, field))
  ------------------
  |  Branch (232:21): [True: 0, False: 5.47k]
  ------------------
  233|      0|                    return false;
  234|  5.47k|            }
  235|  5.47k|            field->pData = (char*)field->pData + field->data_size;
  236|  5.47k|        }
  237|  1.49k|    }
  238|       |    
  239|  9.94k|    return true;
  240|  9.94k|}
pb_encode.c:pb_enc_varint:
  784|   175k|{
  785|   175k|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  299|   175k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   175k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  241|   175k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (785:9): [True: 44.7k, False: 130k]
  ------------------
  786|  44.7k|    {
  787|       |        /* Perform unsigned integer extension */
  788|  44.7k|        pb_uint64_t value = 0;
  ------------------
  |  |   46|  44.7k|#define pb_uint64_t uint64_t
  ------------------
  789|       |
  790|  44.7k|        if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (790:13): [True: 5.12k, False: 39.6k]
  ------------------
  791|  5.12k|            value = *(const uint_least8_t*)field->pData;
  792|  39.6k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (792:18): [True: 5.12k, False: 34.5k]
  ------------------
  793|  5.12k|            value = *(const uint_least16_t*)field->pData;
  794|  34.5k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (794:18): [True: 19.2k, False: 15.2k]
  ------------------
  795|  19.2k|            value = *(const uint32_t*)field->pData;
  796|  15.2k|        else if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (796:18): [True: 15.2k, False: 0]
  ------------------
  797|  15.2k|            value = *(const pb_uint64_t*)field->pData;
  798|      0|        else
  799|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  800|       |
  801|  44.7k|        return pb_encode_varint(stream, value);
  802|  44.7k|    }
  803|   130k|    else
  804|   130k|    {
  805|       |        /* Perform signed integer extension */
  806|   130k|        pb_int64_t value = 0;
  ------------------
  |  |   45|   130k|#define pb_int64_t int64_t
  ------------------
  807|       |
  808|   130k|        if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (808:13): [True: 12.0k, False: 118k]
  ------------------
  809|  12.0k|            value = *(const int_least8_t*)field->pData;
  810|   118k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (810:18): [True: 10.2k, False: 108k]
  ------------------
  811|  10.2k|            value = *(const int_least16_t*)field->pData;
  812|   108k|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (812:18): [True: 86.9k, False: 21.4k]
  ------------------
  813|  86.9k|            value = *(const int32_t*)field->pData;
  814|  21.4k|        else if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (814:18): [True: 21.4k, False: 0]
  ------------------
  815|  21.4k|            value = *(const pb_int64_t*)field->pData;
  816|      0|        else
  817|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  818|       |
  819|   130k|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  299|   130k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   130k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  242|   130k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (819:13): [True: 21.4k, False: 109k]
  ------------------
  820|  21.4k|            return pb_encode_svarint(stream, value);
  821|       |#ifdef PB_WITHOUT_64BIT
  822|       |        else if (value < 0)
  823|       |            return pb_encode_varint_32(stream, (uint32_t)value, (uint32_t)-1);
  824|       |#endif
  825|   109k|        else
  826|   109k|            return pb_encode_varint(stream, (pb_uint64_t)value);
  827|       |
  828|   130k|    }
  829|   175k|}
pb_encode.c:pb_enc_fixed:
  832|  29.5k|{
  833|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  834|       |    if (field->data_size == sizeof(float) && PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  835|       |    {
  836|       |        return pb_encode_float_as_double(stream, *(float*)field->pData);
  837|       |    }
  838|       |#endif
  839|       |
  840|  29.5k|    if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (840:9): [True: 19.2k, False: 10.2k]
  ------------------
  841|  19.2k|    {
  842|  19.2k|        return pb_encode_fixed32(stream, field->pData);
  843|  19.2k|    }
  844|  10.2k|#ifndef PB_WITHOUT_64BIT
  845|  10.2k|    else if (field->data_size == sizeof(uint64_t))
  ------------------
  |  Branch (845:14): [True: 10.2k, False: 0]
  ------------------
  846|  10.2k|    {
  847|  10.2k|        return pb_encode_fixed64(stream, field->pData);
  848|  10.2k|    }
  849|      0|#endif
  850|      0|    else
  851|      0|    {
  852|      0|        PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  853|      0|    }
  854|  29.5k|}
pb_encode.c:encode_basic_field:
  363|   191k|{
  364|   191k|    if (!field->pData)
  ------------------
  |  Branch (364:9): [True: 0, False: 191k]
  ------------------
  365|      0|    {
  366|       |        /* Missing pointer field */
  367|      0|        return true;
  368|      0|    }
  369|       |
  370|   191k|    if (!pb_encode_tag_for_field(stream, field))
  ------------------
  |  Branch (370:9): [True: 0, False: 191k]
  ------------------
  371|      0|        return false;
  372|       |
  373|   191k|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  299|   191k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   191k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  374|   191k|    {
  375|  2.69k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  239|  2.69k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (375:9): [True: 2.69k, False: 189k]
  ------------------
  376|  2.69k|            return pb_enc_bool(stream, field);
  377|       |
  378|  74.6k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  240|  74.6k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (378:9): [True: 74.6k, False: 117k]
  ------------------
  379|   113k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  241|   113k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (379:9): [True: 39.1k, False: 152k]
  ------------------
  380|   129k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  242|   129k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (380:9): [True: 15.6k, False: 176k]
  ------------------
  381|   129k|            return pb_enc_varint(stream, field);
  382|       |
  383|  10.4k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  243|  10.4k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (383:9): [True: 10.4k, False: 181k]
  ------------------
  384|  18.7k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  244|  18.7k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (384:9): [True: 8.31k, False: 183k]
  ------------------
  385|  18.7k|            return pb_enc_fixed(stream, field);
  386|       |
  387|  3.39k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  251|  3.39k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (387:9): [True: 3.39k, False: 188k]
  ------------------
  388|  3.39k|            return pb_enc_bytes(stream, field);
  389|       |
  390|  14.4k|        case PB_LTYPE_STRING:
  ------------------
  |  |  255|  14.4k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (390:9): [True: 14.4k, False: 177k]
  ------------------
  391|  14.4k|            return pb_enc_string(stream, field);
  392|       |
  393|  19.1k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  259|  19.1k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (393:9): [True: 19.1k, False: 172k]
  ------------------
  394|  19.1k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  264|  19.1k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (394:9): [True: 0, False: 191k]
  ------------------
  395|  19.1k|            return pb_enc_submessage(stream, field);
  396|       |
  397|  4.07k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  274|  4.07k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (397:9): [True: 4.07k, False: 187k]
  ------------------
  398|  4.07k|            return pb_enc_fixed_length_bytes(stream, field);
  399|       |
  400|      0|        default:
  ------------------
  |  Branch (400:9): [True: 0, False: 191k]
  ------------------
  401|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  402|   191k|    }
  403|   191k|}
pb_encode.c:pb_enc_bool:
  777|  2.69k|{
  778|  2.69k|    uint32_t value = safe_read_bool(field->pData) ? 1 : 0;
  ------------------
  |  Branch (778:22): [True: 1.79k, False: 902]
  ------------------
  779|  2.69k|    PB_UNUSED(field);
  ------------------
  |  |  143|  2.69k|#define PB_UNUSED(x) (void)(x)
  ------------------
  780|  2.69k|    return pb_encode_varint(stream, value);
  781|  2.69k|}
pb_encode.c:pb_enc_bytes:
  857|  3.39k|{
  858|  3.39k|    const pb_bytes_array_t *bytes = NULL;
  859|       |
  860|  3.39k|    bytes = (const pb_bytes_array_t*)field->pData;
  861|       |    
  862|  3.39k|    if (bytes == NULL)
  ------------------
  |  Branch (862:9): [True: 0, False: 3.39k]
  ------------------
  863|      0|    {
  864|       |        /* Treat null pointer as an empty bytes field */
  865|      0|        return pb_encode_string(stream, NULL, 0);
  866|      0|    }
  867|       |    
  868|  3.39k|    if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  297|  3.39k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  3.39k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  292|  6.78k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (868:9): [True: 3.39k, False: 0]
  ------------------
  869|  3.39k|        bytes->size > field->data_size - offsetof(pb_bytes_array_t, bytes))
  ------------------
  |  Branch (869:9): [True: 0, False: 3.39k]
  ------------------
  870|      0|    {
  871|      0|        PB_RETURN_ERROR(stream, "bytes size exceeded");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  872|      0|    }
  873|       |    
  874|  3.39k|    return pb_encode_string(stream, bytes->bytes, (size_t)bytes->size);
  875|  3.39k|}
pb_encode.c:pb_enc_string:
  878|  14.4k|{
  879|  14.4k|    size_t size = 0;
  880|  14.4k|    size_t max_size = (size_t)field->data_size;
  881|  14.4k|    const char *str = (const char*)field->pData;
  882|       |    
  883|  14.4k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  297|  14.4k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  14.4k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  293|  14.4k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (883:9): [True: 0, False: 14.4k]
  ------------------
  884|      0|    {
  885|      0|        max_size = (size_t)-1;
  886|      0|    }
  887|  14.4k|    else
  888|  14.4k|    {
  889|       |        /* pb_dec_string() assumes string fields end with a null
  890|       |         * terminator when the type isn't PB_ATYPE_POINTER, so we
  891|       |         * shouldn't allow more than max-1 bytes to be written to
  892|       |         * allow space for the null terminator.
  893|       |         */
  894|  14.4k|        if (max_size == 0)
  ------------------
  |  Branch (894:13): [True: 0, False: 14.4k]
  ------------------
  895|      0|            PB_RETURN_ERROR(stream, "zero-length string");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  896|       |
  897|  14.4k|        max_size -= 1;
  898|  14.4k|    }
  899|       |
  900|       |
  901|  14.4k|    if (str == NULL)
  ------------------
  |  Branch (901:9): [True: 0, False: 14.4k]
  ------------------
  902|      0|    {
  903|      0|        size = 0; /* Treat null pointer as an empty string */
  904|      0|    }
  905|  14.4k|    else
  906|  14.4k|    {
  907|  14.4k|        const char *p = str;
  908|       |
  909|       |        /* strnlen() is not always available, so just use a loop */
  910|  57.2k|        while (size < max_size && *p != '\0')
  ------------------
  |  Branch (910:16): [True: 57.0k, False: 216]
  |  Branch (910:35): [True: 42.7k, False: 14.2k]
  ------------------
  911|  42.7k|        {
  912|  42.7k|            size++;
  913|  42.7k|            p++;
  914|  42.7k|        }
  915|       |
  916|  14.4k|        if (*p != '\0')
  ------------------
  |  Branch (916:13): [True: 0, False: 14.4k]
  ------------------
  917|      0|        {
  918|      0|            PB_RETURN_ERROR(stream, "unterminated string");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  919|      0|        }
  920|  14.4k|    }
  921|       |
  922|       |#ifdef PB_VALIDATE_UTF8
  923|       |    if (!pb_validate_utf8(str))
  924|       |        PB_RETURN_ERROR(stream, "invalid utf8");
  925|       |#endif
  926|       |
  927|  14.4k|    return pb_encode_string(stream, (const pb_byte_t*)str, size);
  928|  14.4k|}
pb_encode.c:pb_enc_submessage:
  931|  19.1k|{
  932|  19.1k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (932:9): [True: 0, False: 19.1k]
  ------------------
  933|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  934|       |
  935|  19.1k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  299|  19.1k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  19.1k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  264|  38.2k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (935:9): [True: 0, False: 19.1k]
  |  Branch (935:58): [True: 0, False: 0]
  ------------------
  936|      0|    {
  937|       |        /* Message callback is stored right before pSize. */
  938|      0|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
  939|      0|        if (callback->funcs.encode)
  ------------------
  |  Branch (939:13): [True: 0, False: 0]
  ------------------
  940|      0|        {
  941|      0|            if (!callback->funcs.encode(stream, field, &callback->arg))
  ------------------
  |  Branch (941:17): [True: 0, False: 0]
  ------------------
  942|      0|                return false;
  943|      0|        }
  944|      0|    }
  945|       |    
  946|  19.1k|    return pb_encode_submessage(stream, field->submsg_desc, field->pData);
  947|  19.1k|}
pb_encode.c:pb_enc_fixed_length_bytes:
  950|  4.07k|{
  951|  4.07k|    return pb_encode_string(stream, (const pb_byte_t*)field->pData, (size_t)field->data_size);
  952|  4.07k|}
pb_encode.c:pb_encode_varint_32:
  574|  70.7k|{
  575|  70.7k|    size_t i = 0;
  576|  70.7k|    pb_byte_t buffer[10];
  577|  70.7k|    pb_byte_t byte = (pb_byte_t)(low & 0x7F);
  578|  70.7k|    low >>= 7;
  579|       |
  580|   188k|    while (i < 4 && (low != 0 || high != 0))
  ------------------
  |  Branch (580:12): [True: 178k, False: 10.7k]
  |  Branch (580:22): [True: 117k, False: 60.2k]
  |  Branch (580:34): [True: 214, False: 60.0k]
  ------------------
  581|   118k|    {
  582|   118k|        byte |= 0x80;
  583|   118k|        buffer[i++] = byte;
  584|   118k|        byte = (pb_byte_t)(low & 0x7F);
  585|   118k|        low >>= 7;
  586|   118k|    }
  587|       |
  588|  70.7k|    if (high)
  ------------------
  |  Branch (588:9): [True: 8.97k, False: 61.8k]
  ------------------
  589|  8.97k|    {
  590|  8.97k|        byte = (pb_byte_t)(byte | ((high & 0x07) << 4));
  591|  8.97k|        high >>= 3;
  592|       |
  593|  47.5k|        while (high)
  ------------------
  |  Branch (593:16): [True: 38.5k, False: 8.97k]
  ------------------
  594|  38.5k|        {
  595|  38.5k|            byte |= 0x80;
  596|  38.5k|            buffer[i++] = byte;
  597|  38.5k|            byte = (pb_byte_t)(high & 0x7F);
  598|  38.5k|            high >>= 7;
  599|  38.5k|        }
  600|  8.97k|    }
  601|       |
  602|  70.7k|    buffer[i++] = byte;
  603|       |
  604|  70.7k|    return pb_write(stream, buffer, i);
  605|  70.7k|}

malloc_with_check:
   55|  11.1k|{
   56|  11.1k|    char *buf = NULL;
   57|       |
   58|  11.1k|    if (size <= g_max_alloc_bytes - g_alloc_bytes)
  ------------------
  |  Branch (58:9): [True: 11.1k, False: 0]
  ------------------
   59|  11.1k|    {
   60|  11.1k|        buf = malloc(round_blocksize(size + GUARD_SIZE));
  ------------------
  |  |   12|  11.1k|#define GUARD_SIZE (sizeof(size_t)*3)
  ------------------
   61|  11.1k|    }
   62|       |
   63|  11.1k|    if (buf)
  ------------------
  |  Branch (63:9): [True: 11.1k, False: 0]
  ------------------
   64|  11.1k|    {
   65|  11.1k|        ((size_t*)buf)[0] = size;
   66|  11.1k|        ((size_t*)buf)[1] = CHECK1;
  ------------------
  |  |   14|  11.1k|#define CHECK1 ((size_t)0xDEADBEEF)
  ------------------
   67|  11.1k|        ((size_t*)(buf + size))[2] = CHECK2;
  ------------------
  |  |   15|  11.1k|#define CHECK2 ((size_t)0x600DCAFE)
  ------------------
   68|  11.1k|        g_alloc_count++;
   69|  11.1k|        g_alloc_bytes += size;
   70|  11.1k|        if (DEBUG_MALLOC) fprintf(stderr, "Alloc 0x%04x/%u\n", (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   22|  11.1k|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (22:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
                      if (DEBUG_MALLOC) fprintf(stderr, "Alloc 0x%04x/%u\n", (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   13|      0|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   71|  11.1k|        return buf + PREFIX_SIZE;
  ------------------
  |  |   13|  11.1k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   72|  11.1k|    }
   73|      0|    else
   74|      0|    {
   75|      0|        if (DEBUG_MALLOC) fprintf(stderr, "malloc(%u) failed\n", (unsigned)size);
  ------------------
  |  |   22|      0|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (22:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
   76|      0|        return NULL;
   77|      0|    }
   78|  11.1k|}
free_with_check:
   82|  11.1k|{
   83|  11.1k|    if (mem)
  ------------------
  |  Branch (83:9): [True: 11.1k, False: 0]
  ------------------
   84|  11.1k|    {
   85|  11.1k|        char *buf = (char*)mem - PREFIX_SIZE;
  ------------------
  |  |   13|  11.1k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   86|  11.1k|        size_t size = ((size_t*)buf)[0];
   87|  11.1k|        if (DEBUG_MALLOC) fprintf(stderr, "Release 0x%04x/%u\n", (unsigned)(uintptr_t)mem, (unsigned)size);
  ------------------
  |  |   22|  11.1k|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (22:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
   88|  11.1k|        assert(((size_t*)buf)[1] == CHECK1);
   89|  11.1k|        assert(((size_t*)(buf + size))[2] == CHECK2);
   90|  11.1k|        assert(g_alloc_count > 0);
   91|  11.1k|        assert(g_alloc_bytes >= size);
   92|  11.1k|        ((size_t*)buf)[1] = 0;
   93|  11.1k|        ((size_t*)(buf + size))[2] = 0;
   94|  11.1k|        g_alloc_count--;
   95|  11.1k|        g_alloc_bytes -= size;
   96|  11.1k|        free(buf);
   97|  11.1k|    }
   98|  11.1k|}
get_alloc_count:
  163|  17.0k|{
  164|  17.0k|    return g_alloc_count;
  165|  17.0k|}
malloc_wrappers.c:round_blocksize:
   36|  11.1k|{
   37|  11.1k|    if (size < 256)
  ------------------
  |  Branch (37:9): [True: 0, False: 11.1k]
  ------------------
   38|      0|    {
   39|      0|        return size;
   40|      0|    }
   41|  11.1k|    else
   42|  11.1k|    {
   43|  11.1k|        return (size + 1023) / 1024 * 1024;
   44|  11.1k|    }
   45|  11.1k|}

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

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

validate_static:
    7|   486k|{
    8|   486k|    pb_size_t count = 1;
    9|   486k|    pb_size_t i;
   10|   486k|    bool truebool = true;
   11|   486k|    bool falsebool = false;
   12|       |
   13|   486k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  298|   486k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   486k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  285|   972k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 107k, False: 378k]
  |  Branch (13:54): [True: 107k, False: 0]
  ------------------
   14|   107k|    {
   15|       |        /* Array count must be between 0 and statically allocated size */
   16|   107k|        count = *(pb_size_t*)iter->pSize;
   17|   107k|        assert(count <= iter->array_size);
   18|   107k|    }
   19|   378k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  298|   378k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   378k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  283|   756k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 117k, False: 260k]
  |  Branch (19:59): [True: 117k, False: 0]
  ------------------
   20|   117k|    {
   21|       |        /* Boolean has_ field must have a valid value */
   22|   117k|        assert(memcmp(iter->pSize, &truebool, sizeof(bool)) == 0 ||
   23|   117k|               memcmp(iter->pSize, &falsebool, sizeof(bool)) == 0);
   24|   117k|    }
   25|   260k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  298|   260k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   260k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|   260k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 15.3k, False: 245k]
  ------------------
   26|  15.3k|    {
   27|  15.3k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 13.9k, False: 1.46k]
  ------------------
   28|  13.9k|        {
   29|       |            /* Some different field in oneof */
   30|  13.9k|            return;
   31|  13.9k|        }
   32|  15.3k|    }
   33|       |
   34|   915k|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 442k, False: 472k]
  ------------------
   35|   442k|    {
   36|   442k|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|   442k|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  299|   442k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   442k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  255|   442k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 27.1k, False: 415k]
  ------------------
   39|  27.1k|        {
   40|       |            /* String length must be at most statically allocated size */
   41|  27.1k|            assert(strlen(pData) + 1 <= iter->data_size);
   42|  27.1k|        }
   43|   415k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  299|   415k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   415k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  251|   415k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 11.5k, False: 404k]
  ------------------
   44|  11.5k|        {
   45|       |            /* Bytes length must be at most statically allocated size */
   46|  11.5k|            pb_bytes_array_t *bytes = pData;
   47|  11.5k|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= iter->data_size);
   48|  11.5k|        }
   49|   404k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  299|   404k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   404k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  239|   404k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 12.0k, False: 392k]
  ------------------
   50|  12.0k|        {
   51|       |            /* Bool fields must have valid value */
   52|  12.0k|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
   53|  12.0k|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
   54|  12.0k|        }
   55|   392k|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  300|   392k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|   392k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|   392k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|   784k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 42.6k, False: 349k]
  |  |  ------------------
  |  |  301|   392k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|   349k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|   349k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|   349k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 0, False: 349k]
  |  |  ------------------
  ------------------
   56|  42.6k|        {
   57|  42.6k|            validate_message(pData, 0, iter->submsg_desc);
   58|  42.6k|        }
   59|   442k|    }
   60|   472k|}
validate_message:
  145|  47.7k|{
  146|  47.7k|    pb_field_iter_t iter;
  147|       |
  148|  47.7k|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 35.5k, False: 12.2k]
  ------------------
  149|  35.5k|    {
  150|  35.5k|        do
  151|   491k|        {
  152|   491k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  297|   491k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|   491k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  292|   491k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 486k, False: 5.12k]
  ------------------
  153|   486k|            {
  154|   486k|                validate_static(&iter);
  155|   486k|            }
  156|  5.12k|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  297|  5.12k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  5.12k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  293|  5.12k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 0, False: 5.12k]
  ------------------
  157|      0|            {
  158|      0|                validate_pointer(&iter);
  159|      0|            }
  160|   491k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 455k, False: 35.5k]
  ------------------
  161|  35.5k|    }
  162|  47.7k|}

