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

pb_read:
   82|  2.54M|{
   83|  2.54M|    if (count == 0)
  ------------------
  |  Branch (83:9): [True: 832k, False: 1.71M]
  ------------------
   84|   832k|        return true;
   85|       |
   86|  1.71M|#ifndef PB_BUFFER_ONLY
   87|  1.71M|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (87:6): [True: 93.2k, False: 1.62M]
  |  Branch (87:21): [True: 30.6k, False: 62.6k]
  ------------------
   88|  30.6k|	{
   89|       |		/* Skip input bytes */
   90|  30.6k|		pb_byte_t tmp[16];
   91|   204k|		while (count > 16)
  ------------------
  |  Branch (91:10): [True: 174k, False: 30.6k]
  ------------------
   92|   174k|		{
   93|   174k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (93:8): [True: 0, False: 174k]
  ------------------
   94|      0|				return false;
   95|       |			
   96|   174k|			count -= 16;
   97|   174k|		}
   98|       |		
   99|  30.6k|		return pb_read(stream, tmp, count);
  100|  30.6k|	}
  101|  1.68M|#endif
  102|       |
  103|  1.68M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (103:9): [True: 269, False: 1.68M]
  ------------------
  104|    269|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  930|    269|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    269|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 269]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  105|       |    
  106|  1.68M|#ifndef PB_BUFFER_ONLY
  107|  1.68M|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:9): [True: 0, False: 1.68M]
  ------------------
  108|      0|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|       |#else
  110|       |    if (!buf_read(stream, buf, count))
  111|       |        return false;
  112|       |#endif
  113|       |    
  114|  1.68M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (114:9): [True: 0, False: 1.68M]
  ------------------
  115|      0|        stream->bytes_left = 0;
  116|  1.68M|    else
  117|  1.68M|        stream->bytes_left -= count;
  118|       |
  119|       |    return true;
  120|  1.68M|}
pb_istream_from_buffer:
  143|  11.5k|{
  144|  11.5k|    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|  11.5k|    union {
  149|  11.5k|        void *state;
  150|  11.5k|        const void *c_state;
  151|  11.5k|    } state;
  152|       |#ifdef PB_BUFFER_ONLY
  153|       |    stream.callback = NULL;
  154|       |#else
  155|  11.5k|    stream.callback = &buf_read;
  156|  11.5k|#endif
  157|  11.5k|    state.c_state = buf;
  158|  11.5k|    stream.state = state.state;
  159|  11.5k|    stream.bytes_left = msglen;
  160|  11.5k|#ifndef PB_NO_ERRMSG
  161|  11.5k|    stream.errmsg = NULL;
  162|  11.5k|#endif
  163|       |#ifdef PB_MESSAGE_NESTING_MAX
  164|       |    stream.depth = 0;
  165|       |#endif
  166|  11.5k|    return stream;
  167|  11.5k|}
pb_decode_varint32:
  175|  66.2M|{
  176|  66.2M|    pb_byte_t byte;
  177|  66.2M|    uint32_t result;
  178|       |    
  179|  66.2M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (179:9): [True: 1.90k, False: 66.2M]
  ------------------
  180|  1.90k|    {
  181|  1.90k|        return false;
  182|  1.90k|    }
  183|       |    
  184|  66.2M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (184:9): [True: 35.3M, False: 30.9M]
  ------------------
  185|  35.3M|    {
  186|       |        /* Quick case, 1 byte value */
  187|  35.3M|        result = byte;
  188|  35.3M|    }
  189|  30.9M|    else
  190|  30.9M|    {
  191|       |        /* Multibyte case */
  192|  30.9M|        uint_fast8_t bitpos = 7;
  193|  30.9M|        result = byte & 0x7F;
  194|       |        
  195|  30.9M|        do
  196|  31.0M|        {
  197|  31.0M|            if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (197:17): [True: 61, False: 31.0M]
  ------------------
  198|     61|                return false;
  199|       |            
  200|  31.0M|            if (bitpos >= 32)
  ------------------
  |  Branch (200:17): [True: 7.81k, False: 31.0M]
  ------------------
  201|  7.81k|            {
  202|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  203|  7.81k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (203:44): [True: 7.67k, False: 134]
  ------------------
  204|  7.81k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (204:41): [True: 4.26k, False: 3.54k]
  ------------------
  205|  3.54k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (205:27): [True: 3.52k, False: 16]
  |  Branch (205:50): [True: 3.47k, False: 56]
  ------------------
  206|       |
  207|  7.81k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (207:21): [True: 2, False: 7.80k]
  |  Branch (207:37): [True: 71, False: 7.73k]
  ------------------
  208|     73|                {
  209|     73|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  930|     73|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     73|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 73]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  210|     73|                }
  211|  7.81k|            }
  212|  31.0M|            else if (bitpos == 28)
  ------------------
  |  Branch (212:22): [True: 12.1k, False: 31.0M]
  ------------------
  213|  12.1k|            {
  214|  12.1k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (214:21): [True: 7.94k, False: 4.23k]
  |  Branch (214:43): [True: 39, False: 7.90k]
  ------------------
  215|     39|                {
  216|     39|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  930|     39|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     39|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 39]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|     39|                }
  218|  12.1k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  219|  12.1k|            }
  220|  31.0M|            else
  221|  31.0M|            {
  222|  31.0M|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  223|  31.0M|            }
  224|  31.0M|            bitpos = (uint_fast8_t)(bitpos + 7);
  225|  31.0M|        } while (byte & 0x80);
  ------------------
  |  Branch (225:18): [True: 120k, False: 30.9M]
  ------------------
  226|  30.9M|   }
  227|       |   
  228|  66.2M|   *dest = result;
  229|       |   return true;
  230|  66.2M|}
pb_decode_varint:
  234|  9.86M|{
  235|  9.86M|    pb_byte_t byte;
  236|  9.86M|    uint_fast8_t bitpos = 0;
  237|  9.86M|    uint64_t result = 0;
  238|       |    
  239|  9.86M|    do
  240|  17.5M|    {
  241|  17.5M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (241:13): [True: 97, False: 17.5M]
  ------------------
  242|     97|            return false;
  243|       |
  244|  17.5M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (244:13): [True: 95.1k, False: 17.4M]
  |  Branch (244:29): [True: 40, False: 95.1k]
  ------------------
  245|     40|            PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  930|     40|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     40|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 40]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|       |
  247|  17.5M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  248|  17.5M|        bitpos = (uint_fast8_t)(bitpos + 7);
  249|  17.5M|    } while (byte & 0x80);
  ------------------
  |  Branch (249:14): [True: 7.72M, False: 9.86M]
  ------------------
  250|       |    
  251|  9.86M|    *dest = result;
  252|       |    return true;
  253|  9.86M|}
pb_decode_tag:
  282|  32.5M|{
  283|  32.5M|    uint32_t temp;
  284|  32.5M|    *eof = false;
  285|  32.5M|    *wire_type = (pb_wire_type_t) 0;
  286|  32.5M|    *tag = 0;
  287|       |
  288|  32.5M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (288:9): [True: 177k, False: 32.3M]
  ------------------
  289|   177k|    {
  290|   177k|        *eof = true;
  291|   177k|        return false;
  292|   177k|    }
  293|       |
  294|  32.3M|    if (!pb_decode_varint32(stream, &temp))
  ------------------
  |  Branch (294:9): [True: 1.77k, False: 32.3M]
  ------------------
  295|  1.77k|    {
  296|  1.77k|#ifndef PB_BUFFER_ONLY
  297|       |        /* Workaround for issue #1017
  298|       |         *
  299|       |         * Callback streams don't set bytes_left to 0 on eof until after being called by pb_decode_varint32,
  300|       |         * which results in "io error" being raised. This contrasts the behavior of buffer streams who raise
  301|       |         * no error on eof as bytes_left is already 0 on entry. This causes legitimate errors (e.g. missing
  302|       |         * required fields) to be incorrectly reported by callback streams.
  303|       |         */
  304|  1.77k|        if (stream->callback != buf_read && stream->bytes_left == 0)
  ------------------
  |  Branch (304:13): [True: 1.66k, False: 106]
  |  Branch (304:45): [True: 1.66k, False: 0]
  ------------------
  305|  1.66k|        {
  306|  1.66k|#ifndef PB_NO_ERRMSG
  307|  1.66k|            if (strcmp(stream->errmsg, "io error") == 0)
  ------------------
  |  Branch (307:17): [True: 1.66k, False: 0]
  ------------------
  308|  1.66k|                stream->errmsg = NULL;
  309|  1.66k|#endif
  310|  1.66k|            *eof = true;
  311|  1.66k|        }
  312|  1.77k|#endif
  313|  1.77k|        return false;
  314|  1.77k|    }
  315|       |    
  316|  32.3M|    *tag = temp >> 3;
  317|  32.3M|    *wire_type = (pb_wire_type_t)(temp & 7);
  318|       |    return true;
  319|  32.3M|}
pb_skip_field:
  322|   308k|{
  323|   308k|    switch (wire_type)
  324|   308k|    {
  325|   130k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (325:9): [True: 130k, False: 177k]
  ------------------
  326|  10.2k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (326:9): [True: 10.2k, False: 298k]
  ------------------
  327|   125k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (327:9): [True: 125k, False: 182k]
  ------------------
  328|  41.1k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (328:9): [True: 41.1k, False: 267k]
  ------------------
  329|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (329:2): [True: 0, False: 308k]
  ------------------
  330|       |            /* Calling pb_skip_field with a PB_WT_PACKED is an error.
  331|       |             * Explicitly handle this case and fallthrough to default to avoid
  332|       |             * compiler warnings.
  333|       |             */
  334|    106|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  930|    106|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    106|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 106]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (334:9): [True: 106, False: 308k]
  ------------------
  335|   308k|    }
  336|   308k|}
pb_make_string_substream:
  387|   262k|{
  388|   262k|    uint32_t size;
  389|   262k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (389:9): [True: 122, False: 262k]
  ------------------
  390|    122|        return false;
  391|       |    
  392|   262k|    *substream = *stream;
  393|   262k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (393:9): [True: 119, False: 262k]
  ------------------
  394|    119|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  930|    119|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    119|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 119]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  395|       |    
  396|       |#ifdef PB_MESSAGE_NESTING_MAX
  397|       |    substream->depth++;
  398|       |    if (substream->depth > PB_MESSAGE_NESTING_MAX)
  399|       |        PB_RETURN_ERROR(stream, "max depth");
  400|       |#endif
  401|       |
  402|   262k|    substream->bytes_left = (size_t)size;
  403|   262k|    stream->bytes_left -= (size_t)size;
  404|       |    return true;
  405|   262k|}
pb_close_string_substream:
  408|   262k|{
  409|   262k|    if (substream->bytes_left) {
  ------------------
  |  Branch (409:9): [True: 657, False: 261k]
  ------------------
  410|    657|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (410:13): [True: 0, False: 657]
  ------------------
  411|      0|            return false;
  412|    657|    }
  413|       |
  414|   262k|    stream->state = substream->state;
  415|       |
  416|   262k|#ifndef PB_NO_ERRMSG
  417|   262k|    stream->errmsg = substream->errmsg;
  418|   262k|#endif
  419|       |    return true;
  420|   262k|}
pb_decode_ex:
 1220|  8.74k|{
 1221|  8.74k|    bool status;
 1222|       |
 1223|  8.74k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  123|  8.74k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1223:9): [True: 8.74k, False: 0]
  ------------------
 1224|  8.74k|    {
 1225|  8.74k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1226|  8.74k|    }
 1227|      0|    else
 1228|      0|    {
 1229|      0|      pb_istream_t substream;
 1230|      0|      if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1230:11): [True: 0, False: 0]
  ------------------
 1231|      0|        return false;
 1232|       |
 1233|      0|      status = pb_decode_inner(&substream, fields, dest_struct, flags);
 1234|       |
 1235|      0|      if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1235:11): [True: 0, False: 0]
  ------------------
 1236|      0|        status = false;
 1237|      0|    }
 1238|       |    
 1239|  8.74k|#ifdef PB_ENABLE_MALLOC
 1240|  8.74k|    if (!status)
  ------------------
  |  Branch (1240:9): [True: 2.31k, False: 6.42k]
  ------------------
 1241|  2.31k|        pb_release(fields, dest_struct);
 1242|  8.74k|#endif
 1243|       |    
 1244|  8.74k|    return status;
 1245|  8.74k|}
