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

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

pb_ostream_from_buffer:
   63|  2.59k|{
   64|  2.59k|    pb_ostream_t stream;
   65|       |#ifdef PB_BUFFER_ONLY
   66|       |    /* In PB_BUFFER_ONLY configuration the callback pointer is just int*.
   67|       |     * NULL pointer marks a sizing field, so put a non-NULL value to mark a buffer stream.
   68|       |     */
   69|       |    static const int marker = 0;
   70|       |    stream.callback = &marker;
   71|       |#else
   72|  2.59k|    stream.callback = &buf_write;
   73|  2.59k|#endif
   74|  2.59k|    stream.state = buf;
   75|  2.59k|    stream.max_size = bufsize;
   76|  2.59k|    stream.bytes_written = 0;
   77|  2.59k|#ifndef PB_NO_ERRMSG
   78|  2.59k|    stream.errmsg = NULL;
   79|  2.59k|#endif
   80|  2.59k|    return stream;
   81|  2.59k|}
pb_write:
   84|   489k|{
   85|   489k|    if (count > 0 && stream->callback != NULL)
  ------------------
  |  Branch (85:9): [True: 476k, False: 13.6k]
  |  Branch (85:22): [True: 328k, False: 147k]
  ------------------
   86|   328k|    {
   87|   328k|        if (stream->bytes_written + count < stream->bytes_written ||
  ------------------
  |  Branch (87:13): [True: 0, False: 328k]
  ------------------
   88|   328k|            stream->bytes_written + count > stream->max_size)
  ------------------
  |  Branch (88:13): [True: 0, False: 328k]
  ------------------
   89|      0|        {
   90|      0|            PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|      0|        }
   92|       |
   93|       |#ifdef PB_BUFFER_ONLY
   94|       |        if (!buf_write(stream, buf, count))
   95|       |            PB_RETURN_ERROR(stream, "io error");
   96|       |#else        
   97|   328k|        if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (97:13): [True: 0, False: 328k]
  ------------------
   98|      0|            PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   99|   328k|#endif
  100|   328k|    }
  101|       |    
  102|   489k|    stream->bytes_written += count;
  103|   489k|    return true;
  104|   489k|}