pb_decode:
 1248|  3.09k|{
 1249|  3.09k|    return pb_decode_ex(stream, fields, dest_struct, 0);
 1250|  3.09k|}
pb_release:
 1377|   182k|{
 1378|   182k|    pb_field_iter_t iter;
 1379|       |    
 1380|   182k|    if (!dest_struct)
  ------------------
  |  Branch (1380:9): [True: 0, False: 182k]
  ------------------
 1381|      0|        return; /* Ignore NULL pointers, similar to free() */
 1382|       |
 1383|   182k|    if (!pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1383:9): [True: 59.1k, False: 123k]
  ------------------
 1384|  59.1k|        return; /* Empty message type */
 1385|       |    
 1386|   123k|    do
 1387|  1.07M|    {
 1388|  1.07M|        pb_release_single_field(&iter);
 1389|  1.07M|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (1389:14): [True: 955k, False: 123k]
  ------------------
 1390|   123k|}
pb_decode_bool:
 1403|  3.15M|{
 1404|  3.15M|    uint32_t value;
 1405|  3.15M|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1405:9): [True: 76, False: 3.15M]
  ------------------
 1406|     76|        return false;
 1407|       |
 1408|  3.15M|    *(bool*)dest = (value != 0);
 1409|       |    return true;
 1410|  3.15M|}
pb_decode_svarint:
 1413|  3.69M|{
 1414|  3.69M|    pb_uint64_t value;
  ------------------
  |  |   57|  3.69M|#define pb_uint64_t uint64_t
  ------------------
 1415|  3.69M|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1415:9): [True: 37, False: 3.69M]
  ------------------
 1416|     37|        return false;
 1417|       |    
 1418|  3.69M|    if (value & 1)
  ------------------
  |  Branch (1418:9): [True: 530k, False: 3.16M]
  ------------------
 1419|   530k|        *dest = (pb_int64_t)(~(value >> 1));
 1420|  3.16M|    else
 1421|  3.16M|        *dest = (pb_int64_t)(value >> 1);
 1422|       |    
 1423|       |    return true;
 1424|  3.69M|}
pb_decode_fixed32:
 1427|  81.4k|{
 1428|  81.4k|    union {
 1429|  81.4k|        uint32_t fixed32;
 1430|  81.4k|        pb_byte_t bytes[4];
 1431|  81.4k|    } u;
 1432|       |
 1433|  81.4k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1433:9): [True: 21, False: 81.4k]
  ------------------
 1434|     21|        return false;
 1435|       |
 1436|  81.4k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1437|       |    /* fast path - if we know that we're on little endian, assign directly */
 1438|  81.4k|    *(uint32_t*)dest = u.fixed32;
 1439|       |#else
 1440|       |    *(uint32_t*)dest = ((uint32_t)u.bytes[0] << 0) |
 1441|       |                       ((uint32_t)u.bytes[1] << 8) |
 1442|       |                       ((uint32_t)u.bytes[2] << 16) |
 1443|       |                       ((uint32_t)u.bytes[3] << 24);
 1444|       |#endif
 1445|       |    return true;
 1446|  81.4k|}
pb_decode_fixed64:
 1450|  60.9k|{
 1451|  60.9k|    union {
 1452|  60.9k|        uint64_t fixed64;
 1453|  60.9k|        pb_byte_t bytes[8];
 1454|  60.9k|    } u;
 1455|       |
 1456|  60.9k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1456:9): [True: 19, False: 60.9k]
  ------------------
 1457|     19|        return false;
 1458|       |
 1459|  60.9k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1460|       |    /* fast path - if we know that we're on little endian, assign directly */
 1461|  60.9k|    *(uint64_t*)dest = u.fixed64;
 1462|       |#else
 1463|       |    *(uint64_t*)dest = ((uint64_t)u.bytes[0] << 0) |
 1464|       |                       ((uint64_t)u.bytes[1] << 8) |
 1465|       |                       ((uint64_t)u.bytes[2] << 16) |
 1466|       |                       ((uint64_t)u.bytes[3] << 24) |
 1467|       |                       ((uint64_t)u.bytes[4] << 32) |
 1468|       |                       ((uint64_t)u.bytes[5] << 40) |
 1469|       |                       ((uint64_t)u.bytes[6] << 48) |
 1470|       |                       ((uint64_t)u.bytes[7] << 56);
 1471|       |#endif
 1472|       |    return true;
 1473|  60.9k|}
pb_decode.c:buf_read:
   69|  81.4M|{
   70|  81.4M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   71|  81.4M|    stream->state = (pb_byte_t*)stream->state + count;
   72|       |    
   73|  81.4M|    if (buf != NULL)
  ------------------
  |  Branch (73:9): [True: 81.4M, False: 62.5k]
  ------------------
   74|  81.4M|    {
   75|  81.4M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   76|  81.4M|    }
   77|       |    
   78|       |    return true;
   79|  81.4M|}
pb_decode.c:pb_readbyte:
  125|   114M|{
  126|   114M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (126:9): [True: 395, False: 114M]
  ------------------
  127|    395|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  930|    395|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    395|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 395]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|       |
  129|   114M|#ifndef PB_BUFFER_ONLY
  130|   114M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (130:9): [True: 1.66k, False: 114M]
  ------------------
  131|  1.66k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  930|  1.66k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|  1.66k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 1.66k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|       |#else
  133|       |    *buf = *(const pb_byte_t*)stream->state;
  134|       |    stream->state = (pb_byte_t*)stream->state + 1;
  135|       |#endif
  136|       |
  137|   114M|    stream->bytes_left--;
  138|       |    
  139|       |    return true;    
  140|   114M|}
pb_decode.c:pb_skip_varint:
  257|   130k|{
  258|   130k|    pb_byte_t byte;
  259|   130k|    do
  260|   150k|    {
  261|   150k|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (261:13): [True: 71, False: 150k]
  ------------------
  262|     71|            return false;
  263|   150k|    } while (byte & 0x80);
  ------------------
  |  Branch (263:14): [True: 19.1k, False: 130k]
  ------------------
  264|   130k|    return true;
  265|   130k|}
pb_decode.c:pb_skip_string:
  268|   125k|{
  269|   125k|    uint32_t length;
  270|   125k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (270:9): [True: 52, False: 125k]
  ------------------
  271|     52|        return false;
  272|       |    
  273|   125k|    if ((size_t)length != length)
  ------------------
  |  Branch (273:9): [True: 0, False: 125k]
  ------------------
  274|      0|    {
  275|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  276|      0|    }
  277|       |
  278|   125k|    return pb_read(stream, NULL, (size_t)length);
  279|   125k|}
pb_decode.c:pb_decode_inner:
 1049|   181k|{
 1050|       |    /* If the message contains extension fields, the extension handlers
 1051|       |     * are called when tag number is >= extension_range_start. This precheck
 1052|       |     * is just for speed, and the handlers will check for precise match.
 1053|       |     */
 1054|   181k|    uint32_t extension_range_start = 0;
 1055|   181k|    pb_extension_t *extensions = NULL;
 1056|       |
 1057|       |    /* 'fixed_count_field' and 'fixed_count_size' track position of a repeated fixed
 1058|       |     * count field. This can only handle _one_ repeated fixed count field that
 1059|       |     * is unpacked and unordered among other (non repeated fixed count) fields.
 1060|       |     */
 1061|   181k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  342|   181k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
 1062|   181k|    pb_size_t fixed_count_size = 0;
 1063|   181k|    pb_size_t fixed_count_total_size = 0;
 1064|       |
 1065|       |    /* Tag and wire type of next field from the input stream */
 1066|   181k|    uint32_t tag;
 1067|   181k|    pb_wire_type_t wire_type;
 1068|   181k|    bool eof;
 1069|       |
 1070|       |    /* Track presence of required fields */
 1071|   181k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1072|   181k|    const uint32_t allbits = ~(uint32_t)0;
 1073|       |
 1074|       |    /* Descriptor for the structure field matching the tag decoded from stream */
 1075|   181k|    pb_field_iter_t iter;
 1076|       |
 1077|   181k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1077:9): [True: 122k, False: 59.0k]
  ------------------
 1078|   122k|    {
 1079|   122k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |  122|   122k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1079:13): [True: 113k, False: 9.16k]
  ------------------
 1080|   113k|        {
 1081|   113k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1081:17): [True: 0, False: 113k]
  ------------------
 1082|      0|                PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1083|   113k|        }
 1084|   122k|    }
 1085|       |
 1086|  32.5M|    while (pb_decode_tag(stream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1086:12): [True: 32.3M, False: 179k]
  ------------------
 1087|  32.3M|    {
 1088|  32.3M|        if (tag == 0)
  ------------------
  |  Branch (1088:13): [True: 71, False: 32.3M]
  ------------------
 1089|     71|        {
 1090|     71|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  124|     71|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1090:15): [True: 0, False: 71]
  ------------------
 1091|      0|          {
 1092|      0|            eof = true;
 1093|      0|            break;
 1094|      0|          }
 1095|     71|          else
 1096|     71|          {
 1097|     71|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  930|     71|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     71|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 71]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1098|     71|          }
 1099|     71|        }
 1100|       |
 1101|  32.3M|        if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  32.0M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  32.0M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  32.0M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1101:13): [True: 311k, False: 32.0M]
  |  Branch (1101:48): [True: 958, False: 32.0M]
  ------------------
 1102|   312k|        {
 1103|       |            /* No match found, check if it matches an extension. */
 1104|   312k|            if (extension_range_start == 0)
  ------------------
  |  Branch (1104:17): [True: 10.7k, False: 301k]
  ------------------
 1105|  10.7k|            {
 1106|  10.7k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1106:21): [True: 4.17k, False: 6.58k]
  ------------------
 1107|  4.17k|                {
 1108|  4.17k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1109|  4.17k|                    extension_range_start = iter.tag;
 1110|  4.17k|                }
 1111|       |
 1112|  10.7k|                if (!extensions)
  ------------------
  |  Branch (1112:21): [True: 7.31k, False: 3.44k]
  ------------------
 1113|  7.31k|                {
 1114|  7.31k|                    extension_range_start = (uint32_t)-1;
 1115|  7.31k|                }
 1116|  10.7k|            }
 1117|       |
 1118|   312k|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1118:17): [True: 75.3k, False: 236k]
  ------------------
 1119|  75.3k|            {
 1120|  75.3k|                size_t pos = stream->bytes_left;
 1121|       |
 1122|  75.3k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1122:21): [True: 110, False: 75.2k]
  ------------------
 1123|    110|                    return false;
 1124|       |
 1125|  75.2k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1125:21): [True: 3.58k, False: 71.6k]
  ------------------
 1126|  3.58k|                {
 1127|       |                    /* The field was handled */
 1128|  3.58k|                    continue;
 1129|  3.58k|                }
 1130|  75.2k|            }
 1131|       |
 1132|       |            /* No match found, skip data */
 1133|   308k|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1133:17): [True: 336, False: 308k]
  ------------------
 1134|    336|                return false;
 1135|   308k|            continue;
 1136|   308k|        }
 1137|       |
 1138|       |        /* If a repeated fixed count field was found, get size from
 1139|       |         * 'fixed_count_field' as there is no counter contained in the struct.
 1140|       |         */
 1141|  32.0M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  327|  32.0M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  32.0M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  314|  64.0M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1141:13): [True: 30.4M, False: 1.57M]
  |  Branch (1141:57): [True: 1.27k, False: 30.4M]
  ------------------
 1142|  1.27k|        {
 1143|  1.27k|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1143:17): [True: 1.00k, False: 273]
  ------------------
 1144|       |                /* If the new fixed count field does not match the previous one,
 1145|       |                 * check that the previous one is NULL or that it finished
 1146|       |                 * receiving all the expected data.
 1147|       |                 */
 1148|  1.00k|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  342|  2.00k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1148:21): [True: 486, False: 518]
  ------------------
 1149|    486|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1149:21): [True: 3, False: 483]
  ------------------
 1150|      3|                {
 1151|      3|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  930|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1152|      3|                }
 1153|       |
 1154|  1.00k|                fixed_count_field = iter.index;
 1155|  1.00k|                fixed_count_size = 0;
 1156|  1.00k|                fixed_count_total_size = iter.array_size;
 1157|  1.00k|            }
 1158|       |
 1159|  1.27k|            iter.pSize = &fixed_count_size;
 1160|  1.27k|        }
 1161|       |
 1162|  32.0M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  327|  32.0M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  32.0M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  311|  64.0M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1162:13): [True: 1.53M, False: 30.4M]
  ------------------
 1163|  1.53M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  233|  1.53M|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1163:16): [True: 1.53M, False: 0]
  ------------------
 1164|  1.53M|        {
 1165|  1.53M|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1166|  1.53M|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1167|  1.53M|        }
 1168|       |
 1169|  32.0M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1169:13): [True: 1.50k, False: 32.0M]
  ------------------
 1170|  1.50k|            return false;
 1171|  32.0M|    }
 1172|       |
 1173|   179k|    if (!eof)
  ------------------
  |  Branch (1173:9): [True: 106, False: 179k]
  ------------------
 1174|    106|    {
 1175|       |        /* pb_decode_tag() returned error before end of stream */
 1176|    106|        return false;
 1177|    106|    }
 1178|       |
 1179|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1180|   179k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  342|   358k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1180:9): [True: 454, False: 178k]
  ------------------
 1181|    454|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1181:9): [True: 46, False: 408]
  ------------------
 1182|     46|    {
 1183|     46|        PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  930|     46|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     46|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1184|     46|    }
 1185|       |
 1186|       |    /* Check that all required fields were present. */
 1187|   179k|    {
 1188|   179k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1189|       |
 1190|   179k|        if (req_field_count > 0)
  ------------------
  |  Branch (1190:13): [True: 114k, False: 64.3k]
  ------------------
 1191|   114k|        {
 1192|   114k|            pb_size_t i;
 1193|       |
 1194|   114k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  233|   114k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1194:17): [True: 0, False: 114k]
  ------------------
 1195|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  233|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1196|       |
 1197|       |            /* Check the whole words */
 1198|   114k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1198:25): [True: 0, False: 114k]
  ------------------
 1199|      0|            {
 1200|      0|                if (fields_seen.bitfield[i] != allbits)
  ------------------
  |  Branch (1200:21): [True: 0, False: 0]
  ------------------
 1201|      0|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1202|      0|            }
 1203|       |
 1204|       |            /* Check the remaining bits (if any) */
 1205|   114k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1205:17): [True: 114k, False: 0]
  ------------------
 1206|   114k|            {
 1207|   114k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1207:21): [True: 481, False: 114k]
  ------------------
 1208|   114k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1209|    481|                {
 1210|    481|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  930|    481|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    481|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 481]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1211|    481|                }
 1212|   114k|            }
 1213|   114k|        }
 1214|   179k|    }
 1215|       |
 1216|   178k|    return true;
 1217|   179k|}
pb_decode.c:pb_message_set_to_defaults:
 1010|   120k|{
 1011|   120k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   71|   120k|#  define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
 1012|   120k|    uint32_t tag = 0;
 1013|   120k|    pb_wire_type_t wire_type = PB_WT_VARINT;
 1014|   120k|    bool eof;
 1015|       |
 1016|   120k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (1016:9): [True: 0, False: 120k]
  ------------------
 1017|      0|    {
 1018|      0|        defstream = pb_istream_from_buffer(iter->descriptor->default_value, (size_t)-1);
 1019|      0|        if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1019:13): [True: 0, False: 0]
  ------------------
 1020|      0|            return false;
 1021|      0|    }
 1022|       |
 1023|   120k|    do
 1024|  1.05M|    {
 1025|  1.05M|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (1025:13): [True: 0, False: 1.05M]
  ------------------
 1026|      0|            return false;
 1027|       |
 1028|  1.05M|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (1028:13): [True: 0, False: 1.05M]
  |  Branch (1028:25): [True: 0, False: 0]
  ------------------
 1029|      0|        {
 1030|       |            /* We have a default value for this field in the defstream */
 1031|      0|            if (!decode_field(&defstream, wire_type, iter))
  ------------------
  |  Branch (1031:17): [True: 0, False: 0]
  ------------------
 1032|      0|                return false;
 1033|      0|            if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1033:17): [True: 0, False: 0]
  ------------------
 1034|      0|                return false;
 1035|       |
 1036|      0|            if (iter->pSize)
  ------------------
  |  Branch (1036:17): [True: 0, False: 0]
  ------------------
 1037|      0|                *(bool*)iter->pSize = false;
 1038|      0|        }
 1039|  1.05M|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (1039:14): [True: 934k, False: 120k]
  ------------------
 1040|       |
 1041|   120k|    return true;
 1042|   120k|}
pb_decode.c:pb_field_set_to_default:
  928|  1.05M|{
  929|  1.05M|    pb_type_t type;
  930|  1.05M|    type = field->type;
  931|       |
  932|  1.05M|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  1.05M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.05M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  1.05M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (932:9): [True: 8.74k, False: 1.04M]
  ------------------
  933|  8.74k|    {
  934|  8.74k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  935|  15.8k|        while (ext != NULL)
  ------------------
  |  Branch (935:16): [True: 7.07k, False: 8.74k]
  ------------------
  936|  7.07k|        {
  937|  7.07k|            pb_field_iter_t ext_iter;
  938|  7.07k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (938:17): [True: 7.07k, False: 0]
  ------------------
  939|  7.07k|            {
  940|  7.07k|                ext->found = false;
  941|  7.07k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (941:21): [True: 0, False: 7.07k]
  ------------------
  942|      0|                    return false;
  943|  7.07k|            }
  944|  7.07k|            ext = ext->next;
  945|  7.07k|        }
  946|  8.74k|    }
  947|  1.04M|    else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|  1.04M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  1.04M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|  1.04M|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (947:14): [True: 33.3k, False: 1.01M]
  ------------------
  948|  33.3k|    {
  949|  33.3k|        bool init_data = true;
  950|  33.3k|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  327|  33.3k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  33.3k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  312|  66.6k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (950:13): [True: 0, False: 33.3k]
  |  Branch (950:52): [True: 0, False: 0]
  ------------------
  951|      0|        {
  952|       |            /* Set has_field to false. Still initialize the optional field
  953|       |             * itself also. */
  954|      0|            *(bool*)field->pSize = false;
  955|      0|        }
  956|  33.3k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  327|  33.3k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  33.3k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  314|  66.6k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (956:18): [True: 0, False: 33.3k]
  ------------------
  957|  33.3k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  33.3k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  33.3k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  33.3k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (957:18): [True: 26.2k, False: 7.07k]
  ------------------
  958|  26.2k|        {
  959|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
  960|       |               ONEOF: Set which_field to 0. */
  961|  26.2k|            *(pb_size_t*)field->pSize = 0;
  962|  26.2k|            init_data = false;
  963|  26.2k|        }
  964|       |
  965|  33.3k|        if (init_data)
  ------------------
  |  Branch (965:13): [True: 7.07k, False: 26.2k]
  ------------------
  966|  7.07k|        {
  967|  7.07k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  329|  14.1k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  7.07k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  7.07k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  14.1k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 7.07k, False: 0]
  |  |  ------------------
  |  |  330|  14.1k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|      0|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  968|  7.07k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (968:18): [True: 0, False: 7.07k]
  ------------------
  969|  7.07k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (969:18): [True: 0, False: 7.07k]
  ------------------
  970|  7.07k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (970:18): [True: 0, False: 7.07k]
  ------------------
  971|      0|            {
  972|       |                /* Initialize submessage to defaults.
  973|       |                 * Only needed if it has default values
  974|       |                 * or callback/submessage fields. */
  975|      0|                pb_field_iter_t submsg_iter;
  976|      0|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (976:21): [True: 0, False: 0]
  ------------------
  977|      0|                {
  978|      0|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (978:25): [True: 0, False: 0]
  ------------------
  979|      0|                        return false;
  980|      0|                }
  981|      0|            }
  982|  7.07k|            else
  983|  7.07k|            {
  984|       |                /* Initialize to zeros */
  985|  7.07k|                memset(field->pData, 0, (size_t)field->data_size);
  986|  7.07k|            }
  987|  7.07k|        }
  988|  33.3k|    }
  989|  1.01M|    else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  1.01M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  1.01M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  1.01M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (989:14): [True: 995k, False: 17.4k]
  ------------------
  990|   995k|    {
  991|       |        /* Initialize the pointer to NULL. */
  992|   995k|        *(void**)field->pField = NULL;
  993|       |
  994|       |        /* Initialize array count to 0. */
  995|   995k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  327|   995k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   995k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  314|  1.99M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (995:13): [True: 183k, False: 811k]
  ------------------
  996|   811k|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   811k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   811k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   811k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (996:13): [True: 17.4k, False: 794k]
  ------------------
  997|   201k|        {
  998|   201k|            *(pb_size_t*)field->pSize = 0;
  999|   201k|        }
 1000|   995k|    }
 1001|  17.4k|    else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|  17.4k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  17.4k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|  17.4k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1001:14): [True: 17.4k, False: 0]
  ------------------
 1002|  17.4k|    {
 1003|       |        /* Don't overwrite callback */
 1004|  17.4k|    }
 1005|       |
 1006|  1.05M|    return true;
 1007|  1.05M|}
pb_decode.c:decode_extension:
  906|  75.3k|{
  907|  75.3k|    size_t pos = stream->bytes_left;
  908|       |    
  909|   150k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (909:12): [True: 75.3k, False: 75.2k]
  |  Branch (909:33): [True: 75.3k, False: 0]
  ------------------
  910|  75.3k|    {
  911|  75.3k|        bool status;
  912|  75.3k|        if (extension->type->decode)
  ------------------
  |  Branch (912:13): [True: 0, False: 75.3k]
  ------------------
  913|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  914|  75.3k|        else
  915|  75.3k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  916|       |
  917|  75.3k|        if (!status)
  ------------------
  |  Branch (917:13): [True: 110, False: 75.2k]
  ------------------
  918|    110|            return false;
  919|       |        
  920|  75.2k|        extension = extension->next;
  921|  75.2k|    }
  922|       |    
  923|  75.2k|    return true;
  924|  75.3k|}
pb_decode.c:default_extension_decoder:
  889|  75.3k|{
  890|  75.3k|    pb_field_iter_t iter;
  891|       |
  892|  75.3k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (892:9): [True: 0, False: 75.3k]
  ------------------
  893|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  894|       |
  895|  75.3k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (895:9): [True: 71.6k, False: 3.69k]
  |  Branch (895:28): [True: 0, False: 3.69k]
  ------------------
  896|  71.6k|        return true;
  897|       |
  898|  3.69k|    extension->found = true;
  899|  3.69k|    return decode_field(stream, wire_type, &iter);
  900|  75.3k|}