pb_encode:
  512|  41.8k|{
  513|  41.8k|    pb_field_iter_t iter;
  514|  41.8k|    if (!pb_field_iter_begin_const(&iter, fields, src_struct))
  ------------------
  |  Branch (514:9): [True: 7.91k, False: 33.9k]
  ------------------
  515|  7.91k|        return true; /* Empty message type */
  516|       |    
  517|   312k|    do {
  518|   312k|        if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  288|   312k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   312k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  257|   312k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (518:13): [True: 2.59k, False: 309k]
  ------------------
  519|  2.59k|        {
  520|       |            /* Special case for the extension field placeholder */
  521|  2.59k|            if (!encode_extension_field(stream, &iter))
  ------------------
  |  Branch (521:17): [True: 0, False: 2.59k]
  ------------------
  522|      0|                return false;
  523|  2.59k|        }
  524|   309k|        else
  525|   309k|        {
  526|       |            /* Regular field */
  527|   309k|            if (!encode_field(stream, &iter))
  ------------------
  |  Branch (527:17): [True: 0, False: 309k]
  ------------------
  528|      0|                return false;
  529|   309k|        }
  530|   312k|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (530:14): [True: 278k, False: 33.9k]
  ------------------
  531|       |    
  532|  33.9k|    return true;
  533|  33.9k|}
pb_encode_varint:
  607|   436k|{
  608|   436k|    if (value <= 0x7F)
  ------------------
  |  Branch (608:9): [True: 362k, False: 74.7k]
  ------------------
  609|   362k|    {
  610|       |        /* Fast path: single byte */
  611|   362k|        pb_byte_t byte = (pb_byte_t)value;
  612|   362k|        return pb_write(stream, &byte, 1);
  613|   362k|    }
  614|  74.7k|    else
  615|  74.7k|    {
  616|       |#ifdef PB_WITHOUT_64BIT
  617|       |        return pb_encode_varint_32(stream, value, 0);
  618|       |#else
  619|  74.7k|        return pb_encode_varint_32(stream, (uint32_t)value, (uint32_t)(value >> 32));
  620|  74.7k|#endif
  621|  74.7k|    }
  622|   436k|}
pb_encode_svarint:
  625|  21.8k|{
  626|  21.8k|    pb_uint64_t zigzagged;
  ------------------
  |  |   45|  21.8k|#define pb_uint64_t uint64_t
  ------------------
  627|  21.8k|    pb_uint64_t mask = ((pb_uint64_t)-1) >> 1; /* Satisfy clang -fsanitize=integer */
  ------------------
  |  |   45|  21.8k|#define pb_uint64_t uint64_t
  ------------------
  628|  21.8k|    if (value < 0)
  ------------------
  |  Branch (628:9): [True: 9.96k, False: 11.8k]
  ------------------
  629|  9.96k|        zigzagged = ~(((pb_uint64_t)value & mask) << 1);
  630|  11.8k|    else
  631|  11.8k|        zigzagged = (pb_uint64_t)value << 1;
  632|       |    
  633|  21.8k|    return pb_encode_varint(stream, zigzagged);
  634|  21.8k|}
pb_encode_fixed32:
  637|  19.4k|{
  638|  19.4k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
  639|       |    /* Fast path if we know that we're on little endian */
  640|  19.4k|    return pb_write(stream, (const pb_byte_t*)value, 4);
  641|       |#else
  642|       |    uint32_t val = *(const uint32_t*)value;
  643|       |    pb_byte_t bytes[4];
  644|       |    bytes[0] = (pb_byte_t)(val & 0xFF);
  645|       |    bytes[1] = (pb_byte_t)((val >> 8) & 0xFF);
  646|       |    bytes[2] = (pb_byte_t)((val >> 16) & 0xFF);
  647|       |    bytes[3] = (pb_byte_t)((val >> 24) & 0xFF);
  648|       |    return pb_write(stream, bytes, 4);
  649|       |#endif
  650|  19.4k|}
pb_encode_fixed64:
  654|  10.6k|{
  655|  10.6k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
  656|       |    /* Fast path if we know that we're on little endian */
  657|  10.6k|    return pb_write(stream, (const pb_byte_t*)value, 8);
  658|       |#else
  659|       |    uint64_t val = *(const uint64_t*)value;
  660|       |    pb_byte_t bytes[8];
  661|       |    bytes[0] = (pb_byte_t)(val & 0xFF);
  662|       |    bytes[1] = (pb_byte_t)((val >> 8) & 0xFF);
  663|       |    bytes[2] = (pb_byte_t)((val >> 16) & 0xFF);
  664|       |    bytes[3] = (pb_byte_t)((val >> 24) & 0xFF);
  665|       |    bytes[4] = (pb_byte_t)((val >> 32) & 0xFF);
  666|       |    bytes[5] = (pb_byte_t)((val >> 40) & 0xFF);
  667|       |    bytes[6] = (pb_byte_t)((val >> 48) & 0xFF);
  668|       |    bytes[7] = (pb_byte_t)((val >> 56) & 0xFF);
  669|       |    return pb_write(stream, bytes, 8);
  670|       |#endif
  671|  10.6k|}
pb_encode_tag:
  675|   204k|{
  676|   204k|    pb_uint64_t tag = ((pb_uint64_t)field_number << 3) | wiretype;
  ------------------
  |  |   45|   204k|#define pb_uint64_t uint64_t
  ------------------
  677|   204k|    return pb_encode_varint(stream, tag);
  678|   204k|}
pb_encode_tag_for_field:
  681|   195k|{
  682|   195k|    pb_wire_type_t wiretype;
  683|   195k|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  288|   195k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   195k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  684|   195k|    {
  685|  2.72k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  228|  2.72k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (685:9): [True: 2.72k, False: 192k]
  ------------------
  686|  78.4k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  229|  78.4k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (686:9): [True: 75.7k, False: 119k]
  ------------------
  687|   118k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  230|   118k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (687:9): [True: 39.7k, False: 155k]
  ------------------
  688|   134k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  231|   134k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (688:9): [True: 15.8k, False: 179k]
  ------------------
  689|   134k|            wiretype = PB_WT_VARINT;
  690|   134k|            break;
  691|       |        
  692|  10.4k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  232|  10.4k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (692:9): [True: 10.4k, False: 185k]
  ------------------
  693|  10.4k|            wiretype = PB_WT_32BIT;
  694|  10.4k|            break;
  695|       |        
  696|  8.43k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  233|  8.43k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (696:9): [True: 8.43k, False: 187k]
  ------------------
  697|  8.43k|            wiretype = PB_WT_64BIT;
  698|  8.43k|            break;
  699|       |        
  700|  3.50k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  240|  3.50k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (700:9): [True: 3.50k, False: 192k]
  ------------------
  701|  18.6k|        case PB_LTYPE_STRING:
  ------------------
  |  |  244|  18.6k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (701:9): [True: 15.1k, False: 180k]
  ------------------
  702|  38.2k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  248|  38.2k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (702:9): [True: 19.6k, False: 175k]
  ------------------
  703|  38.2k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  253|  38.2k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (703:9): [True: 0, False: 195k]
  ------------------
  704|  42.5k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  263|  42.5k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (704:9): [True: 4.30k, False: 191k]
  ------------------
  705|  42.5k|            wiretype = PB_WT_STRING;
  706|  42.5k|            break;
  707|       |        
  708|      0|        default:
  ------------------
  |  Branch (708:9): [True: 0, False: 195k]
  ------------------
  709|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  710|   195k|    }
  711|       |    
  712|   195k|    return pb_encode_tag(stream, wiretype, field->tag);
  713|   195k|}
pb_encode_string:
  716|  22.9k|{
  717|  22.9k|    if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (717:9): [True: 0, False: 22.9k]
  ------------------
  718|      0|        return false;
  719|       |    
  720|  22.9k|    return pb_write(stream, buffer, size);
  721|  22.9k|}
pb_encode_submessage:
  724|  19.6k|{
  725|       |    /* First calculate the message size using a non-writing substream. */
  726|  19.6k|    pb_ostream_t substream = PB_OSTREAM_SIZING;
  ------------------
  |  |  116|  19.6k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  727|  19.6k|    size_t size;
  728|  19.6k|    bool status;
  729|       |    
  730|  19.6k|    if (!pb_encode(&substream, fields, src_struct))
  ------------------
  |  Branch (730:9): [True: 0, False: 19.6k]
  ------------------
  731|      0|    {
  732|      0|#ifndef PB_NO_ERRMSG
  733|      0|        stream->errmsg = substream.errmsg;
  734|      0|#endif
  735|      0|        return false;
  736|      0|    }
  737|       |    
  738|  19.6k|    size = substream.bytes_written;
  739|       |    
  740|  19.6k|    if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (740:9): [True: 0, False: 19.6k]
  ------------------
  741|      0|        return false;
  742|       |    
  743|  19.6k|    if (stream->callback == NULL)
  ------------------
  |  Branch (743:9): [True: 0, False: 19.6k]
  ------------------
  744|      0|        return pb_write(stream, NULL, size); /* Just sizing */
  745|       |    
  746|  19.6k|    if (stream->bytes_written + size > stream->max_size)
  ------------------
  |  Branch (746:9): [True: 0, False: 19.6k]
  ------------------
  747|      0|        PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  748|       |        
  749|       |    /* Use a substream to verify that a callback doesn't write more than
  750|       |     * what it did the first time. */
  751|  19.6k|    substream.callback = stream->callback;
  752|  19.6k|    substream.state = stream->state;
  753|  19.6k|    substream.max_size = size;
  754|  19.6k|    substream.bytes_written = 0;
  755|  19.6k|#ifndef PB_NO_ERRMSG
  756|  19.6k|    substream.errmsg = NULL;
  757|  19.6k|#endif
  758|       |    
  759|  19.6k|    status = pb_encode(&substream, fields, src_struct);
  760|       |    
  761|  19.6k|    stream->bytes_written += substream.bytes_written;
  762|  19.6k|    stream->state = substream.state;
  763|  19.6k|#ifndef PB_NO_ERRMSG
  764|  19.6k|    stream->errmsg = substream.errmsg;
  765|  19.6k|#endif
  766|       |    
  767|  19.6k|    if (substream.bytes_written != size)
  ------------------
  |  Branch (767:9): [True: 0, False: 19.6k]
  ------------------
  768|      0|        PB_RETURN_ERROR(stream, "submsg size changed");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  769|       |    
  770|  19.6k|    return status;
  771|  19.6k|}
pb_encode.c:buf_write:
   53|   328k|{
   54|   328k|    pb_byte_t *dest = (pb_byte_t*)stream->state;
   55|   328k|    stream->state = dest + count;
   56|       |    
   57|   328k|    memcpy(dest, buf, count * sizeof(pb_byte_t));
   58|       |    
   59|   328k|    return true;
   60|   328k|}
pb_encode.c:encode_extension_field:
  487|  2.59k|{
  488|  2.59k|    const pb_extension_t *extension = *(const pb_extension_t* const *)field->pData;
  489|       |
  490|  5.19k|    while (extension)
  ------------------
  |  Branch (490:12): [True: 2.59k, False: 2.59k]
  ------------------
  491|  2.59k|    {
  492|  2.59k|        bool status;
  493|  2.59k|        if (extension->type->encode)
  ------------------
  |  Branch (493:13): [True: 0, False: 2.59k]
  ------------------
  494|      0|            status = extension->type->encode(stream, extension);
  495|  2.59k|        else
  496|  2.59k|            status = default_extension_encoder(stream, extension);
  497|       |
  498|  2.59k|        if (!status)
  ------------------
  |  Branch (498:13): [True: 0, False: 2.59k]
  ------------------
  499|      0|            return false;
  500|       |        
  501|  2.59k|        extension = extension->next;
  502|  2.59k|    }
  503|       |    
  504|  2.59k|    return true;
  505|  2.59k|}
pb_encode.c:default_extension_encoder:
  474|  2.59k|{
  475|  2.59k|    pb_field_iter_t iter;
  476|       |
  477|  2.59k|    if (!pb_field_iter_begin_extension_const(&iter, extension))
  ------------------
  |  Branch (477:9): [True: 0, False: 2.59k]
  ------------------
  478|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  479|       |
  480|  2.59k|    return encode_field(stream, &iter);
  481|  2.59k|}
pb_encode.c:encode_field:
  418|   312k|{
  419|       |    /* Check field presence */
  420|   312k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|   312k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|   312k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  276|   312k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (420:9): [True: 7.78k, False: 304k]
  ------------------
  421|  7.78k|    {
  422|  7.78k|        if (*(const pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (422:13): [True: 7.01k, False: 770]
  ------------------
  423|  7.01k|        {
  424|       |            /* Different type oneof field */
  425|  7.01k|            return true;
  426|  7.01k|        }
  427|  7.78k|    }
  428|   304k|    else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  287|   304k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|   304k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  272|   304k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (428:14): [True: 67.6k, False: 236k]
  ------------------
  429|  67.6k|    {
  430|  67.6k|        if (field->pSize)
  ------------------
  |  Branch (430:13): [True: 67.6k, False: 0]
  ------------------
  431|  67.6k|        {
  432|  67.6k|            if (safe_read_bool(field->pSize) == false)
  ------------------
  |  Branch (432:17): [True: 61.0k, False: 6.61k]
  ------------------
  433|  61.0k|            {
  434|       |                /* Missing optional field */
  435|  61.0k|                return true;
  436|  61.0k|            }
  437|  67.6k|        }
  438|      0|        else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  286|      0|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|      0|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  281|      0|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (438:18): [True: 0, False: 0]
  ------------------
  439|      0|        {
  440|       |            /* Proto3 singular field */
  441|      0|            if (pb_check_proto3_default_value(field))
  ------------------
  |  Branch (441:17): [True: 0, False: 0]
  ------------------
  442|      0|                return true;
  443|      0|        }
  444|  67.6k|    }
  445|       |
  446|   244k|    if (!field->pData)
  ------------------
  |  Branch (446:9): [True: 0, False: 244k]
  ------------------
  447|      0|    {
  448|      0|        if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  287|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  271|      0|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (448:13): [True: 0, False: 0]
  ------------------
  449|      0|            PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  450|       |
  451|       |        /* Pointer field set to NULL */
  452|      0|        return true;
  453|      0|    }
  454|       |
  455|       |    /* Then encode field contents */
  456|   244k|    if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  286|   244k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|   244k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  283|   244k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (456:9): [True: 0, False: 244k]
  ------------------
  457|      0|    {
  458|      0|        return encode_callback_field(stream, field);
  459|      0|    }
  460|   244k|    else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  287|   244k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|   244k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  274|   244k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (460:14): [True: 54.5k, False: 189k]
  ------------------
  461|  54.5k|    {
  462|  54.5k|        return encode_array(stream, field);
  463|  54.5k|    }
  464|   189k|    else
  465|   189k|    {
  466|   189k|        return encode_basic_field(stream, field);
  467|   189k|    }
  468|   244k|}
pb_encode.c:safe_read_bool:
  115|  70.4k|{
  116|  70.4k|    const char *p = (const char *)pSize;
  117|  70.4k|    size_t i;
  118|   132k|    for (i = 0; i < sizeof(bool); i++)
  ------------------
  |  Branch (118:17): [True: 70.4k, False: 62.0k]
  ------------------
  119|  70.4k|    {
  120|  70.4k|        if (p[i] != 0)
  ------------------
  |  Branch (120:13): [True: 8.41k, False: 62.0k]
  ------------------
  121|  8.41k|            return true;
  122|  70.4k|    }
  123|  62.0k|    return false;
  124|  70.4k|}
pb_encode.c:encode_array:
  128|  54.5k|{
  129|  54.5k|    pb_size_t i;
  130|  54.5k|    pb_size_t count;
  131|  54.5k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  132|  54.5k|    size_t size;
  133|  54.5k|#endif
  134|       |
  135|  54.5k|    count = *(pb_size_t*)field->pSize;
  136|       |
  137|  54.5k|    if (count == 0)
  ------------------
  |  Branch (137:9): [True: 44.2k, False: 10.2k]
  ------------------
  138|  44.2k|        return true;
  139|       |
  140|  10.2k|    if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  286|  10.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|  10.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  282|  20.4k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (140:9): [True: 10.2k, False: 0]
  |  Branch (140:54): [True: 0, False: 10.2k]
  ------------------
  141|      0|        PB_RETURN_ERROR(stream, "array max size exceeded");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  142|       |    
  143|  10.2k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  144|       |    /* We always pack arrays if the datatype allows it. */
  145|  10.2k|    if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  288|  10.2k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|  10.2k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  236|  10.2k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (145:9): [True: 8.70k, False: 1.54k]
  ------------------
  146|  8.70k|    {
  147|  8.70k|        if (!pb_encode_tag(stream, PB_WT_STRING, field->tag))
  ------------------
  |  Branch (147:13): [True: 0, False: 8.70k]
  ------------------
  148|      0|            return false;
  149|       |        
  150|       |        /* Determine the total size of packed array. */
  151|  8.70k|        if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  288|  8.70k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|  8.70k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  232|  8.70k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (151:13): [True: 3.09k, False: 5.61k]
  ------------------
  152|  3.09k|        {
  153|  3.09k|            size = 4 * (size_t)count;
  154|  3.09k|        }
  155|  5.61k|        else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  288|  5.61k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|  5.61k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  233|  5.61k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (155:18): [True: 582, False: 5.03k]
  ------------------
  156|    582|        {
  157|    582|            size = 8 * (size_t)count;
  158|    582|        }
  159|  5.03k|        else
  160|  5.03k|        { 
  161|  5.03k|            pb_ostream_t sizestream = PB_OSTREAM_SIZING;
  ------------------
  |  |  116|  5.03k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  162|  5.03k|            void *pData_orig = field->pData;
  163|  28.6k|            for (i = 0; i < count; i++)
  ------------------
  |  Branch (163:25): [True: 23.6k, False: 5.03k]
  ------------------
  164|  23.6k|            {
  165|  23.6k|                if (!pb_enc_varint(&sizestream, field))
  ------------------
  |  Branch (165:21): [True: 0, False: 23.6k]
  ------------------
  166|      0|                    PB_RETURN_ERROR(stream, PB_GET_ERROR(&sizestream));
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  |  Branch (885:92): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  167|  23.6k|                field->pData = (char*)field->pData + field->data_size;
  168|  23.6k|            }
  169|  5.03k|            field->pData = pData_orig;
  170|  5.03k|            size = sizestream.bytes_written;
  171|  5.03k|        }
  172|       |        
  173|  8.70k|        if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (173:13): [True: 0, False: 8.70k]
  ------------------
  174|      0|            return false;
  175|       |        
  176|  8.70k|        if (stream->callback == NULL)
  ------------------
  |  Branch (176:13): [True: 0, False: 8.70k]
  ------------------
  177|      0|            return pb_write(stream, NULL, size); /* Just sizing.. */
  178|       |        
  179|       |        /* Write the data */
  180|  43.4k|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (180:21): [True: 34.7k, False: 8.70k]
  ------------------
  181|  34.7k|        {
  182|  34.7k|            if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  288|  34.7k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|  34.7k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  232|  69.5k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  288|  25.8k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|  25.8k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  233|  25.8k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (182:17): [True: 8.97k, False: 25.8k]
  |  Branch (182:62): [True: 2.18k, False: 23.6k]
  ------------------
  183|  11.1k|            {
  184|  11.1k|                if (!pb_enc_fixed(stream, field))
  ------------------
  |  Branch (184:21): [True: 0, False: 11.1k]
  ------------------
  185|      0|                    return false;
  186|  11.1k|            }
  187|  23.6k|            else
  188|  23.6k|            {
  189|  23.6k|                if (!pb_enc_varint(stream, field))
  ------------------
  |  Branch (189:21): [True: 0, False: 23.6k]
  ------------------
  190|      0|                    return false;
  191|  23.6k|            }
  192|       |
  193|  34.7k|            field->pData = (char*)field->pData + field->data_size;
  194|  34.7k|        }
  195|  8.70k|    }
  196|  1.54k|    else /* Unpacked fields */
  197|  1.54k|#endif
  198|  1.54k|    {
  199|  7.55k|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (199:21): [True: 6.01k, False: 1.54k]
  ------------------
  200|  6.01k|        {
  201|       |            /* Normally the data is stored directly in the array entries, but
  202|       |             * for pointer-type string and bytes fields, the array entries are
  203|       |             * actually pointers themselves also. So we have to dereference once
  204|       |             * more to get to the actual data. */
  205|  6.01k|            if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  286|  6.01k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|  6.01k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  282|  12.0k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (205:17): [True: 0, False: 6.01k]
  ------------------
  206|  6.01k|                (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  288|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  244|      0|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (206:18): [True: 0, False: 0]
  ------------------
  207|      0|                 PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  288|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                               PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  240|      0|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (207:18): [True: 0, False: 0]
  ------------------
  208|      0|            {
  209|      0|                bool status;
  210|      0|                void *pData_orig = field->pData;
  211|      0|                field->pData = *(void* const*)field->pData;
  212|       |
  213|      0|                if (!field->pData)
  ------------------
  |  Branch (213:21): [True: 0, False: 0]
  ------------------
  214|      0|                {
  215|       |                    /* Null pointer in array is treated as empty string / bytes */
  216|      0|                    status = pb_encode_tag_for_field(stream, field) &&
  ------------------
  |  Branch (216:30): [True: 0, False: 0]
  ------------------
  217|      0|                             pb_encode_varint(stream, 0);
  ------------------
  |  Branch (217:30): [True: 0, False: 0]
  ------------------
  218|      0|                }
  219|      0|                else
  220|      0|                {
  221|      0|                    status = encode_basic_field(stream, field);
  222|      0|                }
  223|       |
  224|      0|                field->pData = pData_orig;
  225|       |
  226|      0|                if (!status)
  ------------------
  |  Branch (226:21): [True: 0, False: 0]
  ------------------
  227|      0|                    return false;
  228|      0|            }
  229|  6.01k|            else
  230|  6.01k|            {
  231|  6.01k|                if (!encode_basic_field(stream, field))
  ------------------
  |  Branch (231:21): [True: 0, False: 6.01k]
  ------------------
  232|      0|                    return false;
  233|  6.01k|            }
  234|  6.01k|            field->pData = (char*)field->pData + field->data_size;
  235|  6.01k|        }
  236|  1.54k|    }
  237|       |    
  238|  10.2k|    return true;
  239|  10.2k|}
pb_encode.c:pb_enc_varint:
  783|   178k|{
  784|   178k|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  288|   178k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   178k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  230|   178k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (784:9): [True: 45.8k, False: 132k]
  ------------------
  785|  45.8k|    {
  786|       |        /* Perform unsigned integer extension */
  787|  45.8k|        pb_uint64_t value = 0;
  ------------------
  |  |   45|  45.8k|#define pb_uint64_t uint64_t
  ------------------
  788|       |
  789|  45.8k|        if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (789:13): [True: 5.19k, False: 40.6k]
  ------------------
  790|  5.19k|            value = *(const uint_least8_t*)field->pData;
  791|  40.6k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (791:18): [True: 5.19k, False: 35.4k]
  ------------------
  792|  5.19k|            value = *(const uint_least16_t*)field->pData;
  793|  35.4k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (793:18): [True: 19.9k, False: 15.5k]
  ------------------
  794|  19.9k|            value = *(const uint32_t*)field->pData;
  795|  15.5k|        else if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (795:18): [True: 15.5k, False: 0]
  ------------------
  796|  15.5k|            value = *(const pb_uint64_t*)field->pData;
  797|      0|        else
  798|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  799|       |
  800|  45.8k|        return pb_encode_varint(stream, value);
  801|  45.8k|    }
  802|   132k|    else
  803|   132k|    {
  804|       |        /* Perform signed integer extension */
  805|   132k|        pb_int64_t value = 0;
  ------------------
  |  |   44|   132k|#define pb_int64_t int64_t
  ------------------
  806|       |
  807|   132k|        if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (807:13): [True: 12.2k, False: 120k]
  ------------------
  808|  12.2k|            value = *(const int_least8_t*)field->pData;
  809|   120k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (809:18): [True: 10.3k, False: 110k]
  ------------------
  810|  10.3k|            value = *(const int_least16_t*)field->pData;
  811|   110k|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (811:18): [True: 88.1k, False: 22.0k]
  ------------------
  812|  88.1k|            value = *(const int32_t*)field->pData;
  813|  22.0k|        else if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (813:18): [True: 22.0k, False: 0]
  ------------------
  814|  22.0k|            value = *(const pb_int64_t*)field->pData;
  815|      0|        else
  816|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  817|       |
  818|   132k|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  288|   132k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   132k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  231|   132k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (818:13): [True: 21.8k, False: 110k]
  ------------------
  819|  21.8k|            return pb_encode_svarint(stream, value);
  820|       |#ifdef PB_WITHOUT_64BIT
  821|       |        else if (value < 0)
  822|       |            return pb_encode_varint_32(stream, (uint32_t)value, (uint32_t)-1);
  823|       |#endif
  824|   110k|        else
  825|   110k|            return pb_encode_varint(stream, (pb_uint64_t)value);
  826|       |
  827|   132k|    }
  828|   178k|}
pb_encode.c:pb_enc_fixed:
  831|  30.0k|{
  832|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  833|       |    if (field->data_size == sizeof(float) && PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  834|       |    {
  835|       |        return pb_encode_float_as_double(stream, *(float*)field->pData);
  836|       |    }
  837|       |#endif
  838|       |
  839|  30.0k|    if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (839:9): [True: 19.4k, False: 10.6k]
  ------------------
  840|  19.4k|    {
  841|  19.4k|        return pb_encode_fixed32(stream, field->pData);
  842|  19.4k|    }
  843|  10.6k|#ifndef PB_WITHOUT_64BIT
  844|  10.6k|    else if (field->data_size == sizeof(uint64_t))
  ------------------
  |  Branch (844:14): [True: 10.6k, False: 0]
  ------------------
  845|  10.6k|    {
  846|  10.6k|        return pb_encode_fixed64(stream, field->pData);
  847|  10.6k|    }
  848|      0|#endif
  849|      0|    else
  850|      0|    {
  851|      0|        PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  852|      0|    }
  853|  30.0k|}
pb_encode.c:encode_basic_field:
  362|   195k|{
  363|   195k|    if (!field->pData)
  ------------------
  |  Branch (363:9): [True: 0, False: 195k]
  ------------------
  364|      0|    {
  365|       |        /* Missing pointer field */
  366|      0|        return true;
  367|      0|    }
  368|       |
  369|   195k|    if (!pb_encode_tag_for_field(stream, field))
  ------------------
  |  Branch (369:9): [True: 0, False: 195k]
  ------------------
  370|      0|        return false;
  371|       |
  372|   195k|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  288|   195k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   195k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  373|   195k|    {
  374|  2.72k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  228|  2.72k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (374:9): [True: 2.72k, False: 192k]
  ------------------
  375|  2.72k|            return pb_enc_bool(stream, field);
  376|       |
  377|  75.7k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  229|  75.7k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (377:9): [True: 75.7k, False: 119k]
  ------------------
  378|   115k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  230|   115k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (378:9): [True: 39.7k, False: 155k]
  ------------------
  379|   131k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  231|   131k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (379:9): [True: 15.8k, False: 179k]
  ------------------
  380|   131k|            return pb_enc_varint(stream, field);
  381|       |
  382|  10.4k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  232|  10.4k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (382:9): [True: 10.4k, False: 185k]
  ------------------
  383|  18.8k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  233|  18.8k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (383:9): [True: 8.43k, False: 187k]
  ------------------
  384|  18.8k|            return pb_enc_fixed(stream, field);
  385|       |
  386|  3.50k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  240|  3.50k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (386:9): [True: 3.50k, False: 192k]
  ------------------
  387|  3.50k|            return pb_enc_bytes(stream, field);
  388|       |
  389|  15.1k|        case PB_LTYPE_STRING:
  ------------------
  |  |  244|  15.1k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (389:9): [True: 15.1k, False: 180k]
  ------------------
  390|  15.1k|            return pb_enc_string(stream, field);
  391|       |
  392|  19.6k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  248|  19.6k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (392:9): [True: 19.6k, False: 175k]
  ------------------
  393|  19.6k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  253|  19.6k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (393:9): [True: 0, False: 195k]
  ------------------
  394|  19.6k|            return pb_enc_submessage(stream, field);
  395|       |
  396|  4.30k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  263|  4.30k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (396:9): [True: 4.30k, False: 191k]
  ------------------
  397|  4.30k|            return pb_enc_fixed_length_bytes(stream, field);
  398|       |
  399|      0|        default:
  ------------------
  |  Branch (399:9): [True: 0, False: 195k]
  ------------------
  400|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  401|   195k|    }
  402|   195k|}
pb_encode.c:pb_enc_bool:
  776|  2.72k|{
  777|  2.72k|    uint32_t value = safe_read_bool(field->pData) ? 1 : 0;
  ------------------
  |  Branch (777:22): [True: 1.79k, False: 926]
  ------------------
  778|  2.72k|    PB_UNUSED(field);
  ------------------
  |  |  143|  2.72k|#define PB_UNUSED(x) (void)(x)
  ------------------
  779|  2.72k|    return pb_encode_varint(stream, value);
  780|  2.72k|}
pb_encode.c:pb_enc_bytes:
  856|  3.50k|{
  857|  3.50k|    const pb_bytes_array_t *bytes = NULL;
  858|       |
  859|  3.50k|    bytes = (const pb_bytes_array_t*)field->pData;
  860|       |    
  861|  3.50k|    if (bytes == NULL)
  ------------------
  |  Branch (861:9): [True: 0, False: 3.50k]
  ------------------
  862|      0|    {
  863|       |        /* Treat null pointer as an empty bytes field */
  864|      0|        return pb_encode_string(stream, NULL, 0);
  865|      0|    }
  866|       |    
  867|  3.50k|    if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  286|  3.50k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|  3.50k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  281|  7.00k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (867:9): [True: 3.50k, False: 0]
  ------------------
  868|  3.50k|        bytes->size > field->data_size - offsetof(pb_bytes_array_t, bytes))
  ------------------
  |  Branch (868:9): [True: 0, False: 3.50k]
  ------------------
  869|      0|    {
  870|      0|        PB_RETURN_ERROR(stream, "bytes size exceeded");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  871|      0|    }
  872|       |    
  873|  3.50k|    return pb_encode_string(stream, bytes->bytes, (size_t)bytes->size);
  874|  3.50k|}
pb_encode.c:pb_enc_string:
  877|  15.1k|{
  878|  15.1k|    size_t size = 0;
  879|  15.1k|    size_t max_size = (size_t)field->data_size;
  880|  15.1k|    const char *str = (const char*)field->pData;
  881|       |    
  882|  15.1k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  286|  15.1k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|  15.1k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  282|  15.1k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (882:9): [True: 0, False: 15.1k]
  ------------------
  883|      0|    {
  884|      0|        max_size = (size_t)-1;
  885|      0|    }
  886|  15.1k|    else
  887|  15.1k|    {
  888|       |        /* pb_dec_string() assumes string fields end with a null
  889|       |         * terminator when the type isn't PB_ATYPE_POINTER, so we
  890|       |         * shouldn't allow more than max-1 bytes to be written to
  891|       |         * allow space for the null terminator.
  892|       |         */
  893|  15.1k|        if (max_size == 0)
  ------------------
  |  Branch (893:13): [True: 0, False: 15.1k]
  ------------------
  894|      0|            PB_RETURN_ERROR(stream, "zero-length string");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  895|       |
  896|  15.1k|        max_size -= 1;
  897|  15.1k|    }
  898|       |
  899|       |
  900|  15.1k|    if (str == NULL)
  ------------------
  |  Branch (900:9): [True: 0, False: 15.1k]
  ------------------
  901|      0|    {
  902|      0|        size = 0; /* Treat null pointer as an empty string */
  903|      0|    }
  904|  15.1k|    else
  905|  15.1k|    {
  906|  15.1k|        const char *p = str;
  907|       |
  908|       |        /* strnlen() is not always available, so just use a loop */
  909|  62.6k|        while (size < max_size && *p != '\0')
  ------------------
  |  Branch (909:16): [True: 62.3k, False: 304]
  |  Branch (909:35): [True: 47.5k, False: 14.8k]
  ------------------
  910|  47.5k|        {
  911|  47.5k|            size++;
  912|  47.5k|            p++;
  913|  47.5k|        }
  914|       |
  915|  15.1k|        if (*p != '\0')
  ------------------
  |  Branch (915:13): [True: 0, False: 15.1k]
  ------------------
  916|      0|        {
  917|      0|            PB_RETURN_ERROR(stream, "unterminated string");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  918|      0|        }
  919|  15.1k|    }
  920|       |
  921|       |#ifdef PB_VALIDATE_UTF8
  922|       |    if (!pb_validate_utf8(str))
  923|       |        PB_RETURN_ERROR(stream, "invalid utf8");
  924|       |#endif
  925|       |
  926|  15.1k|    return pb_encode_string(stream, (const pb_byte_t*)str, size);
  927|  15.1k|}
pb_encode.c:pb_enc_submessage:
  930|  19.6k|{
  931|  19.6k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (931:9): [True: 0, False: 19.6k]
  ------------------
  932|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  933|       |
  934|  19.6k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  288|  19.6k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|  19.6k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  253|  39.2k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (934:9): [True: 0, False: 19.6k]
  |  Branch (934:58): [True: 0, False: 0]
  ------------------
  935|      0|    {
  936|       |        /* Message callback is stored right before pSize. */
  937|      0|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
  938|      0|        if (callback->funcs.encode)
  ------------------
  |  Branch (938:13): [True: 0, False: 0]
  ------------------
  939|      0|        {
  940|      0|            if (!callback->funcs.encode(stream, field, &callback->arg))
  ------------------
  |  Branch (940:17): [True: 0, False: 0]
  ------------------
  941|      0|                return false;
  942|      0|        }
  943|      0|    }
  944|       |    
  945|  19.6k|    return pb_encode_submessage(stream, field->submsg_desc, field->pData);
  946|  19.6k|}
pb_encode.c:pb_enc_fixed_length_bytes:
  949|  4.30k|{
  950|  4.30k|    return pb_encode_string(stream, (const pb_byte_t*)field->pData, (size_t)field->data_size);
  951|  4.30k|}
pb_encode.c:pb_encode_varint_32:
  573|  74.7k|{
  574|  74.7k|    size_t i = 0;
  575|  74.7k|    pb_byte_t buffer[10];
  576|  74.7k|    pb_byte_t byte = (pb_byte_t)(low & 0x7F);
  577|  74.7k|    low >>= 7;
  578|       |
  579|   201k|    while (i < 4 && (low != 0 || high != 0))
  ------------------
  |  Branch (579:12): [True: 189k, False: 11.8k]
  |  Branch (579:22): [True: 126k, False: 63.1k]
  |  Branch (579:34): [True: 288, False: 62.8k]
  ------------------
  580|   126k|    {
  581|   126k|        byte |= 0x80;
  582|   126k|        buffer[i++] = byte;
  583|   126k|        byte = (pb_byte_t)(low & 0x7F);
  584|   126k|        low >>= 7;
  585|   126k|    }
  586|       |
  587|  74.7k|    if (high)
  ------------------
  |  Branch (587:9): [True: 9.52k, False: 65.1k]
  ------------------
  588|  9.52k|    {
  589|  9.52k|        byte = (pb_byte_t)(byte | ((high & 0x07) << 4));
  590|  9.52k|        high >>= 3;
  591|       |
  592|  49.9k|        while (high)
  ------------------
  |  Branch (592:16): [True: 40.4k, False: 9.52k]
  ------------------
  593|  40.4k|        {
  594|  40.4k|            byte |= 0x80;
  595|  40.4k|            buffer[i++] = byte;
  596|  40.4k|            byte = (pb_byte_t)(high & 0x7F);
  597|  40.4k|            high >>= 7;
  598|  40.4k|        }
  599|  9.52k|    }
  600|       |
  601|  74.7k|    buffer[i++] = byte;
  602|       |
  603|  74.7k|    return pb_write(stream, buffer, i);
  604|  74.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.1k|{
  164|  17.1k|    return g_alloc_count;
  165|  17.1k|}
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.43M|{
    6|  5.43M|    flakystream_t *state = stream->state;
    7|       |
    8|  5.43M|    if (state->position + count > state->msglen)
  ------------------
  |  Branch (8:9): [True: 1.29k, False: 5.43M]
  ------------------
    9|  1.29k|    {
   10|  1.29k|        stream->bytes_left = 0;
   11|  1.29k|        return false;
   12|  1.29k|    }
   13|  5.43M|    else if (state->position + count > state->fail_after)
  ------------------
  |  Branch (13:14): [True: 0, False: 5.43M]
  ------------------
   14|      0|    {
   15|      0|        PB_RETURN_ERROR(stream, "flaky error");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   16|      0|    }
   17|       |
   18|  5.43M|    memcpy(buf, state->buffer + state->position, count);
   19|  5.43M|    state->position += count;
   20|  5.43M|    return true;
   21|  5.43M|}
flakystream_init:
   24|  1.29k|{
   25|  1.29k|    memset(stream, 0, sizeof(*stream));
   26|  1.29k|    stream->stream.callback = flakystream_callback;
   27|  1.29k|    stream->stream.bytes_left = SIZE_MAX;
   28|  1.29k|    stream->stream.state = stream;
   29|  1.29k|    stream->buffer = buffer;
   30|  1.29k|    stream->position = 0;
   31|  1.29k|    stream->msglen = msglen;
   32|  1.29k|    stream->fail_after = fail_after;
   33|  1.29k|}

do_callback_decode:
  161|  1.29k|{
  162|  1.29k|    bool status;
  163|  1.29k|    pb_istream_t stream;
  164|  1.29k|    size_t initial_alloc_count = get_alloc_count();
  165|  1.29k|    alltypes_callback_AllTypes *msg = malloc_with_check(sizeof(alltypes_callback_AllTypes));
  166|  1.29k|    assert(msg);
  167|       |
  168|  1.29k|    memset(msg, 0, sizeof(alltypes_callback_AllTypes));
  169|  1.29k|    stream = pb_istream_from_buffer(buffer, msglen);
  170|       |
  171|  1.29k|    msg->rep_int32.funcs.decode = &field_callback;
  172|  1.29k|    msg->rep_int32.arg = &g_sentinel;
  173|  1.29k|    msg->rep_string.funcs.decode = &field_callback;
  174|  1.29k|    msg->rep_string.arg = &g_sentinel;
  175|  1.29k|    msg->rep_farray.funcs.decode = &field_callback;
  176|  1.29k|    msg->rep_farray.arg = &g_sentinel;
  177|  1.29k|    msg->req_limits.int64_min.funcs.decode = &field_callback;
  178|  1.29k|    msg->req_limits.int64_min.arg = &g_sentinel;
  179|  1.29k|    msg->cb_oneof.funcs.decode = &submsg_callback;
  180|  1.29k|    msg->cb_oneof.arg = &g_sentinel;
  181|       |
  182|  1.29k|    status = pb_decode(&stream, alltypes_callback_AllTypes_fields, msg);
  ------------------
  |  |  465|  1.29k|#define alltypes_callback_AllTypes_fields &alltypes_callback_AllTypes_msg
  ------------------
  183|       |
  184|  1.29k|    if (assert_success)
  ------------------
  |  Branch (184:9): [True: 1.29k, False: 0]
  ------------------
  185|  1.29k|    {
  186|  1.29k|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  886|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (886:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (186:13): [True: 0, False: 1.29k]
  ------------------
  187|  1.29k|        assert(status);
  188|  1.29k|    }
  189|       |
  190|  1.29k|    pb_release(alltypes_callback_AllTypes_fields, msg);
  ------------------
  |  |  465|  1.29k|#define alltypes_callback_AllTypes_fields &alltypes_callback_AllTypes_msg
  ------------------
  191|  1.29k|    free_with_check(msg);
  192|  1.29k|    assert(get_alloc_count() == initial_alloc_count);
  193|       |
  194|  1.29k|    return status;
  195|  1.29k|}
do_roundtrip:
  199|  1.29k|{
  200|  1.29k|    bool status;
  201|  1.29k|    uint32_t checksum2, checksum3;
  202|  1.29k|    size_t msglen2, msglen3;
  203|  1.29k|    uint8_t *buf2 = malloc_with_check(g_bufsize);
  204|  1.29k|    void *msg = malloc_with_check(structsize);
  205|       |
  206|       |    /* For proto2 types, we also test extension fields */
  207|  1.29k|    alltypes_static_TestExtension extmsg = alltypes_static_TestExtension_init_zero;
  ------------------
  |  |  248|  1.29k|#define alltypes_static_TestExtension_init_zero  {false, ""}
  ------------------
  208|  1.29k|    pb_extension_t ext = pb_extension_init_zero;
  ------------------
  |  |  472|  1.29k|#define pb_extension_init_zero {NULL,NULL,NULL,false}
  ------------------
  209|  1.29k|    pb_extension_t **ext_field = NULL;
  210|  1.29k|    ext.type = &alltypes_static_TestExtension_testextension;
  211|  1.29k|    ext.dest = &extmsg;
  212|  1.29k|    ext.next = NULL;
  213|       |
  214|  1.29k|    assert(buf2 && msg);
  215|       |
  216|  1.29k|    if (msgtype == alltypes_static_AllTypes_fields)
  ------------------
  |  |  490|  1.29k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (216:9): [True: 1.29k, False: 0]
  ------------------
  217|  1.29k|    {
  218|  1.29k|        ext_field = &((alltypes_static_AllTypes*)msg)->extensions;
  219|  1.29k|    }
  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.29k|    {
  229|  1.29k|        pb_istream_t stream = pb_istream_from_buffer(buffer, msglen);
  230|  1.29k|        memset(msg, 0, structsize);
  231|  1.29k|        if (ext_field) *ext_field = &ext;
  ------------------
  |  Branch (231:13): [True: 1.29k, False: 0]
  ------------------
  232|  1.29k|        status = pb_decode(&stream, msgtype, msg);
  233|  1.29k|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  886|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (886:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (233:13): [True: 0, False: 1.29k]
  ------------------
  234|  1.29k|        assert(status);
  235|       |
  236|  1.29k|        validate_message(msg, structsize, msgtype);
  237|  1.29k|    }
  238|       |    
  239|      0|    {
  240|  1.29k|        pb_ostream_t stream = pb_ostream_from_buffer(buf2, g_bufsize);
  241|  1.29k|        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.29k|        if (!status && strcmp(PB_GET_ERROR(&stream), "stream full") != 0)
  ------------------
  |  |  886|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (886:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (245:13): [True: 0, False: 1.29k]
  |  Branch (245:24): [True: 0, False: 0]
  ------------------
  246|      0|        {
  247|      0|            fprintf(stderr, "pb_encode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  886|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (886:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  248|      0|            assert(status);
  249|      0|        }
  250|       |
  251|  1.29k|        msglen2 = stream.bytes_written;
  252|  1.29k|        checksum2 = xor32_checksum(buf2, msglen2);
  253|  1.29k|    }
  254|       |    
  255|      0|    pb_release(msgtype, msg);
  256|       |
  257|       |    /* Then decode from canonical format and re-encode. Result should remain the same. */
  258|  1.29k|    if (status)
  ------------------
  |  Branch (258:9): [True: 1.29k, False: 0]
  ------------------
  259|  1.29k|    {
  260|  1.29k|        pb_istream_t stream = pb_istream_from_buffer(buf2, msglen2);
  261|  1.29k|        memset(msg, 0, structsize);
  262|  1.29k|        if (ext_field) *ext_field = &ext;
  ------------------
  |  Branch (262:13): [True: 1.29k, False: 0]
  ------------------
  263|  1.29k|        status = pb_decode(&stream, msgtype, msg);
  264|  1.29k|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  886|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (886:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (264:13): [True: 0, False: 1.29k]
  ------------------
  265|  1.29k|        assert(status);
  266|       |
  267|  1.29k|        validate_message(msg, structsize, msgtype);
  268|  1.29k|    }
  269|       |    
  270|  1.29k|    if (status)
  ------------------
  |  Branch (270:9): [True: 1.29k, False: 0]
  ------------------
  271|  1.29k|    {
  272|  1.29k|        pb_ostream_t stream = pb_ostream_from_buffer(buf2, g_bufsize);
  273|  1.29k|        status = pb_encode(&stream, msgtype, msg);
  274|  1.29k|        if (!status) fprintf(stderr, "pb_encode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  886|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (886:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (274:13): [True: 0, False: 1.29k]
  ------------------
  275|  1.29k|        assert(status);
  276|  1.29k|        msglen3 = stream.bytes_written;
  277|  1.29k|        checksum3 = xor32_checksum(buf2, msglen3);
  278|       |
  279|  1.29k|        assert(msglen2 == msglen3);
  280|  1.29k|        assert(checksum2 == checksum3);
  281|  1.29k|    }
  282|       |    
  283|  1.29k|    pb_release(msgtype, msg);
  284|  1.29k|    free_with_check(msg);
  285|  1.29k|    free_with_check(buf2);
  286|  1.29k|}
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.29k, False: 1.68k]
  ------------------
  296|  1.29k|    {
  297|  1.29k|        do_roundtrip(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields);
  ------------------
  |  |  490|  1.29k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  298|  1.29k|        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, true);
  ------------------
  |  |  490|  1.29k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  299|  1.29k|        do_callback_decode(data, size, true);
  300|  1.29k|    }
  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.98k|{
  354|  2.98k|    if (size > g_bufsize)
  ------------------
  |  Branch (354:9): [True: 3, False: 2.98k]
  ------------------
  355|      3|        return 0;
  356|       |
  357|  2.98k|    do_roundtrips(data, size, false);
  358|       |
  359|  2.98k|    return 0;
  360|  2.98k|}
fuzztest.c:field_callback:
  145|  5.14k|{
  146|  5.14k|    assert(stream);
  147|  5.14k|    assert(field);
  148|  5.14k|    assert(*arg == &g_sentinel);
  149|  5.14k|    return pb_read(stream, NULL, stream->bytes_left);
  150|  5.14k|}
fuzztest.c:submsg_callback:
  153|  52.5k|{
  154|  52.5k|    assert(stream);
  155|  52.5k|    assert(field);
  156|  52.5k|    assert(*arg == &g_sentinel);
  157|  52.5k|    return true;
  158|  52.5k|}
fuzztest.c:xor32_checksum:
   52|  2.59k|{
   53|  2.59k|    const uint8_t *buf = (const uint8_t*)data;
   54|  2.59k|    uint32_t checksum = 1234;
   55|   623k|    for (; len > 0; len--)
  ------------------
  |  Branch (55:12): [True: 620k, False: 2.59k]
  ------------------
   56|   620k|    {
   57|   620k|        checksum ^= checksum << 13;
   58|   620k|        checksum ^= checksum >> 17;
   59|   620k|        checksum ^= checksum << 5;
   60|   620k|        checksum += *buf++;
   61|   620k|    }
   62|  2.59k|    return checksum;
   63|  2.59k|}
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;
  ------------------
  |  |  472|  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.29k, False: 1.68k]
  ------------------
   94|  1.29k|    {
   95|  1.29k|        validate_message(msg, structsize, msgtype);
   96|  1.29k|    }
   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));
  ------------------
  |  |  886|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (886: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.29k|{
  114|  1.29k|    bool status;
  115|  1.29k|    flakystream_t stream;
  116|  1.29k|    size_t initial_alloc_count = get_alloc_count();
  117|  1.29k|    void *msg = malloc_with_check(structsize);
  118|  1.29k|    assert(msg);
  119|       |
  120|  1.29k|    memset(msg, 0, structsize);
  121|  1.29k|    flakystream_init(&stream, buffer, msglen, fail_after);
  122|  1.29k|    status = pb_decode(&stream.stream, msgtype, msg);
  123|       |
  124|  1.29k|    if (status)
  ------------------
  |  Branch (124:9): [True: 1.29k, False: 0]
  ------------------
  125|  1.29k|    {
  126|  1.29k|        validate_message(msg, structsize, msgtype);
  127|  1.29k|    }
  128|       |
  129|  1.29k|    if (assert_success)
  ------------------
  |  Branch (129:9): [True: 1.29k, False: 0]
  ------------------
  130|  1.29k|    {
  131|  1.29k|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream.stream));
  ------------------
  |  |  886|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (886:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (131:13): [True: 0, False: 1.29k]
  ------------------
  132|  1.29k|        assert(status);
  133|  1.29k|    }
  134|       |
  135|  1.29k|    pb_release(msgtype, msg);
  136|  1.29k|    free_with_check(msg);
  137|  1.29k|    assert(get_alloc_count() == initial_alloc_count);
  138|       |
  139|  1.29k|    return status;
  140|  1.29k|}

validate_static:
    7|   492k|{
    8|   492k|    pb_size_t count = 1;
    9|   492k|    pb_size_t i;
   10|   492k|    bool truebool = true;
   11|   492k|    bool falsebool = false;
   12|       |
   13|   492k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  287|   492k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|   492k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  274|   984k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 109k, False: 383k]
  |  Branch (13:54): [True: 109k, False: 0]
  ------------------
   14|   109k|    {
   15|       |        /* Array count must be between 0 and statically allocated size */
   16|   109k|        count = *(pb_size_t*)iter->pSize;
   17|   109k|        assert(count <= iter->array_size);
   18|   109k|    }
   19|   383k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  287|   383k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|   383k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  272|   766k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 119k, False: 264k]
  |  Branch (19:59): [True: 119k, False: 0]
  ------------------
   20|   119k|    {
   21|       |        /* Boolean has_ field must have a valid value */
   22|   119k|        assert(memcmp(iter->pSize, &truebool, sizeof(bool)) == 0 ||
   23|   119k|               memcmp(iter->pSize, &falsebool, sizeof(bool)) == 0);
   24|   119k|    }
   25|   264k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|   264k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|   264k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  276|   264k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 15.5k, False: 248k]
  ------------------
   26|  15.5k|    {
   27|  15.5k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 14.0k, False: 1.54k]
  ------------------
   28|  14.0k|        {
   29|       |            /* Some different field in oneof */
   30|  14.0k|            return;
   31|  14.0k|        }
   32|  15.5k|    }
   33|       |
   34|   929k|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 450k, False: 478k]
  ------------------
   35|   450k|    {
   36|   450k|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|   450k|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  288|   450k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   450k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  244|   450k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 27.9k, False: 422k]
  ------------------
   39|  27.9k|        {
   40|       |            /* String length must be at most statically allocated size */
   41|  27.9k|            assert(strlen(pData) + 1 <= iter->data_size);
   42|  27.9k|        }
   43|   422k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  288|   422k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   422k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  240|   422k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 11.6k, False: 411k]
  ------------------
   44|  11.6k|        {
   45|       |            /* Bytes length must be at most statically allocated size */
   46|  11.6k|            pb_bytes_array_t *bytes = pData;
   47|  11.6k|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= iter->data_size);
   48|  11.6k|        }
   49|   411k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  288|   411k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   411k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  228|   411k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 12.2k, False: 399k]
  ------------------
   50|  12.2k|        {
   51|       |            /* Bool fields must have valid value */
   52|  12.2k|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
   53|  12.2k|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
   54|  12.2k|        }
   55|   399k|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  289|   399k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|   399k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|   399k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  248|   798k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (289:32): [True: 43.4k, False: 355k]
  |  |  ------------------
  |  |  290|   399k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  288|   355k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|   355k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  253|   355k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (290:32): [True: 0, False: 355k]
  |  |  ------------------
  ------------------
   56|  43.4k|        {
   57|  43.4k|            validate_message(pData, 0, iter->submsg_desc);
   58|  43.4k|        }
   59|   450k|    }
   60|   478k|}
validate_message:
  145|  48.6k|{
  146|  48.6k|    pb_field_iter_t iter;
  147|       |
  148|  48.6k|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 36.0k, False: 12.6k]
  ------------------
  149|  36.0k|    {
  150|  36.0k|        do
  151|   497k|        {
  152|   497k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  286|   497k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|   497k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  281|   497k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 492k, False: 5.19k]
  ------------------
  153|   492k|            {
  154|   492k|                validate_static(&iter);
  155|   492k|            }
  156|  5.19k|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  286|  5.19k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|  5.19k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  282|  5.19k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 0, False: 5.19k]
  ------------------
  157|      0|            {
  158|      0|                validate_pointer(&iter);
  159|      0|            }
  160|   497k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 461k, False: 36.0k]
  ------------------
  161|  36.0k|    }
  162|  48.6k|}