pb_decode.c:decode_field:
  857|  32.0M|{
  858|  32.0M|#ifdef PB_ENABLE_MALLOC
  859|       |    /* When decoding an oneof field, check if there is old data that must be
  860|       |     * released first. */
  861|  32.0M|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  32.0M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  32.0M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  32.0M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (861:9): [True: 23.7k, False: 32.0M]
  ------------------
  862|  23.7k|    {
  863|  23.7k|        if (!pb_release_union_field(stream, field))
  ------------------
  |  Branch (863:13): [True: 0, False: 23.7k]
  ------------------
  864|      0|            return false;
  865|  23.7k|    }
  866|  32.0M|#endif
  867|       |
  868|  32.0M|    switch (PB_ATYPE(field->type))
  ------------------
  |  |  326|  32.0M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  32.0M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
  869|  32.0M|    {
  870|  11.8k|        case PB_ATYPE_STATIC:
  ------------------
  |  |  321|  11.8k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (870:9): [True: 11.8k, False: 32.0M]
  ------------------
  871|  11.8k|            return decode_static_field(stream, wire_type, field);
  872|       |        
  873|  32.0M|        case PB_ATYPE_POINTER:
  ------------------
  |  |  322|  32.0M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (873:9): [True: 32.0M, False: 18.0k]
  ------------------
  874|  32.0M|            return decode_pointer_field(stream, wire_type, field);
  875|       |        
  876|  6.15k|        case PB_ATYPE_CALLBACK:
  ------------------
  |  |  323|  6.15k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (876:9): [True: 6.15k, False: 32.0M]
  ------------------
  877|  6.15k|            return decode_callback_field(stream, wire_type, field);
  878|       |        
  879|      0|        default:
  ------------------
  |  Branch (879:9): [True: 0, False: 32.0M]
  ------------------
  880|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  881|  32.0M|    }
  882|  32.0M|}
pb_decode.c:pb_release_union_field:
 1256|  23.7k|{
 1257|  23.7k|    pb_field_iter_t old_field = *field;
 1258|  23.7k|    pb_size_t old_tag = *(pb_size_t*)field->pSize; /* Previous which_ value */
 1259|  23.7k|    pb_size_t new_tag = field->tag; /* New which_ value */
 1260|       |
 1261|  23.7k|    if (old_tag == 0)
  ------------------
  |  Branch (1261:9): [True: 1.77k, False: 21.9k]
  ------------------
 1262|  1.77k|        return true; /* Ok, no old data in union */
 1263|       |
 1264|  21.9k|    if (old_tag == new_tag)
  ------------------
  |  Branch (1264:9): [True: 13.5k, False: 8.43k]
  ------------------
 1265|  13.5k|        return true; /* Ok, old data is of same type => merge */
 1266|       |
 1267|       |    /* Release old data. The find can fail if the message struct contains
 1268|       |     * invalid data. */
 1269|  8.43k|    if (!pb_field_iter_find(&old_field, old_tag))
  ------------------
  |  Branch (1269:9): [True: 0, False: 8.43k]
  ------------------
 1270|      0|        PB_RETURN_ERROR(stream, "invalid union tag");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1271|       |
 1272|  8.43k|    pb_release_single_field(&old_field);
 1273|       |
 1274|  8.43k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  8.43k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  8.43k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  8.43k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1274:9): [True: 2.48k, False: 5.95k]
  ------------------
 1275|  2.48k|    {
 1276|       |        /* Initialize the pointer to NULL to make sure it is valid
 1277|       |         * even in case of error return. */
 1278|  2.48k|        *(void**)field->pField = NULL;
 1279|  2.48k|        field->pData = NULL;
 1280|  2.48k|    }
 1281|       |
 1282|       |    return true;
 1283|  8.43k|}
pb_decode.c:decode_static_field:
  498|  11.8k|{
  499|  11.8k|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  327|  11.8k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  11.8k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  500|  11.8k|    {
  501|  3.69k|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  311|  3.69k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (501:9): [True: 3.69k, False: 8.15k]
  ------------------
  502|  3.69k|            return decode_basic_field(stream, wire_type, field);
  503|       |            
  504|  1.23k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  312|  1.23k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (504:9): [True: 1.23k, False: 10.6k]
  ------------------
  505|  1.23k|            if (field->pSize != NULL)
  ------------------
  |  Branch (505:17): [True: 1.23k, False: 0]
  ------------------
  506|  1.23k|                *(bool*)field->pSize = true;
  507|  1.23k|            return decode_basic_field(stream, wire_type, field);
  508|       |    
  509|      0|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  314|      0|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (509:9): [True: 0, False: 11.8k]
  ------------------
  510|      0|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (510:17): [True: 0, False: 0]
  ------------------
  511|      0|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  328|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  276|      0|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (511:20): [True: 0, False: 0]
  ------------------
  512|      0|            {
  513|       |                /* Packed array */
  514|      0|                bool status = true;
  515|      0|                pb_istream_t substream;
  516|      0|                pb_size_t *size = (pb_size_t*)field->pSize;
  517|      0|                field->pData = (char*)field->pField + field->data_size * (*size);
  518|       |
  519|      0|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (519:21): [True: 0, False: 0]
  ------------------
  520|      0|                    return false;
  521|       |
  522|      0|                while (substream.bytes_left > 0 && *size < field->array_size)
  ------------------
  |  Branch (522:24): [True: 0, False: 0]
  |  Branch (522:52): [True: 0, False: 0]
  ------------------
  523|      0|                {
  524|      0|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (524:25): [True: 0, False: 0]
  ------------------
  525|      0|                    {
  526|      0|                        status = false;
  527|      0|                        break;
  528|      0|                    }
  529|      0|                    (*size)++;
  530|      0|                    field->pData = (char*)field->pData + field->data_size;
  531|      0|                }
  532|       |
  533|      0|                if (substream.bytes_left != 0)
  ------------------
  |  Branch (533:21): [True: 0, False: 0]
  ------------------
  534|      0|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  535|      0|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (535:21): [True: 0, False: 0]
  ------------------
  536|      0|                    return false;
  537|       |
  538|      0|                return status;
  539|      0|            }
  540|      0|            else
  541|      0|            {
  542|       |                /* Repeated field */
  543|      0|                pb_size_t *size = (pb_size_t*)field->pSize;
  544|      0|                field->pData = (char*)field->pField + field->data_size * (*size);
  545|       |
  546|      0|                if ((*size)++ >= field->array_size)
  ------------------
  |  Branch (546:21): [True: 0, False: 0]
  ------------------
  547|      0|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  548|       |
  549|      0|                return decode_basic_field(stream, wire_type, field);
  550|      0|            }
  551|       |
  552|  6.92k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  316|  6.92k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (552:9): [True: 6.92k, False: 4.92k]
  ------------------
  553|  6.92k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  329|  13.8k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  6.92k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  6.92k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  13.8k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 5.53k, False: 1.39k]
  |  |  ------------------
  |  |  330|  13.8k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  1.39k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.39k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  1.39k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 1.39k]
  |  |  ------------------
  ------------------
  554|  5.53k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (554:17): [True: 2.84k, False: 2.68k]
  ------------------
  555|  2.84k|            {
  556|       |                /* We memset to zero so that any callbacks are set to NULL.
  557|       |                 * This is because the callbacks might otherwise have values
  558|       |                 * from some other union field.
  559|       |                 * If callbacks are needed inside oneof field, use .proto
  560|       |                 * option submsg_callback to have a separate callback function
  561|       |                 * that can set the fields before submessage is decoded.
  562|       |                 * pb_dec_submessage() will set any default values. */
  563|  2.84k|                memset(field->pData, 0, (size_t)field->data_size);
  564|       |
  565|       |                /* Set default values for the submessage fields. */
  566|  2.84k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (566:21): [True: 0, False: 2.84k]
  ------------------
  567|  2.84k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (567:21): [True: 0, False: 2.84k]
  ------------------
  568|  2.84k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (568:21): [True: 0, False: 2.84k]
  ------------------
  569|      0|                {
  570|      0|                    pb_field_iter_t submsg_iter;
  571|      0|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (571:25): [True: 0, False: 0]
  ------------------
  572|      0|                    {
  573|      0|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (573:29): [True: 0, False: 0]
  ------------------
  574|      0|                            PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  575|      0|                    }
  576|      0|                }
  577|  2.84k|            }
  578|  6.92k|            *(pb_size_t*)field->pSize = field->tag;
  579|       |
  580|  6.92k|            return decode_basic_field(stream, wire_type, field);
  581|       |
  582|      0|        default:
  ------------------
  |  Branch (582:9): [True: 0, False: 11.8k]
  ------------------
  583|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  584|  11.8k|    }
  585|  11.8k|}
pb_decode.c:decode_basic_field:
  427|  43.7M|{
  428|  43.7M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|  43.7M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  43.7M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  429|  43.7M|    {
  430|  3.15M|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|  3.15M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (430:9): [True: 3.15M, False: 40.5M]
  ------------------
  431|  3.15M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (431:17): [True: 2.85M, False: 296k]
  |  Branch (431:46): [True: 11, False: 2.85M]
  ------------------
  432|     11|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     11|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     11|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  433|       |
  434|  3.15M|            return pb_dec_bool(stream, field);
  435|       |
  436|  5.30M|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|  5.30M|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (436:9): [True: 5.30M, False: 38.4M]
  ------------------
  437|  6.16M|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|  6.16M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (437:9): [True: 856k, False: 42.8M]
  ------------------
  438|  9.86M|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|  9.86M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (438:9): [True: 3.69M, False: 40.0M]
  ------------------
  439|  9.86M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (439:17): [True: 8.89M, False: 970k]
  |  Branch (439:46): [True: 81, False: 8.89M]
  ------------------
  440|     81|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     81|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     81|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 81]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  441|       |
  442|  9.86M|            return pb_dec_varint(stream, field);
  443|       |
  444|  81.4k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|  81.4k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (444:9): [True: 81.4k, False: 43.6M]
  ------------------
  445|  81.4k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (445:17): [True: 13.0k, False: 68.4k]
  |  Branch (445:45): [True: 15, False: 12.9k]
  ------------------
  446|     15|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     15|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     15|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  447|       |
  448|  81.4k|            return pb_decode_fixed32(stream, field->pData);
  449|       |
  450|  60.9k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|  60.9k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (450:9): [True: 60.9k, False: 43.6M]
  ------------------
  451|  60.9k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (451:17): [True: 15.7k, False: 45.1k]
  |  Branch (451:45): [True: 14, False: 15.7k]
  ------------------
  452|     14|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     14|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     14|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  453|       |
  454|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  455|       |            if (field->data_size == sizeof(float))
  456|       |            {
  457|       |                return pb_decode_double_as_float(stream, (float*)field->pData);
  458|       |            }
  459|       |#endif
  460|       |
  461|       |#ifdef PB_WITHOUT_64BIT
  462|       |            PB_RETURN_ERROR(stream, "invalid data_size");
  463|       |#else
  464|  60.9k|            return pb_decode_fixed64(stream, field->pData);
  465|      0|#endif
  466|       |
  467|   664k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|   664k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (467:9): [True: 664k, False: 43.0M]
  ------------------
  468|   664k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (468:17): [True: 14, False: 664k]
  ------------------
  469|     14|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     14|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     14|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  470|       |
  471|   664k|            return pb_dec_bytes(stream, field);
  472|       |
  473|   112k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|   112k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (473:9): [True: 112k, False: 43.6M]
  ------------------
  474|   112k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (474:17): [True: 11, False: 112k]
  ------------------
  475|     11|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     11|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     11|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  476|       |
  477|   112k|            return pb_dec_string(stream, field);
  478|       |
  479|   172k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|   172k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (479:9): [True: 172k, False: 43.5M]
  ------------------
  480|   172k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|   172k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (480:9): [True: 0, False: 43.7M]
  ------------------
  481|   172k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (481:17): [True: 25, False: 172k]
  ------------------
  482|     25|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     25|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     25|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  483|       |
  484|   172k|            return pb_dec_submessage(stream, field);
  485|       |
  486|  29.6M|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  303|  29.6M|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (486:9): [True: 29.6M, False: 14.1M]
  ------------------
  487|  29.6M|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (487:17): [True: 6, False: 29.6M]
  ------------------
  488|      6|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|      6|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      6|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|  29.6M|            return pb_dec_fixed_length_bytes(stream, field);
  491|       |
  492|      0|        default:
  ------------------
  |  Branch (492:9): [True: 0, False: 43.7M]
  ------------------
  493|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  494|  43.7M|    }
  495|  43.7M|}
pb_decode.c:pb_dec_bool:
 1477|  3.15M|{
 1478|  3.15M|    return pb_decode_bool(stream, (bool*)field->pData);
 1479|  3.15M|}
pb_decode.c:pb_dec_varint:
 1482|  9.86M|{
 1483|  9.86M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  328|  9.86M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  9.86M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  270|  9.86M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1483:9): [True: 856k, False: 9.00M]
  ------------------
 1484|   856k|    {
 1485|   856k|        pb_uint64_t value, clamped;
  ------------------
  |  |   57|   856k|#define pb_uint64_t uint64_t
  ------------------
 1486|   856k|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1486:13): [True: 48, False: 856k]
  ------------------
 1487|     48|            return false;
 1488|       |
 1489|       |        /* Cast to the proper field size, while checking for overflows */
 1490|   856k|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1490:13): [True: 520k, False: 335k]
  ------------------
 1491|   520k|            clamped = *(pb_uint64_t*)field->pData = value;
 1492|   335k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1492:18): [True: 311k, False: 23.6k]
  ------------------
 1493|   311k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1494|  23.6k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1494:18): [True: 11.7k, False: 11.9k]
  ------------------
 1495|  11.7k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1496|  11.9k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1496:18): [True: 11.9k, False: 0]
  ------------------
 1497|  11.9k|            clamped = *(uint_least8_t*)field->pData = (uint_least8_t)value;
 1498|      0|        else
 1499|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1500|       |
 1501|   856k|        if (clamped != value)
  ------------------
  |  Branch (1501:13): [True: 113, False: 856k]
  ------------------
 1502|    113|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  930|    113|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    113|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 113]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1503|       |
 1504|   856k|        return true;
 1505|   856k|    }
 1506|  9.00M|    else
 1507|  9.00M|    {
 1508|  9.00M|        pb_uint64_t value;
  ------------------
  |  |   57|  9.00M|#define pb_uint64_t uint64_t
  ------------------
 1509|  9.00M|        pb_int64_t svalue;
  ------------------
  |  |   56|  9.00M|#define pb_int64_t int64_t
  ------------------
 1510|  9.00M|        pb_int64_t clamped;
  ------------------
  |  |   56|  9.00M|#define pb_int64_t int64_t
  ------------------
 1511|       |
 1512|  9.00M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  328|  9.00M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  9.00M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  271|  9.00M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1512:13): [True: 3.69M, False: 5.30M]
  ------------------
 1513|  3.69M|        {
 1514|  3.69M|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1514:17): [True: 37, False: 3.69M]
  ------------------
 1515|     37|                return false;
 1516|  3.69M|        }
 1517|  5.30M|        else
 1518|  5.30M|        {
 1519|  5.30M|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1519:17): [True: 52, False: 5.30M]
  ------------------
 1520|     52|                return false;
 1521|       |
 1522|       |            /* See issue 97: Google's C++ protobuf allows negative varint values to
 1523|       |            * be cast as int32_t, instead of the int64_t that should be used when
 1524|       |            * encoding. Nanopb versions before 0.2.5 had a bug in encoding. In order to
 1525|       |            * not break decoding of such messages, we cast <=32 bit fields to
 1526|       |            * int32_t first to get the sign correct.
 1527|       |            */
 1528|  5.30M|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1528:17): [True: 684k, False: 4.62M]
  ------------------
 1529|   684k|                svalue = (pb_int64_t)value;
 1530|  4.62M|            else
 1531|  4.62M|                svalue = (int32_t)value;
 1532|  5.30M|        }
 1533|       |
 1534|       |        /* Cast to the proper field size, while checking for overflows */
 1535|  9.00M|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1535:13): [True: 4.31M, False: 4.68M]
  ------------------
 1536|  4.31M|            clamped = *(pb_int64_t*)field->pData = svalue;
 1537|  4.68M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1537:18): [True: 4.64M, False: 46.9k]
  ------------------
 1538|  4.64M|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1539|  46.9k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1539:18): [True: 23.4k, False: 23.5k]
  ------------------
 1540|  23.4k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1541|  23.5k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1541:18): [True: 23.5k, False: 0]
  ------------------
 1542|  23.5k|            clamped = *(int_least8_t*)field->pData = (int_least8_t)svalue;
 1543|      0|        else
 1544|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1545|       |
 1546|  9.00M|        if (clamped != svalue)
  ------------------
  |  Branch (1546:13): [True: 87, False: 9.00M]
  ------------------
 1547|     87|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  930|     87|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     87|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 87]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1548|       |
 1549|  9.00M|        return true;
 1550|  9.00M|    }
 1551|  9.86M|}
pb_decode.c:pb_dec_bytes:
 1554|   664k|{
 1555|   664k|    uint32_t size;
 1556|   664k|    size_t alloc_size;
 1557|   664k|    pb_bytes_array_t *dest;
 1558|       |    
 1559|   664k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1559:9): [True: 23, False: 663k]
  ------------------
 1560|     23|        return false;
 1561|       |    
 1562|   663k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  342|   663k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1562:9): [True: 33, False: 663k]
  ------------------
 1563|     33|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  930|     33|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     33|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 33]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1564|       |    
 1565|   663k|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  411|   663k|    (((size_t)(n) + offsetof(pb_bytes_array_t, bytes)) < sizeof(pb_bytes_array_t) \
  |  |  ------------------
  |  |  |  Branch (411:6): [True: 654k, False: 9.14k]
  |  |  ------------------
  |  |  412|   663k|        ? sizeof(pb_bytes_array_t) \
  |  |  413|   663k|        : ((size_t)(n) + offsetof(pb_bytes_array_t, bytes)))
  ------------------
 1566|   663k|    if (size > alloc_size)
  ------------------
  |  Branch (1566:9): [True: 0, False: 663k]
  ------------------
 1567|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1568|       |    
 1569|   663k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   663k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   663k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   663k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1569:9): [True: 663k, False: 0]
  ------------------
 1570|   663k|    {
 1571|       |#ifndef PB_ENABLE_MALLOC
 1572|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1573|       |#else
 1574|   663k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1574:13): [True: 52, False: 663k]
  ------------------
 1575|     52|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  930|     52|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     52|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 52]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1576|       |
 1577|   663k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1577:13): [True: 0, False: 663k]
  ------------------
 1578|      0|            return false;
 1579|   663k|        dest = *(pb_bytes_array_t**)field->pData;
 1580|   663k|#endif
 1581|   663k|    }
 1582|      0|    else
 1583|      0|    {
 1584|      0|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1584:13): [True: 0, False: 0]
  ------------------
 1585|      0|            PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1586|      0|        dest = (pb_bytes_array_t*)field->pData;
 1587|      0|    }
 1588|       |
 1589|   663k|    dest->size = (pb_size_t)size;
 1590|   663k|    return pb_read(stream, dest->bytes, (size_t)size);
 1591|   663k|}
pb_decode.c:allocate_field:
  593|  33.5M|{    
  594|  33.5M|    void *ptr = *(void**)pData;
  595|       |    
  596|  33.5M|    if (data_size == 0 || array_size == 0)
  ------------------
  |  Branch (596:9): [True: 0, False: 33.5M]
  |  Branch (596:27): [True: 0, False: 33.5M]
  ------------------
  597|      0|        PB_RETURN_ERROR(stream, "invalid size");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  598|       |    
  599|       |#ifdef __AVR__
  600|       |    /* Workaround for AVR libc bug 53284: http://savannah.nongnu.org/bugs/?53284
  601|       |     * Realloc to size of 1 byte can cause corruption of the malloc structures.
  602|       |     */
  603|       |    if (data_size == 1 && array_size == 1)
  604|       |    {
  605|       |        data_size = 2;
  606|       |    }
  607|       |#endif
  608|       |
  609|       |    /* Check for multiplication overflows.
  610|       |     * This code avoids the costly division if the sizes are small enough.
  611|       |     * Multiplication is safe as long as only half of bits are set
  612|       |     * in either multiplicand.
  613|       |     */
  614|  33.5M|    {
  615|  33.5M|        const size_t check_limit = (size_t)1 << (sizeof(size_t) * 4);
  616|  33.5M|        if (data_size >= check_limit || array_size >= check_limit)
  ------------------
  |  Branch (616:13): [True: 0, False: 33.5M]
  |  Branch (616:41): [True: 0, False: 33.5M]
  ------------------
  617|      0|        {
  618|      0|            const size_t size_max = (size_t)-1;
  619|      0|            if (size_max / array_size < data_size)
  ------------------
  |  Branch (619:17): [True: 0, False: 0]
  ------------------
  620|      0|            {
  621|      0|                PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  622|      0|            }
  623|      0|        }
  624|  33.5M|    }
  625|       |    
  626|       |    /* Allocate new or expand previous allocation */
  627|       |    /* Note: on failure the old pointer will remain in the structure,
  628|       |     * the message must be freed by caller also on error return. */
  629|  33.5M|    ptr = pb_realloc(ptr, array_size * data_size);
  ------------------
  |  |    3|  33.5M|#define pb_realloc(ptr,size) realloc_with_check(ptr,size)
  ------------------
  630|  33.5M|    if (ptr == NULL)
  ------------------
  |  Branch (630:9): [True: 0, False: 33.5M]
  ------------------
  631|      0|        PB_RETURN_ERROR(stream, "realloc failed");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  632|       |    
  633|  33.5M|    *(void**)pData = ptr;
  634|       |    return true;
  635|  33.5M|}
pb_decode.c:pb_dec_string:
 1594|   112k|{
 1595|   112k|    uint32_t size;
 1596|   112k|    size_t alloc_size;
 1597|   112k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1598|       |
 1599|   112k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1599:9): [True: 28, False: 112k]
  ------------------
 1600|     28|        return false;
 1601|       |
 1602|   112k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1602:9): [True: 3, False: 112k]
  ------------------
 1603|      3|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1604|       |
 1605|       |    /* Space for null terminator */
 1606|   112k|    alloc_size = (size_t)(size + 1);
 1607|       |
 1608|   112k|    if (alloc_size < size)
  ------------------
  |  Branch (1608:9): [True: 0, False: 112k]
  ------------------
 1609|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1610|       |
 1611|   112k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   112k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   112k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   112k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1611:9): [True: 111k, False: 1.22k]
  ------------------
 1612|   111k|    {
 1613|       |#ifndef PB_ENABLE_MALLOC
 1614|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1615|       |#else
 1616|   111k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1616:13): [True: 66, False: 111k]
  ------------------
 1617|     66|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  930|     66|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     66|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 66]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1618|       |
 1619|   111k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1619:13): [True: 0, False: 111k]
  ------------------
 1620|      0|            return false;
 1621|   111k|        dest = *(pb_byte_t**)field->pData;
 1622|   111k|#endif
 1623|   111k|    }
 1624|  1.22k|    else
 1625|  1.22k|    {
 1626|  1.22k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1626:13): [True: 51, False: 1.17k]
  ------------------
 1627|     51|            PB_RETURN_ERROR(stream, "string overflow");
  ------------------
  |  |  930|     51|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     51|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 51]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1628|  1.22k|    }
 1629|       |    
 1630|   112k|    dest[size] = 0;
 1631|       |
 1632|   112k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1632:9): [True: 5, False: 112k]
  ------------------
 1633|      5|        return false;
 1634|       |
 1635|       |#ifdef PB_VALIDATE_UTF8
 1636|       |    if (!pb_validate_utf8((const char*)dest))
 1637|       |        PB_RETURN_ERROR(stream, "invalid utf8");
 1638|       |#endif
 1639|       |
 1640|   112k|    return true;
 1641|   112k|}
pb_decode.c:pb_dec_submessage:
 1644|   172k|{
 1645|   172k|    bool status = true;
 1646|   172k|    bool submsg_consumed = false;
 1647|   172k|    pb_istream_t substream;
 1648|       |
 1649|   172k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1649:9): [True: 137, False: 172k]
  ------------------
 1650|    137|        return false;
 1651|       |    
 1652|   172k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1652:9): [True: 0, False: 172k]
  ------------------
 1653|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1654|       |    
 1655|       |    /* Submessages can have a separate message-level callback that is called
 1656|       |     * before decoding the message. Typically it is used to set callback fields
 1657|       |     * inside oneofs. */
 1658|   172k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  328|   172k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   172k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  293|   345k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1658:9): [True: 0, False: 172k]
  |  Branch (1658:58): [True: 0, False: 0]
  ------------------
 1659|      0|    {
 1660|       |        /* Message callback is stored right before pSize. */
 1661|      0|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
 1662|      0|        if (callback->funcs.decode)
  ------------------
  |  Branch (1662:13): [True: 0, False: 0]
  ------------------
 1663|      0|        {
 1664|      0|            status = callback->funcs.decode(&substream, field, &callback->arg);
 1665|       |
 1666|      0|            if (substream.bytes_left == 0)
  ------------------
  |  Branch (1666:17): [True: 0, False: 0]
  ------------------
 1667|      0|            {
 1668|      0|                submsg_consumed = true;
 1669|      0|            }
 1670|      0|        }
 1671|      0|    }
 1672|       |
 1673|       |    /* Now decode the submessage contents */
 1674|   172k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1674:9): [True: 172k, False: 0]
  |  Branch (1674:19): [True: 172k, False: 0]
  ------------------
 1675|   172k|    {
 1676|   172k|        unsigned int flags = 0;
 1677|       |
 1678|       |        /* Static required/optional fields are already initialized by top-level
 1679|       |         * pb_decode(), no need to initialize them again. */
 1680|   172k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  326|   172k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   172k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  321|   345k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1680:13): [True: 9.16k, False: 163k]
  ------------------
 1681|  9.16k|            PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  327|  9.16k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  9.16k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  314|  9.16k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1681:13): [True: 9.16k, False: 0]
  ------------------
 1682|  9.16k|        {
 1683|  9.16k|            flags = PB_DECODE_NOINIT;
  ------------------
  |  |  122|  9.16k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1684|  9.16k|        }
 1685|       |
 1686|   172k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1687|   172k|    }
 1688|       |    
 1689|   172k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1689:9): [True: 0, False: 172k]
  ------------------
 1690|      0|        return false;
 1691|       |
 1692|   172k|    return status;
 1693|   172k|}
pb_decode.c:pb_dec_fixed_length_bytes:
 1696|  29.6M|{
 1697|  29.6M|    uint32_t size;
 1698|       |
 1699|  29.6M|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1699:9): [True: 3, False: 29.6M]
  ------------------
 1700|      3|        return false;
 1701|       |
 1702|  29.6M|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  342|  29.6M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1702:9): [True: 31, False: 29.6M]
  ------------------
 1703|     31|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  930|     31|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     31|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1704|       |
 1705|  29.6M|    if (size == 0)
  ------------------
  |  Branch (1705:9): [True: 28.5M, False: 1.09M]
  ------------------
 1706|  28.5M|    {
 1707|       |        /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */
 1708|  28.5M|        memset(field->pData, 0, (size_t)field->data_size);
 1709|  28.5M|        return true;
 1710|  28.5M|    }
 1711|       |
 1712|  1.09M|    if (size != field->data_size)
  ------------------
  |  Branch (1712:9): [True: 47, False: 1.09M]
  ------------------
 1713|     47|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  930|     47|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     47|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1714|       |
 1715|  1.09M|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1716|  1.09M|}
pb_decode.c:decode_pointer_field:
  655|  32.0M|{
  656|       |#ifndef PB_ENABLE_MALLOC
  657|       |    PB_UNUSED(wire_type);
  658|       |    PB_UNUSED(field);
  659|       |    PB_RETURN_ERROR(stream, "no malloc support");
  660|       |#else
  661|  32.0M|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  327|  32.0M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  32.0M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  662|  32.0M|    {
  663|  1.53M|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  311|  1.53M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (663:9): [True: 1.53M, False: 30.4M]
  ------------------
  664|  1.55M|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  312|  1.55M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (664:9): [True: 20.0k, False: 31.9M]
  ------------------
  665|  1.56M|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  316|  1.56M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (665:9): [True: 10.6k, False: 32.0M]
  ------------------
  666|  1.56M|            if (PB_LTYPE_IS_SUBMSG(field->type) && *(void**)field->pField != NULL)
  ------------------
  |  |  329|  3.12M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  1.56M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.56M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  3.12M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 75.7k, False: 1.48M]
  |  |  ------------------
  |  |  330|  3.12M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  1.48M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.48M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  1.48M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 1.48M]
  |  |  ------------------
  ------------------
  |  Branch (666:52): [True: 39.4k, False: 36.3k]
  ------------------
  667|  39.4k|            {
  668|       |                /* Duplicate field, have to release the old allocation first. */
  669|       |                /* FIXME: Does this work correctly for oneofs? */
  670|  39.4k|                pb_release_single_field(field);
  671|  39.4k|            }
  672|       |        
  673|  1.56M|            if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  1.56M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.56M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  1.56M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (673:17): [True: 10.6k, False: 1.55M]
  ------------------
  674|  10.6k|            {
  675|  10.6k|                *(pb_size_t*)field->pSize = field->tag;
  676|  10.6k|            }
  677|       |
  678|  1.56M|            if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|  1.56M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.56M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|  3.12M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (678:17): [True: 89.4k, False: 1.47M]
  ------------------
  679|  1.47M|                PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|  1.47M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.47M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|  1.47M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (679:17): [True: 16.2k, False: 1.45M]
  ------------------
  680|   105k|            {
  681|       |                /* pb_dec_string and pb_dec_bytes handle allocation themselves */
  682|   105k|                field->pData = field->pField;
  683|   105k|                return decode_basic_field(stream, wire_type, field);
  684|   105k|            }
  685|  1.45M|            else
  686|  1.45M|            {
  687|  1.45M|                if (!allocate_field(stream, field->pField, field->data_size, 1))
  ------------------
  |  Branch (687:21): [True: 0, False: 1.45M]
  ------------------
  688|      0|                    return false;
  689|       |                
  690|  1.45M|                field->pData = *(void**)field->pField;
  691|  1.45M|                initialize_pointer_field(field->pData, field);
  692|  1.45M|                return decode_basic_field(stream, wire_type, field);
  693|  1.45M|            }
  694|       |    
  695|  30.4M|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  314|  30.4M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (695:9): [True: 30.4M, False: 1.56M]
  ------------------
  696|  30.4M|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (696:17): [True: 30.4M, False: 8.62k]
  ------------------
  697|  30.4M|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  328|  30.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  30.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  276|  30.4M|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (697:20): [True: 88.1k, False: 30.3M]
  ------------------
  698|  88.1k|            {
  699|       |                /* Packed array, multiple items come in at once. */
  700|  88.1k|                bool status = true;
  701|  88.1k|                pb_size_t *size = (pb_size_t*)field->pSize;
  702|  88.1k|                size_t allocated_size = *size;
  703|  88.1k|                pb_istream_t substream;
  704|       |                
  705|  88.1k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (705:21): [True: 54, False: 88.0k]
  ------------------
  706|     54|                    return false;
  707|       |                
  708|  11.8M|                while (substream.bytes_left)
  ------------------
  |  Branch (708:24): [True: 11.7M, False: 87.9k]
  ------------------
  709|  11.7M|                {
  710|  11.7M|                    if (*size == PB_SIZE_MAX)
  ------------------
  |  |  342|  11.7M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (710:25): [True: 6, False: 11.7M]
  ------------------
  711|      6|                    {
  712|      6|#ifndef PB_NO_ERRMSG
  713|      6|                        stream->errmsg = "too many array entries";
  714|      6|#endif
  715|      6|                        status = false;
  716|      6|                        break;
  717|      6|                    }
  718|       |
  719|  11.7M|                    if ((size_t)*size + 1 > allocated_size)
  ------------------
  |  Branch (719:25): [True: 925k, False: 10.8M]
  ------------------
  720|   925k|                    {
  721|       |                        /* Allocate more storage. This tries to guess the
  722|       |                         * number of remaining entries. Round the division
  723|       |                         * upwards. */
  724|   925k|                        size_t remain = (substream.bytes_left - 1) / field->data_size + 1;
  725|   925k|                        if (remain < PB_SIZE_MAX - allocated_size)
  ------------------
  |  |  342|   925k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (725:29): [True: 251k, False: 673k]
  ------------------
  726|   251k|                            allocated_size += remain;
  727|   673k|                        else
  728|   673k|                            allocated_size += 1;
  729|       |                        
  730|   925k|                        if (!allocate_field(&substream, field->pField, field->data_size, allocated_size))
  ------------------
  |  Branch (730:29): [True: 0, False: 925k]
  ------------------
  731|      0|                        {
  732|      0|                            status = false;
  733|      0|                            break;
  734|      0|                        }
  735|   925k|                    }
  736|       |
  737|       |                    /* Decode the array entry */
  738|  11.7M|                    field->pData = *(char**)field->pField + field->data_size * (*size);
  739|  11.7M|                    if (field->pData == NULL)
  ------------------
  |  Branch (739:25): [True: 0, False: 11.7M]
  ------------------
  740|      0|                    {
  741|       |                        /* Shouldn't happen, but satisfies static analyzers */
  742|      0|                        status = false;
  743|      0|                        break;
  744|      0|                    }
  745|  11.7M|                    initialize_pointer_field(field->pData, field);
  746|  11.7M|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (746:25): [True: 104, False: 11.7M]
  ------------------
  747|    104|                    {
  748|    104|                        status = false;
  749|    104|                        break;
  750|    104|                    }
  751|       |                    
  752|  11.7M|                    (*size)++;
  753|  11.7M|                }
  754|  88.0k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (754:21): [True: 0, False: 88.0k]
  ------------------
  755|      0|                    return false;
  756|       |                
  757|  88.0k|                return status;
  758|  88.0k|            }
  759|  30.3M|            else
  760|  30.3M|            {
  761|       |                /* Normal repeated field, i.e. only one item at a time. */
  762|  30.3M|                pb_size_t *size = (pb_size_t*)field->pSize;
  763|       |
  764|  30.3M|                if (*size == PB_SIZE_MAX)
  ------------------
  |  |  342|  30.3M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (764:21): [True: 1, False: 30.3M]
  ------------------
  765|      1|                    PB_RETURN_ERROR(stream, "too many array entries");
  ------------------
  |  |  930|      1|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      1|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  766|       |                
  767|  30.3M|                if (!allocate_field(stream, field->pField, field->data_size, (size_t)(*size + 1)))
  ------------------
  |  Branch (767:21): [True: 0, False: 30.3M]
  ------------------
  768|      0|                    return false;
  769|       |            
  770|  30.3M|                field->pData = *(char**)field->pField + field->data_size * (*size);
  771|  30.3M|                (*size)++;
  772|  30.3M|                initialize_pointer_field(field->pData, field);
  773|  30.3M|                return decode_basic_field(stream, wire_type, field);
  774|  30.3M|            }
  775|       |
  776|      0|        default:
  ------------------
  |  Branch (776:9): [True: 0, False: 32.0M]
  ------------------
  777|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  778|  32.0M|    }
  779|  32.0M|#endif
  780|  32.0M|}
pb_decode.c:initialize_pointer_field:
  639|  43.5M|{
  640|  43.5M|    if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|  43.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  43.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|  87.1M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (640:9): [True: 21.8k, False: 43.5M]
  ------------------
  641|  43.5M|        PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|  43.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  43.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|  43.5M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (641:9): [True: 647k, False: 42.9M]
  ------------------
  642|   669k|    {
  643|   669k|        *(void**)pItem = NULL;
  644|   669k|    }
  645|  42.9M|    else if (PB_LTYPE_IS_SUBMSG(field->type))
  ------------------
  |  |  329|  42.9M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  42.9M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  42.9M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  85.8M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 163k, False: 42.7M]
  |  |  ------------------
  |  |  330|  42.9M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  42.7M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  42.7M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  42.7M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 42.7M]
  |  |  ------------------
  ------------------
  646|   163k|    {
  647|       |        /* We memset to zero so that any callbacks are set to NULL.
  648|       |         * Default values will be set by pb_dec_submessage(). */
  649|   163k|        memset(pItem, 0, field->data_size);
  650|   163k|    }
  651|  43.5M|}
pb_decode.c:decode_callback_field:
  783|  6.15k|{
  784|       |    /* Clear any data that may have been decoded for another oneof field
  785|       |     * that has come before this callback field.
  786|       |     */
  787|  6.15k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  6.15k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  6.15k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  6.15k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (787:9): [True: 6.15k, False: 0]
  ------------------
  788|  6.15k|    {
  789|  6.15k|        if (*(pb_size_t*)field->pSize != 0 && *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (789:13): [True: 5.52k, False: 634]
  |  Branch (789:47): [True: 2.43k, False: 3.08k]
  ------------------
  790|  2.43k|        {
  791|  2.43k|            memset(field->pData, 0, (size_t)field->data_size);
  792|  2.43k|        }
  793|  6.15k|        *(pb_size_t*)field->pSize = field->tag;
  794|  6.15k|    }
  795|       |
  796|  6.15k|    if (!field->descriptor->field_callback)
  ------------------
  |  Branch (796:9): [True: 0, False: 6.15k]
  ------------------
  797|      0|        return pb_skip_field(stream, wire_type);
  798|       |
  799|  6.15k|    if (wire_type == PB_WT_STRING)
  ------------------
  |  Branch (799:9): [True: 1.62k, False: 4.53k]
  ------------------
  800|  1.62k|    {
  801|  1.62k|        pb_istream_t substream;
  802|  1.62k|        size_t prev_bytes_left;
  803|       |        
  804|  1.62k|        if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (804:13): [True: 50, False: 1.57k]
  ------------------
  805|     50|            return false;
  806|       |
  807|       |        /* If the callback field is inside a submsg, first call the submsg_callback which
  808|       |         * should set the decoder for the callback field. */
  809|  1.57k|        if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  328|  1.57k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.57k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  293|  3.14k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (809:13): [True: 0, False: 1.57k]
  |  Branch (809:62): [True: 0, False: 0]
  ------------------
  810|      0|            pb_callback_t* callback;
  811|      0|            *(pb_size_t*)field->pSize = field->tag;
  812|      0|            callback = (pb_callback_t*)field->pSize - 1;
  813|       |
  814|      0|            if (callback->funcs.decode)
  ------------------
  |  Branch (814:17): [True: 0, False: 0]
  ------------------
  815|      0|            {
  816|      0|                if (!callback->funcs.decode(&substream, field, &callback->arg)) {
  ------------------
  |  Branch (816:21): [True: 0, False: 0]
  ------------------
  817|      0|                    PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "submsg callback failed");
  ------------------
  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  Branch (926:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  818|      0|                    return false;
  819|      0|                }
  820|      0|            }
  821|      0|        }
  822|       |        
  823|  1.57k|        do
  824|  1.57k|        {
  825|  1.57k|            prev_bytes_left = substream.bytes_left;
  826|  1.57k|            if (!field->descriptor->field_callback(&substream, NULL, field))
  ------------------
  |  Branch (826:17): [True: 0, False: 1.57k]
  ------------------
  827|      0|            {
  828|      0|                PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "callback failed");
  ------------------
  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  Branch (926:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  829|      0|                return false;
  830|      0|            }
  831|  1.57k|        } while (substream.bytes_left > 0 && substream.bytes_left < prev_bytes_left);
  ------------------
  |  Branch (831:18): [True: 540, False: 1.03k]
  |  Branch (831:46): [True: 0, False: 540]
  ------------------
  832|       |        
  833|  1.57k|        if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (833:13): [True: 0, False: 1.57k]
  ------------------
  834|      0|            return false;
  835|       |
  836|  1.57k|        return true;
  837|  1.57k|    }
  838|  4.53k|    else
  839|  4.53k|    {
  840|       |        /* Copy the single scalar value to stack.
  841|       |         * This is required so that we can limit the stream length,
  842|       |         * which in turn allows to use same callback for packed and
  843|       |         * not-packed fields. */
  844|  4.53k|        pb_istream_t substream;
  845|  4.53k|        pb_byte_t buffer[10];
  846|  4.53k|        size_t size = sizeof(buffer);
  847|       |        
  848|  4.53k|        if (!read_raw_value(stream, wire_type, buffer, &size))
  ------------------
  |  Branch (848:13): [True: 49, False: 4.48k]
  ------------------
  849|     49|            return false;
  850|  4.48k|        substream = pb_istream_from_buffer(buffer, size);
  851|       |        
  852|       |        return field->descriptor->field_callback(&substream, NULL, field);
  853|  4.53k|    }
  854|  6.15k|}
pb_decode.c:read_raw_value:
  342|  4.53k|{
  343|  4.53k|    size_t max_size = *size;
  344|  4.53k|    switch (wire_type)
  345|  4.53k|    {
  346|  2.51k|        case PB_WT_VARINT:
  ------------------
  |  Branch (346:9): [True: 2.51k, False: 2.02k]
  ------------------
  347|  2.51k|            *size = 0;
  348|  2.51k|            do
  349|  4.19k|            {
  350|  4.19k|                (*size)++;
  351|  4.19k|                if (*size > max_size)
  ------------------
  |  Branch (351:21): [True: 4, False: 4.18k]
  ------------------
  352|      4|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  930|      4|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      4|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  353|       |
  354|  4.18k|                if (!pb_read(stream, buf, 1))
  ------------------
  |  Branch (354:21): [True: 27, False: 4.16k]
  ------------------
  355|     27|                    return false;
  356|  4.18k|            } while (*buf++ & 0x80);
  ------------------
  |  Branch (356:22): [True: 1.68k, False: 2.48k]
  ------------------
  357|  2.48k|            return true;
  358|       |            
  359|    952|        case PB_WT_64BIT:
  ------------------
  |  Branch (359:9): [True: 952, False: 3.57k]
  ------------------
  360|    952|            *size = 8;
  361|    952|            return pb_read(stream, buf, 8);
  362|       |        
  363|  1.06k|        case PB_WT_32BIT:
  ------------------
  |  Branch (363:9): [True: 1.06k, False: 3.46k]
  ------------------
  364|  1.06k|            *size = 4;
  365|  1.06k|            return pb_read(stream, buf, 4);
  366|       |        
  367|      0|        case PB_WT_STRING:
  ------------------
  |  Branch (367:9): [True: 0, False: 4.53k]
  ------------------
  368|       |            /* Calling read_raw_value with a PB_WT_STRING is an error.
  369|       |             * Explicitly handle this case and fallthrough to default to avoid
  370|       |             * compiler warnings.
  371|       |             */
  372|       |
  373|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (373:2): [True: 0, False: 4.53k]
  ------------------
  374|       |            /* Calling read_raw_value with a PB_WT_PACKED is an error.
  375|       |             * Explicitly handle this case and fallthrough to default to avoid
  376|       |             * compiler warnings.
  377|       |             */
  378|       |
  379|      5|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  930|      5|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      5|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (379:9): [True: 5, False: 4.52k]
  ------------------
  380|  4.53k|    }
  381|  4.53k|}
pb_decode.c:pb_release_single_field:
 1286|  1.13M|{
 1287|  1.13M|    pb_type_t type;
 1288|  1.13M|    type = field->type;
 1289|       |
 1290|  1.13M|    if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  1.13M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.13M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  1.13M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (1290:9): [True: 78.7k, False: 1.05M]
  ------------------
 1291|  78.7k|    {
 1292|  78.7k|        if (*(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (1292:13): [True: 61.0k, False: 17.7k]
  ------------------
 1293|  61.0k|            return; /* This is not the current field in the union */
 1294|  78.7k|    }
 1295|       |
 1296|       |    /* Release anything contained inside an extension or submsg.
 1297|       |     * This has to be done even if the submsg itself is statically
 1298|       |     * allocated. */
 1299|  1.07M|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  1.07M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.07M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  1.07M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1299:9): [True: 8.98k, False: 1.06M]
  ------------------
 1300|  8.98k|    {
 1301|       |        /* Release fields from all extensions in the linked list */
 1302|  8.98k|        pb_extension_t *ext = *(pb_extension_t**)field->pData;
 1303|  16.2k|        while (ext != NULL)
  ------------------
  |  Branch (1303:16): [True: 7.31k, False: 8.98k]
  ------------------
 1304|  7.31k|        {
 1305|  7.31k|            pb_field_iter_t ext_iter;
 1306|  7.31k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (1306:17): [True: 7.31k, False: 0]
  ------------------
 1307|  7.31k|            {
 1308|  7.31k|                pb_release_single_field(&ext_iter);
 1309|  7.31k|            }
 1310|  7.31k|            ext = ext->next;
 1311|  7.31k|        }
 1312|  8.98k|    }
 1313|  1.06M|    else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  329|  2.12M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  1.06M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.06M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  2.12M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 135k, False: 928k]
  |  |  ------------------
  |  |  330|  2.12M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|   928k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   928k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|   928k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 928k]
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|   135k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   135k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|   135k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1313:42): [True: 133k, False: 1.87k]
  ------------------
 1314|   133k|    {
 1315|       |        /* Release fields in submessage or submsg array */
 1316|   133k|        pb_size_t count = 1;
 1317|       |        
 1318|   133k|        if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   133k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   133k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   133k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1318:13): [True: 123k, False: 10.1k]
  ------------------
 1319|   123k|        {
 1320|   123k|            field->pData = *(void**)field->pField;
 1321|   123k|        }
 1322|  10.1k|        else
 1323|  10.1k|        {
 1324|  10.1k|            field->pData = field->pField;
 1325|  10.1k|        }
 1326|       |        
 1327|   133k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   133k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   133k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   133k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1327:13): [True: 17.9k, False: 115k]
  ------------------
 1328|  17.9k|        {
 1329|  17.9k|            count = *(pb_size_t*)field->pSize;
 1330|       |
 1331|  17.9k|            if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  326|  17.9k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  17.9k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  321|  35.9k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1331:17): [True: 0, False: 17.9k]
  |  Branch (1331:54): [True: 0, False: 0]
  ------------------
 1332|      0|            {
 1333|       |                /* Protect against corrupted _count fields */
 1334|      0|                count = field->array_size;
 1335|      0|            }
 1336|  17.9k|        }
 1337|       |        
 1338|   133k|        if (field->pData)
  ------------------
  |  Branch (1338:13): [True: 88.4k, False: 45.2k]
  ------------------
 1339|  88.4k|        {
 1340|   262k|            for (; count > 0; count--)
  ------------------
  |  Branch (1340:20): [True: 173k, False: 88.4k]
  ------------------
 1341|   173k|            {
 1342|   173k|                pb_release(field->submsg_desc, field->pData);
 1343|   173k|                field->pData = (char*)field->pData + field->data_size;
 1344|   173k|            }
 1345|  88.4k|        }
 1346|   133k|    }
 1347|       |    
 1348|  1.07M|    if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  1.07M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  1.07M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  1.07M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1348:9): [True: 1.04M, False: 30.6k]
  ------------------
 1349|  1.04M|    {
 1350|  1.04M|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  327|  1.04M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.04M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  314|  2.08M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1350:13): [True: 188k, False: 853k]
  ------------------
 1351|   188k|            (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|   188k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   188k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|   377k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (1351:14): [True: 8.98k, False: 179k]
  ------------------
 1352|   179k|             PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  328|   179k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   179k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                           PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  280|   179k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (1352:14): [True: 8.98k, False: 170k]
  ------------------
 1353|  17.9k|        {
 1354|       |            /* Release entries in repeated string or bytes array */
 1355|  17.9k|            void **pItem = *(void***)field->pField;
 1356|  17.9k|            pb_size_t count = *(pb_size_t*)field->pSize;
 1357|   687k|            for (; count > 0; count--)
  ------------------
  |  Branch (1357:20): [True: 669k, False: 17.9k]
  ------------------
 1358|   669k|            {
 1359|   669k|                pb_free(*pItem);
  ------------------
  |  |    4|   669k|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1360|   669k|                *pItem++ = NULL;
 1361|   669k|            }
 1362|  17.9k|        }
 1363|       |        
 1364|  1.04M|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|  1.04M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.04M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|  1.04M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1364:13): [True: 188k, False: 853k]
  ------------------
 1365|   188k|        {
 1366|       |            /* We are going to release the array, so set the size to 0 */
 1367|   188k|            *(pb_size_t*)field->pSize = 0;
 1368|   188k|        }
 1369|       |        
 1370|       |        /* Release main pointer */
 1371|  1.04M|        pb_free(*(void**)field->pField);
  ------------------
  |  |    4|  1.04M|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1372|       |        *(void**)field->pField = NULL;
 1373|  1.04M|    }
 1374|  1.07M|}

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

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

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

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

validate_static:
    7|  19.2k|{
    8|  19.2k|    pb_size_t count = 1;
    9|  19.2k|    pb_size_t i;
   10|  19.2k|    bool truebool = true;
   11|  19.2k|    bool falsebool = false;
   12|       |
   13|  19.2k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  327|  19.2k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  19.2k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  314|  38.5k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 0, False: 19.2k]
  |  Branch (13:54): [True: 0, False: 0]
  ------------------
   14|      0|    {
   15|       |        /* Array count must be between 0 and statically allocated size */
   16|      0|        count = *(pb_size_t*)iter->pSize;
   17|      0|        assert(count <= iter->array_size);
  ------------------
  |  Branch (17:9): [True: 0, False: 0]
  |  Branch (17:9): [True: 0, False: 0]
  ------------------
   18|      0|    }
   19|  19.2k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  327|  19.2k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  19.2k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  312|  38.5k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 0, False: 19.2k]
  |  Branch (19:59): [True: 0, False: 0]
  ------------------
   20|      0|    {
   21|       |        /* Boolean has_ field must have a valid value */
   22|      0|        assert(memcmp(iter->pSize, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (22:9): [True: 0, False: 0]
  |  Branch (22:9): [True: 0, False: 0]
  |  Branch (22:9): [True: 0, False: 0]
  |  Branch (22:9): [True: 0, False: 0]
  ------------------
   23|      0|               memcmp(iter->pSize, &falsebool, sizeof(bool)) == 0);
   24|      0|    }
   25|  19.2k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  19.2k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  19.2k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  19.2k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 19.2k, False: 0]
  ------------------
   26|  19.2k|    {
   27|  19.2k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 18.8k, False: 438]
  ------------------
   28|  18.8k|        {
   29|       |            /* Some different field in oneof */
   30|  18.8k|            return;
   31|  18.8k|        }
   32|  19.2k|    }
   33|       |
   34|    876|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 438, False: 438]
  ------------------
   35|    438|    {
   36|    438|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|    438|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  328|    438|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|    438|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  284|    438|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 0, False: 438]
  ------------------
   39|      0|        {
   40|       |            /* String length must be at most statically allocated size */
   41|      0|            assert(strlen(pData) + 1 <= iter->data_size);
  ------------------
  |  Branch (41:13): [True: 0, False: 0]
  |  Branch (41:13): [True: 0, False: 0]
  ------------------
   42|      0|        }
   43|    438|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|    438|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|    438|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|    438|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 0, False: 438]
  ------------------
   44|      0|        {
   45|       |            /* Bytes length must be at most statically allocated size */
   46|      0|            pb_bytes_array_t *bytes = pData;
   47|      0|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= iter->data_size);
  ------------------
  |  Branch (47:13): [True: 0, False: 0]
  |  Branch (47:13): [True: 0, False: 0]
  |  Branch (47:13): [True: 0, False: 0]
  |  Branch (47:13): [True: 0, False: 0]
  ------------------
   48|      0|        }
   49|    438|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  328|    438|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|    438|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  268|    438|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 0, False: 438]
  ------------------
   50|      0|        {
   51|       |            /* Bool fields must have valid value */
   52|      0|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (52:13): [True: 0, False: 0]
  |  Branch (52:13): [True: 0, False: 0]
  |  Branch (52:13): [True: 0, False: 0]
  |  Branch (52:13): [True: 0, False: 0]
  ------------------
   53|      0|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
   54|      0|        }
   55|    438|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  329|    438|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|    438|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|    438|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|    876|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 360, False: 78]
  |  |  ------------------
  |  |  330|    438|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|     78|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|     78|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|     78|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 78]
  |  |  ------------------
  ------------------
   56|    360|        {
   57|    360|            validate_message(pData, 0, iter->submsg_desc);
   58|    360|        }
   59|    438|    }
   60|    438|}
validate_pointer:
   63|   725k|{
   64|   725k|    pb_size_t count = 1;
   65|   725k|    pb_size_t i;
   66|   725k|    bool truebool = true;
   67|   725k|    bool falsebool = false;
   68|       |
   69|   725k|    if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   725k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   725k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   725k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (69:9): [True: 12.8k, False: 712k]
  ------------------
   70|  12.8k|    {
   71|  12.8k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (71:13): [True: 12.3k, False: 537]
  ------------------
   72|  12.3k|        {
   73|       |            /* Some different field in oneof */
   74|  12.3k|            return;
   75|  12.3k|        }
   76|  12.8k|    }
   77|   712k|    else if (!iter->pData)
  ------------------
  |  Branch (77:14): [True: 297k, False: 415k]
  ------------------
   78|   297k|    {
   79|       |        /* Nothing allocated */
   80|   297k|        if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize != &iter->array_size)
  ------------------
  |  |  327|   297k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   297k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize != &iter->array_size)
  ------------------
  |  |  314|   594k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (80:13): [True: 122k, False: 175k]
  |  Branch (80:58): [True: 109k, False: 12.2k]
  ------------------
   81|   109k|        {
   82|   109k|            assert(*(pb_size_t*)iter->pSize == 0);
  ------------------
  |  Branch (82:13): [True: 0, False: 109k]
  |  Branch (82:13): [True: 109k, False: 0]
  ------------------
   83|   109k|        }
   84|   297k|        return;
   85|   297k|    }
   86|       |
   87|   415k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   415k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   415k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   415k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (87:9): [True: 12.8k, False: 403k]
  ------------------
   88|  12.8k|    {
   89|       |        /* Check that enough memory has been allocated for array */
   90|  12.8k|        size_t allocated_size = get_allocation_size(iter->pData);
   91|  12.8k|        count = *(pb_size_t*)iter->pSize;
   92|  12.8k|        assert(allocated_size >= count * iter->data_size);
  ------------------
  |  Branch (92:9): [True: 0, False: 12.8k]
  |  Branch (92:9): [True: 12.8k, False: 0]
  ------------------
   93|  12.8k|    }
   94|   403k|    else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  328|   403k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   403k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  284|   806k|#define PB_LTYPE_STRING 0x07U
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  328|   336k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   336k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  280|   336k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (94:14): [True: 336k, False: 66.7k]
  |  Branch (94:57): [True: 329k, False: 7.21k]
  ------------------
   95|   329k|    {
   96|   329k|        size_t allocated_size = get_allocation_size(iter->pData);
   97|   329k|        assert(allocated_size >= iter->data_size);
  ------------------
  |  Branch (97:9): [True: 0, False: 329k]
  |  Branch (97:9): [True: 329k, False: 0]
  ------------------
   98|   329k|    }
   99|       |
  100|  39.8M|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (100:17): [True: 39.4M, False: 415k]
  ------------------
  101|  39.4M|    {
  102|  39.4M|        void *pData = (char*)iter->pData + iter->data_size * i;
  103|       |
  104|  39.4M|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  328|  39.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  39.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  284|  39.4M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (104:13): [True: 88.1k, False: 39.3M]
  ------------------
  105|  88.1k|        {
  106|       |            /* Check that enough memory is allocated for string and that
  107|       |               the string is properly terminated. */
  108|  88.1k|            const char *str = pData;
  109|       |
  110|  88.1k|            if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|  88.1k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  88.1k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|  88.1k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (110:17): [True: 21.4k, False: 66.7k]
  ------------------
  111|  21.4k|            {
  112|       |                /* String arrays are stored as array of pointers */
  113|  21.4k|                str = ((const char**)iter->pData)[i];
  114|  21.4k|            }
  115|       |
  116|  88.1k|            assert(strlen(str) + 1 <= get_allocation_size(str));
  ------------------
  |  Branch (116:13): [True: 0, False: 88.1k]
  |  Branch (116:13): [True: 88.1k, False: 0]
  ------------------
  117|  88.1k|        }
  118|  39.3M|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|  39.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  39.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|  39.3M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (118:18): [True: 496k, False: 38.8M]
  ------------------
  119|   496k|        {
  120|       |            /* Bytes length must be at most statically allocated size */
  121|   496k|            const pb_bytes_array_t *bytes = pData;
  122|       |
  123|   496k|            if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   496k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   496k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   496k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (123:17): [True: 489k, False: 7.21k]
  ------------------
  124|   489k|            {
  125|       |                /* Bytes arrays are stored as array of pointers */
  126|   489k|                bytes = ((const pb_bytes_array_t**)iter->pData)[i];
  127|   489k|            }
  128|       |
  129|   496k|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= get_allocation_size(bytes));
  ------------------
  |  Branch (129:13): [True: 0, False: 496k]
  |  Branch (129:13): [True: 0, False: 496k]
  |  Branch (129:13): [True: 489k, False: 7.01k]
  |  Branch (129:13): [True: 496k, False: 0]
  ------------------
  130|   496k|        }
  131|  38.8M|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  328|  38.8M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  38.8M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  268|  38.8M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (131:18): [True: 1.00M, False: 37.8M]
  ------------------
  132|  1.00M|        {
  133|       |            /* Bool fields must have valid value */
  134|  1.00M|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (134:13): [True: 1.00M, False: 0]
  |  Branch (134:13): [True: 0, False: 0]
  |  Branch (134:13): [True: 198k, False: 802k]
  |  Branch (134:13): [True: 802k, False: 0]
  ------------------
  135|  1.00M|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
  136|  1.00M|        }
  137|  37.8M|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  329|  37.8M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  37.8M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  37.8M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  75.7M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 118k, False: 37.7M]
  |  |  ------------------
  |  |  330|  37.8M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  37.7M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  37.7M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  37.7M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 37.7M]
  |  |  ------------------
  ------------------
  138|   118k|        {
  139|   118k|            validate_message(pData, 0, iter->submsg_desc);
  140|   118k|        }
  141|  39.4M|    }
  142|   415k|}
validate_message:
  145|   125k|{
  146|   125k|    pb_field_iter_t iter;
  147|       |
  148|   125k|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 85.6k, False: 39.5k]
  ------------------
  149|  85.6k|    {
  150|  85.6k|        do
  151|   764k|        {
  152|   764k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|   764k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   764k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|   764k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 19.2k, False: 744k]
  ------------------
  153|  19.2k|            {
  154|  19.2k|                validate_static(&iter);
  155|  19.2k|            }
  156|   744k|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   744k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   744k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   744k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 725k, False: 19.2k]
  ------------------
  157|   725k|            {
  158|   725k|                validate_pointer(&iter);
  159|   725k|            }
  160|   764k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 678k, False: 85.6k]
  ------------------
  161|  85.6k|    }
  162|   125k|}

