pb_field_iter_begin:
  157|   731k|{
  158|   731k|    memset(iter, 0, sizeof(*iter));
  159|       |
  160|   731k|    iter->descriptor = desc;
  161|   731k|    iter->message = message;
  162|       |
  163|   731k|    return load_descriptor_values(iter);
  164|   731k|}
pb_field_iter_begin_extension:
  167|  95.0k|{
  168|  95.0k|    const pb_msgdesc_t *msg = (const pb_msgdesc_t*)extension->type->arg;
  169|  95.0k|    bool status;
  170|       |
  171|  95.0k|    uint32_t word0 = PB_PROGMEM_READU32(msg->field_info[0]);
  ------------------
  |  |  184|  95.0k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  172|  95.0k|    if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  95.0k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  95.0k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  95.0k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (172:9): [True: 0, False: 95.0k]
  ------------------
  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|  95.0k|    else
  180|  95.0k|    {
  181|  95.0k|        status = pb_field_iter_begin(iter, msg, extension->dest);
  182|  95.0k|    }
  183|       |
  184|  95.0k|    iter->pSize = &extension->found;
  185|  95.0k|    return status;
  186|  95.0k|}
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.4M|{
  197|  32.4M|    if (iter->tag == tag)
  ------------------
  |  Branch (197:9): [True: 31.2M, False: 1.21M]
  ------------------
  198|  31.2M|    {
  199|  31.2M|        return true; /* Nothing to do, correct field already. */
  200|  31.2M|    }
  201|  1.21M|    else if (tag > iter->descriptor->largest_tag)
  ------------------
  |  Branch (201:14): [True: 270k, False: 946k]
  ------------------
  202|   270k|    {
  203|   270k|        return false;
  204|   270k|    }
  205|   946k|    else
  206|   946k|    {
  207|   946k|        pb_size_t start = iter->index;
  208|   946k|        uint32_t fieldinfo;
  209|       |
  210|   946k|        if (tag < iter->tag)
  ------------------
  |  Branch (210:13): [True: 224k, False: 722k]
  ------------------
  211|   224k|        {
  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|   224k|            iter->index = iter->descriptor->field_count;
  216|   224k|        }
  217|       |
  218|   946k|        do
  219|  10.3M|        {
  220|       |            /* Advance iterator but don't load values yet */
  221|  10.3M|            advance_iterator(iter);
  222|       |
  223|       |            /* Do fast check for tag number match */
  224|  10.3M|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  184|  10.3M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  225|       |
  226|  10.3M|            if (((fieldinfo >> 2) & 0x3F) == (tag & 0x3F))
  ------------------
  |  Branch (226:17): [True: 976k, False: 9.33M]
  ------------------
  227|   976k|            {
  228|       |                /* Good candidate, check further */
  229|   976k|                (void)load_descriptor_values(iter);
  230|       |
  231|   976k|                if (iter->tag == tag &&
  ------------------
  |  Branch (231:21): [True: 880k, False: 95.8k]
  ------------------
  232|   880k|                    PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|   880k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   880k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                                  PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|   880k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (232:21): [True: 877k, False: 3.61k]
  ------------------
  233|   877k|                {
  234|       |                    /* Found it */
  235|   877k|                    return true;
  236|   877k|                }
  237|   976k|            }
  238|  10.3M|        } while (iter->index != start);
  ------------------
  |  Branch (238:18): [True: 9.35M, False: 69.8k]
  ------------------
  239|       |
  240|       |        /* Searched all the way back to start, and found nothing. */
  241|  69.8k|        (void)load_descriptor_values(iter);
  242|       |        return false;
  243|   946k|    }
  244|  32.4M|}
pb_field_iter_find_extension:
  247|  9.49k|{
  248|  9.49k|    if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|  9.49k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  9.49k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|  9.49k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (248:9): [True: 0, False: 9.49k]
  ------------------
  249|      0|    {
  250|      0|        return true;
  251|      0|    }
  252|  9.49k|    else
  253|  9.49k|    {
  254|  9.49k|        pb_size_t start = iter->index;
  255|  9.49k|        uint32_t fieldinfo;
  256|       |
  257|  9.49k|        do
  258|   133k|        {
  259|       |            /* Advance iterator but don't load values yet */
  260|   133k|            advance_iterator(iter);
  261|       |
  262|       |            /* Do fast check for field type */
  263|   133k|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  184|   133k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  264|       |
  265|   133k|            if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|   133k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   133k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|   133k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (265:17): [True: 3.94k, False: 129k]
  ------------------
  266|  3.94k|            {
  267|  3.94k|                return load_descriptor_values(iter);
  268|  3.94k|            }
  269|   133k|        } while (iter->index != start);
  ------------------
  |  Branch (269:18): [True: 123k, False: 5.54k]
  ------------------
  270|       |
  271|       |        /* Searched all the way back to start, and found nothing. */
  272|  5.54k|        (void)load_descriptor_values(iter);
  273|       |        return false;
  274|  9.49k|    }
  275|  9.49k|}
pb_field_iter_begin_const:
  291|   231k|{
  292|   231k|    return pb_field_iter_begin(iter, desc, pb_const_cast(message));
  293|   231k|}
pb_field_iter_begin_extension_const:
  296|  3.03k|{
  297|  3.03k|    return pb_field_iter_begin_extension(iter, (pb_extension_t*)pb_const_cast(extension));
  298|  3.03k|}
pb_default_field_callback:
  301|  5.93k|{
  302|  5.93k|    if (field->data_size == sizeof(pb_callback_t))
  ------------------
  |  Branch (302:9): [True: 5.93k, False: 0]
  ------------------
  303|  5.93k|    {
  304|  5.93k|        pb_callback_t *pCallback = (pb_callback_t*)field->pData;
  305|       |
  306|  5.93k|        if (pCallback != NULL)
  ------------------
  |  Branch (306:13): [True: 5.93k, False: 0]
  ------------------
  307|  5.93k|        {
  308|  5.93k|            if (istream != NULL && pCallback->funcs.decode != NULL)
  ------------------
  |  Branch (308:17): [True: 5.80k, False: 133]
  |  Branch (308:36): [True: 0, False: 5.80k]
  ------------------
  309|      0|            {
  310|      0|                return pCallback->funcs.decode(istream, field, &pCallback->arg);
  311|      0|            }
  312|       |
  313|  5.93k|            if (ostream != NULL && pCallback->funcs.encode != NULL)
  ------------------
  |  Branch (313:17): [True: 133, False: 5.80k]
  |  Branch (313:36): [True: 0, False: 133]
  ------------------
  314|      0|            {
  315|      0|                return pCallback->funcs.encode(ostream, field, &pCallback->arg);
  316|      0|            }
  317|  5.93k|        }
  318|  5.93k|    }
  319|       |
  320|  5.93k|    return true; /* Success, but didn't do anything */
  321|       |
  322|  5.93k|}
pb_common.c:load_descriptor_values:
    9|  5.18M|{
   10|  5.18M|    uint32_t word0;
   11|  5.18M|    uint32_t data_offset;
   12|  5.18M|    int_least8_t size_offset;
   13|       |
   14|  5.18M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (14:9): [True: 240k, False: 4.94M]
  ------------------
   15|   240k|        return false;
   16|       |
   17|  4.94M|    word0 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  184|  4.94M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   18|  4.94M|    iter->type = (pb_type_t)((word0 >> 8) & 0xFF);
   19|       |
   20|  4.94M|    switch(word0 & 3)
   21|  4.94M|    {
   22|   856k|        case 0: {
  ------------------
  |  Branch (22:9): [True: 856k, False: 4.08M]
  ------------------
   23|       |            /* 1-word format */
   24|   856k|            iter->array_size = 1;
   25|   856k|            iter->tag = (pb_size_t)((word0 >> 2) & 0x3F);
   26|   856k|            size_offset = (int_least8_t)((word0 >> 24) & 0x0F);
   27|   856k|            data_offset = (word0 >> 16) & 0xFF;
   28|   856k|            iter->data_size = (pb_size_t)((word0 >> 28) & 0x0F);
   29|   856k|            break;
   30|      0|        }
   31|       |
   32|  3.40M|        case 1: {
  ------------------
  |  Branch (32:9): [True: 3.40M, False: 1.54M]
  ------------------
   33|       |            /* 2-word format */
   34|  3.40M|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  184|  3.40M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   35|       |
   36|  3.40M|            iter->array_size = (pb_size_t)((word0 >> 16) & 0x0FFF);
   37|  3.40M|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 28) << 6));
   38|  3.40M|            size_offset = (int_least8_t)((word0 >> 28) & 0x0F);
   39|  3.40M|            data_offset = word1 & 0xFFFF;
   40|  3.40M|            iter->data_size = (pb_size_t)((word1 >> 16) & 0x0FFF);
   41|  3.40M|            break;
   42|      0|        }
   43|       |
   44|   513k|        case 2: {
  ------------------
  |  Branch (44:9): [True: 513k, False: 4.43M]
  ------------------
   45|       |            /* 4-word format */
   46|   513k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  184|   513k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   47|   513k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  184|   513k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   48|   513k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  184|   513k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   49|       |
   50|   513k|            iter->array_size = (pb_size_t)(word0 >> 16);
   51|   513k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   52|   513k|            size_offset = (int_least8_t)(word1 & 0xFF);
   53|   513k|            data_offset = word2;
   54|   513k|            iter->data_size = (pb_size_t)word3;
   55|   513k|            break;
   56|      0|        }
   57|       |
   58|   174k|        default: {
  ------------------
  |  Branch (58:9): [True: 174k, False: 4.77M]
  ------------------
   59|       |            /* 8-word format */
   60|   174k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  184|   174k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   61|   174k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  184|   174k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   62|   174k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  184|   174k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   63|   174k|            uint32_t word4 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 4]);
  ------------------
  |  |  184|   174k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   64|       |
   65|   174k|            iter->array_size = (pb_size_t)word4;
   66|   174k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   67|   174k|            size_offset = (int_least8_t)(word1 & 0xFF);
   68|   174k|            data_offset = word2;
   69|   174k|            iter->data_size = (pb_size_t)word3;
   70|   174k|            break;
   71|      0|        }
   72|  4.94M|    }
   73|       |
   74|  4.94M|    if (!iter->message)
  ------------------
  |  Branch (74:9): [True: 0, False: 4.94M]
  ------------------
   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.94M|    else
   81|  4.94M|    {
   82|  4.94M|        iter->pField = (char*)iter->message + data_offset;
   83|       |
   84|  4.94M|        if (size_offset)
  ------------------
  |  Branch (84:13): [True: 956k, False: 3.98M]
  ------------------
   85|   956k|        {
   86|   956k|            iter->pSize = (char*)iter->pField - size_offset;
   87|   956k|        }
   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: 60.3k, False: 3.92M]
  ------------------
   89|  60.3k|                 (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  326|  60.3k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  60.3k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                               (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  321|   120k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (89:19): [True: 0, False: 60.3k]
  ------------------
   90|  60.3k|                  PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  326|  60.3k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  60.3k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                                PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  322|  60.3k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (90:19): [True: 60.3k, False: 0]
  ------------------
   91|  60.3k|        {
   92|       |            /* Fixed count array */
   93|  60.3k|            iter->pSize = &iter->array_size;
   94|  60.3k|        }
   95|  3.92M|        else
   96|  3.92M|        {
   97|  3.92M|            iter->pSize = NULL;
   98|  3.92M|        }
   99|       |
  100|  4.94M|        if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  326|  4.94M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  4.94M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  322|  9.89M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (100:13): [True: 4.60M, False: 340k]
  |  Branch (100:57): [True: 4.60M, False: 0]
  ------------------
  101|  4.60M|        {
  102|  4.60M|            iter->pData = *(void**)iter->pField;
  103|  4.60M|        }
  104|   340k|        else
  105|   340k|        {
  106|   340k|            iter->pData = iter->pField;
  107|   340k|        }
  108|  4.94M|    }
  109|       |
  110|  4.94M|    if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  329|  4.94M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  4.94M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  4.94M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  9.89M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 622k, False: 4.32M]
  |  |  ------------------
  |  |  330|  4.94M|                               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|   622k|    {
  112|   622k|        iter->submsg_desc = iter->descriptor->submsg_info[iter->submessage_index];
  113|   622k|    }
  114|  4.32M|    else
  115|  4.32M|    {
  116|  4.32M|        iter->submsg_desc = NULL;
  117|  4.32M|    }
  118|       |
  119|       |    return true;
  120|  4.94M|}
pb_common.c:advance_iterator:
  123|  13.8M|{
  124|  13.8M|    iter->index++;
  125|       |
  126|  13.8M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (126:9): [True: 692k, False: 13.1M]
  ------------------
  127|   692k|    {
  128|       |        /* Restart */
  129|   692k|        iter->index = 0;
  130|   692k|        iter->field_info_index = 0;
  131|   692k|        iter->submessage_index = 0;
  132|   692k|        iter->required_field_index = 0;
  133|   692k|    }
  134|  13.1M|    else
  135|  13.1M|    {
  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.1M|        uint32_t prev_descriptor = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  184|  13.1M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  143|  13.1M|        pb_type_t prev_type = (prev_descriptor >> 8) & 0xFF;
  144|  13.1M|        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.1M|        iter->field_info_index = (pb_size_t)(iter->field_info_index + descriptor_len);
  151|  13.1M|        iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  327|  13.1M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  13.1M|#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.1M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  152|  13.1M|        iter->submessage_index = (pb_size_t)(iter->submessage_index + PB_LTYPE_IS_SUBMSG(prev_type));
  ------------------
  |  |  329|  13.1M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  13.1M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  13.1M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  26.2M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 1.88M, False: 11.2M]
  |  |  ------------------
  |  |  330|  13.1M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  11.2M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  11.2M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  11.2M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 11.2M]
  |  |  ------------------
  ------------------
  153|  13.1M|    }
  154|  13.8M|}
pb_common.c:pb_const_cast:
  278|   235k|{
  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|   235k|    union {
  283|   235k|        void *p1;
  284|   235k|        const void *p2;
  285|   235k|    } t;
  286|   235k|    t.p2 = p;
  287|   235k|    return t.p1;
  288|   235k|}

pb_read:
   82|  2.51M|{
   83|  2.51M|    if (count == 0)
  ------------------
  |  Branch (83:9): [True: 749k, False: 1.76M]
  ------------------
   84|   749k|        return true;
   85|       |
   86|  1.76M|#ifndef PB_BUFFER_ONLY
   87|  1.76M|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (87:6): [True: 97.6k, False: 1.67M]
  |  Branch (87:21): [True: 32.2k, False: 65.3k]
  ------------------
   88|  32.2k|	{
   89|       |		/* Skip input bytes */
   90|  32.2k|		pb_byte_t tmp[16];
   91|   176k|		while (count > 16)
  ------------------
  |  Branch (91:10): [True: 144k, False: 32.2k]
  ------------------
   92|   144k|		{
   93|   144k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (93:8): [True: 0, False: 144k]
  ------------------
   94|      0|				return false;
   95|       |			
   96|   144k|			count -= 16;
   97|   144k|		}
   98|       |		
   99|  32.2k|		return pb_read(stream, tmp, count);
  100|  32.2k|	}
  101|  1.73M|#endif
  102|       |
  103|  1.73M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (103:9): [True: 267, False: 1.73M]
  ------------------
  104|    267|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  930|    267|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    267|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 267]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  105|       |    
  106|  1.73M|#ifndef PB_BUFFER_ONLY
  107|  1.73M|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:9): [True: 0, False: 1.73M]
  ------------------
  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.73M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (114:9): [True: 0, False: 1.73M]
  ------------------
  115|      0|        stream->bytes_left = 0;
  116|  1.73M|    else
  117|  1.73M|        stream->bytes_left -= count;
  118|       |
  119|       |    return true;
  120|  1.73M|}
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.3M|{
  176|  66.3M|    pb_byte_t byte;
  177|  66.3M|    uint32_t result;
  178|       |    
  179|  66.3M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (179:9): [True: 1.92k, False: 66.3M]
  ------------------
  180|  1.92k|    {
  181|  1.92k|        return false;
  182|  1.92k|    }
  183|       |    
  184|  66.3M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (184:9): [True: 35.4M, False: 30.9M]
  ------------------
  185|  35.4M|    {
  186|       |        /* Quick case, 1 byte value */
  187|  35.4M|        result = byte;
  188|  35.4M|    }
  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: 45, False: 31.0M]
  ------------------
  198|     45|                return false;
  199|       |            
  200|  31.0M|            if (bitpos >= 32)
  ------------------
  |  Branch (200:17): [True: 7.49k, False: 31.0M]
  ------------------
  201|  7.49k|            {
  202|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  203|  7.49k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (203:44): [True: 7.32k, False: 171]
  ------------------
  204|  7.49k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (204:41): [True: 3.91k, False: 3.58k]
  ------------------
  205|  3.58k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (205:27): [True: 3.56k, False: 19]
  |  Branch (205:50): [True: 3.49k, False: 66]
  ------------------
  206|       |
  207|  7.49k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (207:21): [True: 2, False: 7.49k]
  |  Branch (207:37): [True: 85, False: 7.41k]
  ------------------
  208|     87|                {
  209|     87|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  210|     87|                }
  211|  7.49k|            }
  212|  31.0M|            else if (bitpos == 28)
  ------------------
  |  Branch (212:22): [True: 11.1k, False: 30.9M]
  ------------------
  213|  11.1k|            {
  214|  11.1k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (214:21): [True: 6.92k, False: 4.18k]
  |  Branch (214:43): [True: 36, False: 6.88k]
  ------------------
  215|     36|                {
  216|     36|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  930|     36|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     36|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 36]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|     36|                }
  218|  11.0k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  219|  11.0k|            }
  220|  30.9M|            else
  221|  30.9M|            {
  222|  30.9M|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  223|  30.9M|            }
  224|  31.0M|            bitpos = (uint_fast8_t)(bitpos + 7);
  225|  31.0M|        } while (byte & 0x80);
  ------------------
  |  Branch (225:18): [True: 114k, False: 30.9M]
  ------------------
  226|  30.9M|   }
  227|       |   
  228|  66.3M|   *dest = result;
  229|       |   return true;
  230|  66.3M|}
pb_decode_varint:
  234|  9.31M|{
  235|  9.31M|    pb_byte_t byte;
  236|  9.31M|    uint_fast8_t bitpos = 0;
  237|  9.31M|    uint64_t result = 0;
  238|       |    
  239|  9.31M|    do
  240|  16.2M|    {
  241|  16.2M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (241:13): [True: 92, False: 16.2M]
  ------------------
  242|     92|            return false;
  243|       |
  244|  16.2M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (244:13): [True: 72.7k, False: 16.1M]
  |  Branch (244:29): [True: 40, False: 72.7k]
  ------------------
  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|  16.2M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  248|  16.2M|        bitpos = (uint_fast8_t)(bitpos + 7);
  249|  16.2M|    } while (byte & 0x80);
  ------------------
  |  Branch (249:14): [True: 6.92M, False: 9.31M]
  ------------------
  250|       |    
  251|  9.31M|    *dest = result;
  252|       |    return true;
  253|  9.31M|}
pb_decode_tag:
  282|  32.6M|{
  283|  32.6M|    uint32_t temp;
  284|  32.6M|    *eof = false;
  285|  32.6M|    *wire_type = (pb_wire_type_t) 0;
  286|  32.6M|    *tag = 0;
  287|       |
  288|  32.6M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (288:9): [True: 197k, False: 32.4M]
  ------------------
  289|   197k|    {
  290|   197k|        *eof = true;
  291|   197k|        return false;
  292|   197k|    }
  293|       |
  294|  32.4M|    if (!pb_decode_varint32(stream, &temp))
  ------------------
  |  Branch (294:9): [True: 1.80k, False: 32.4M]
  ------------------
  295|  1.80k|    {
  296|  1.80k|#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.80k|        if (stream->callback != buf_read && stream->bytes_left == 0)
  ------------------
  |  Branch (304:13): [True: 1.69k, False: 102]
  |  Branch (304:45): [True: 1.69k, False: 0]
  ------------------
  305|  1.69k|        {
  306|  1.69k|#ifndef PB_NO_ERRMSG
  307|  1.69k|            if (strcmp(stream->errmsg, "io error") == 0)
  ------------------
  |  Branch (307:17): [True: 1.69k, False: 0]
  ------------------
  308|  1.69k|                stream->errmsg = NULL;
  309|  1.69k|#endif
  310|  1.69k|            *eof = true;
  311|  1.69k|        }
  312|  1.80k|#endif
  313|  1.80k|        return false;
  314|  1.80k|    }
  315|       |    
  316|  32.4M|    *tag = temp >> 3;
  317|  32.4M|    *wire_type = (pb_wire_type_t)(temp & 7);
  318|       |    return true;
  319|  32.4M|}
pb_skip_field:
  322|   338k|{
  323|   338k|    switch (wire_type)
  324|   338k|    {
  325|   122k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (325:9): [True: 122k, False: 215k]
  ------------------
  326|  10.9k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (326:9): [True: 10.9k, False: 327k]
  ------------------
  327|   157k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (327:9): [True: 157k, False: 181k]
  ------------------
  328|  47.2k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (328:9): [True: 47.2k, False: 290k]
  ------------------
  329|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (329:2): [True: 0, False: 338k]
  ------------------
  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|     94|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  930|     94|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     94|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 94]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (334:9): [True: 94, False: 338k]
  ------------------
  335|   338k|    }
  336|   338k|}
pb_make_string_substream:
  387|   278k|{
  388|   278k|    uint32_t size;
  389|   278k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (389:9): [True: 116, False: 278k]
  ------------------
  390|    116|        return false;
  391|       |    
  392|   278k|    *substream = *stream;
  393|   278k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (393:9): [True: 115, False: 278k]
  ------------------
  394|    115|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  930|    115|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    115|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 115]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|   278k|    substream->bytes_left = (size_t)size;
  403|   278k|    stream->bytes_left -= (size_t)size;
  404|       |    return true;
  405|   278k|}
pb_close_string_substream:
  408|   278k|{
  409|   278k|    if (substream->bytes_left) {
  ------------------
  |  Branch (409:9): [True: 725, False: 277k]
  ------------------
  410|    725|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (410:13): [True: 0, False: 725]
  ------------------
  411|      0|            return false;
  412|    725|    }
  413|       |
  414|   278k|    stream->state = substream->state;
  415|       |
  416|   278k|#ifndef PB_NO_ERRMSG
  417|   278k|    stream->errmsg = substream->errmsg;
  418|   278k|#endif
  419|       |    return true;
  420|   278k|}
pb_decode_ex:
 1222|  8.89k|{
 1223|  8.89k|    bool status;
 1224|       |
 1225|  8.89k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  123|  8.89k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1225:9): [True: 8.89k, False: 0]
  ------------------
 1226|  8.89k|    {
 1227|  8.89k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1228|  8.89k|    }
 1229|      0|    else
 1230|      0|    {
 1231|      0|      pb_istream_t substream;
 1232|      0|      if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1232:11): [True: 0, False: 0]
  ------------------
 1233|      0|        return false;
 1234|       |
 1235|      0|      status = pb_decode_inner(&substream, fields, dest_struct, flags);
 1236|       |
 1237|      0|      if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1237:11): [True: 0, False: 0]
  ------------------
 1238|      0|        status = false;
 1239|      0|    }
 1240|       |    
 1241|  8.89k|#ifdef PB_ENABLE_MALLOC
 1242|  8.89k|    if (!status)
  ------------------
  |  Branch (1242:9): [True: 2.33k, False: 6.55k]
  ------------------
 1243|  2.33k|        pb_release(fields, dest_struct);
 1244|  8.89k|#endif
 1245|       |    
 1246|  8.89k|    return status;
 1247|  8.89k|}
pb_decode:
 1250|  3.16k|{
 1251|  3.16k|    return pb_decode_ex(stream, fields, dest_struct, 0);
 1252|  3.16k|}
pb_release:
 1380|   203k|{
 1381|   203k|    pb_field_iter_t iter;
 1382|       |    
 1383|   203k|    if (!dest_struct)
  ------------------
  |  Branch (1383:9): [True: 0, False: 203k]
  ------------------
 1384|      0|        return; /* Ignore NULL pointers, similar to free() */
 1385|       |
 1386|   203k|    if (!pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1386:9): [True: 82.3k, False: 120k]
  ------------------
 1387|  82.3k|        return; /* Empty message type */
 1388|       |    
 1389|   120k|    do
 1390|  1.07M|    {
 1391|  1.07M|        pb_release_single_field(&iter);
 1392|  1.07M|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (1392:14): [True: 958k, False: 120k]
  ------------------
 1393|   120k|}
pb_decode_bool:
 1406|  3.21M|{
 1407|  3.21M|    uint32_t value;
 1408|  3.21M|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1408:9): [True: 72, False: 3.21M]
  ------------------
 1409|     72|        return false;
 1410|       |
 1411|  3.21M|    *(bool*)dest = (value != 0);
 1412|       |    return true;
 1413|  3.21M|}
pb_decode_svarint:
 1416|  3.63M|{
 1417|  3.63M|    pb_uint64_t value;
  ------------------
  |  |   57|  3.63M|#define pb_uint64_t uint64_t
  ------------------
 1418|  3.63M|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1418:9): [True: 45, False: 3.63M]
  ------------------
 1419|     45|        return false;
 1420|       |    
 1421|  3.63M|    if (value & 1)
  ------------------
  |  Branch (1421:9): [True: 522k, False: 3.11M]
  ------------------
 1422|   522k|        *dest = (pb_int64_t)(~(value >> 1));
 1423|  3.11M|    else
 1424|  3.11M|        *dest = (pb_int64_t)(value >> 1);
 1425|       |    
 1426|       |    return true;
 1427|  3.63M|}
pb_decode_fixed32:
 1430|   148k|{
 1431|   148k|    union {
 1432|   148k|        uint32_t fixed32;
 1433|   148k|        pb_byte_t bytes[4];
 1434|   148k|    } u;
 1435|       |
 1436|   148k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1436:9): [True: 19, False: 148k]
  ------------------
 1437|     19|        return false;
 1438|       |
 1439|   148k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1440|       |    /* fast path - if we know that we're on little endian, assign directly */
 1441|   148k|    *(uint32_t*)dest = u.fixed32;
 1442|       |#else
 1443|       |    *(uint32_t*)dest = ((uint32_t)u.bytes[0] << 0) |
 1444|       |                       ((uint32_t)u.bytes[1] << 8) |
 1445|       |                       ((uint32_t)u.bytes[2] << 16) |
 1446|       |                       ((uint32_t)u.bytes[3] << 24);
 1447|       |#endif
 1448|       |    return true;
 1449|   148k|}
pb_decode_fixed64:
 1453|  59.7k|{
 1454|  59.7k|    union {
 1455|  59.7k|        uint64_t fixed64;
 1456|  59.7k|        pb_byte_t bytes[8];
 1457|  59.7k|    } u;
 1458|       |
 1459|  59.7k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1459:9): [True: 21, False: 59.6k]
  ------------------
 1460|     21|        return false;
 1461|       |
 1462|  59.6k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1463|       |    /* fast path - if we know that we're on little endian, assign directly */
 1464|  59.6k|    *(uint64_t*)dest = u.fixed64;
 1465|       |#else
 1466|       |    *(uint64_t*)dest = ((uint64_t)u.bytes[0] << 0) |
 1467|       |                       ((uint64_t)u.bytes[1] << 8) |
 1468|       |                       ((uint64_t)u.bytes[2] << 16) |
 1469|       |                       ((uint64_t)u.bytes[3] << 24) |
 1470|       |                       ((uint64_t)u.bytes[4] << 32) |
 1471|       |                       ((uint64_t)u.bytes[5] << 40) |
 1472|       |                       ((uint64_t)u.bytes[6] << 48) |
 1473|       |                       ((uint64_t)u.bytes[7] << 56);
 1474|       |#endif
 1475|       |    return true;
 1476|  59.7k|}
pb_decode.c:buf_read:
   69|  80.8M|{
   70|  80.8M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   71|  80.8M|    stream->state = (pb_byte_t*)stream->state + count;
   72|       |    
   73|  80.8M|    if (buf != NULL)
  ------------------
  |  Branch (73:9): [True: 80.7M, False: 65.2k]
  ------------------
   74|  80.7M|    {
   75|  80.7M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   76|  80.7M|    }
   77|       |    
   78|       |    return true;
   79|  80.8M|}
pb_decode.c:pb_readbyte:
  125|   113M|{
  126|   113M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (126:9): [True: 367, False: 113M]
  ------------------
  127|    367|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  930|    367|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    367|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 367]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|       |
  129|   113M|#ifndef PB_BUFFER_ONLY
  130|   113M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (130:9): [True: 1.69k, False: 113M]
  ------------------
  131|  1.69k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  930|  1.69k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|  1.69k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 1.69k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|       |#else
  133|       |    *buf = *(const pb_byte_t*)stream->state;
  134|       |    stream->state = (pb_byte_t*)stream->state + 1;
  135|       |#endif
  136|       |
  137|   113M|    stream->bytes_left--;
  138|       |    
  139|       |    return true;    
  140|   113M|}
pb_decode.c:pb_skip_varint:
  257|   122k|{
  258|   122k|    pb_byte_t byte;
  259|   122k|    do
  260|   141k|    {
  261|   141k|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (261:13): [True: 71, False: 141k]
  ------------------
  262|     71|            return false;
  263|   141k|    } while (byte & 0x80);
  ------------------
  |  Branch (263:14): [True: 18.5k, False: 122k]
  ------------------
  264|   122k|    return true;
  265|   122k|}
pb_decode.c:pb_skip_string:
  268|   157k|{
  269|   157k|    uint32_t length;
  270|   157k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (270:9): [True: 49, False: 156k]
  ------------------
  271|     49|        return false;
  272|       |    
  273|   156k|    if ((size_t)length != length)
  ------------------
  |  Branch (273:9): [True: 0, False: 156k]
  ------------------
  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|   156k|    return pb_read(stream, NULL, (size_t)length);
  279|   156k|}
pb_decode.c:pb_decode_inner:
 1051|   201k|{
 1052|       |    /* If the message contains extension fields, the extension handlers
 1053|       |     * are called when tag number is >= extension_range_start. This precheck
 1054|       |     * is just for speed, and the handlers will check for precise match.
 1055|       |     */
 1056|   201k|    uint32_t extension_range_start = 0;
 1057|   201k|    pb_extension_t *extensions = NULL;
 1058|       |
 1059|       |    /* 'fixed_count_field' and 'fixed_count_size' track position of a repeated fixed
 1060|       |     * count field. This can only handle _one_ repeated fixed count field that
 1061|       |     * is unpacked and unordered among other (non repeated fixed count) fields.
 1062|       |     */
 1063|   201k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  342|   201k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
 1064|   201k|    pb_size_t fixed_count_size = 0;
 1065|   201k|    pb_size_t fixed_count_total_size = 0;
 1066|       |
 1067|       |    /* Tag and wire type of next field from the input stream */
 1068|   201k|    uint32_t tag;
 1069|   201k|    pb_wire_type_t wire_type;
 1070|   201k|    bool eof;
 1071|       |
 1072|       |    /* Track presence of required fields */
 1073|   201k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1074|   201k|    const uint32_t allbits = ~(uint32_t)0;
 1075|       |
 1076|       |    /* Descriptor for the structure field matching the tag decoded from stream */
 1077|   201k|    pb_field_iter_t iter;
 1078|       |
 1079|   201k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1079:9): [True: 119k, False: 82.2k]
  ------------------
 1080|   119k|    {
 1081|   119k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |  122|   119k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1081:13): [True: 110k, False: 8.78k]
  ------------------
 1082|   110k|        {
 1083|   110k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1083:17): [True: 0, False: 110k]
  ------------------
 1084|      0|                PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1085|   110k|        }
 1086|   119k|    }
 1087|       |
 1088|  32.6M|    while (pb_decode_tag(stream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1088:12): [True: 32.4M, False: 199k]
  ------------------
 1089|  32.4M|    {
 1090|  32.4M|        if (tag == 0)
  ------------------
  |  Branch (1090:13): [True: 92, False: 32.4M]
  ------------------
 1091|     92|        {
 1092|     92|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  124|     92|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1092:15): [True: 0, False: 92]
  ------------------
 1093|      0|          {
 1094|      0|            eof = true;
 1095|      0|            break;
 1096|      0|          }
 1097|     92|          else
 1098|     92|          {
 1099|     92|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  930|     92|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     92|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 92]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1100|     92|          }
 1101|     92|        }
 1102|       |
 1103|  32.4M|        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 (1103:13): [True: 340k, False: 32.0M]
  |  Branch (1103:48): [True: 1.18k, False: 32.0M]
  ------------------
 1104|   341k|        {
 1105|       |            /* No match found, check if it matches an extension. */
 1106|   341k|            if (extension_range_start == 0)
  ------------------
  |  Branch (1106:17): [True: 9.49k, False: 332k]
  ------------------
 1107|  9.49k|            {
 1108|  9.49k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1108:21): [True: 3.94k, False: 5.54k]
  ------------------
 1109|  3.94k|                {
 1110|  3.94k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1111|  3.94k|                    extension_range_start = iter.tag;
 1112|  3.94k|                }
 1113|       |
 1114|  9.49k|                if (!extensions)
  ------------------
  |  Branch (1114:21): [True: 6.20k, False: 3.29k]
  ------------------
 1115|  6.20k|                {
 1116|  6.20k|                    extension_range_start = (uint32_t)-1;
 1117|  6.20k|                }
 1118|  9.49k|            }
 1119|       |
 1120|   341k|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1120:17): [True: 77.4k, False: 264k]
  ------------------
 1121|  77.4k|            {
 1122|  77.4k|                size_t pos = stream->bytes_left;
 1123|       |
 1124|  77.4k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1124:21): [True: 115, False: 77.3k]
  ------------------
 1125|    115|                    return false;
 1126|       |
 1127|  77.3k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1127:21): [True: 3.37k, False: 73.9k]
  ------------------
 1128|  3.37k|                {
 1129|       |                    /* The field was handled */
 1130|  3.37k|                    continue;
 1131|  3.37k|                }
 1132|  77.3k|            }
 1133|       |
 1134|       |            /* No match found, skip data */
 1135|   338k|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1135:17): [True: 318, False: 337k]
  ------------------
 1136|    318|                return false;
 1137|   337k|            continue;
 1138|   338k|        }
 1139|       |
 1140|       |        /* If a repeated fixed count field was found, get size from
 1141|       |         * 'fixed_count_field' as there is no counter contained in the struct.
 1142|       |         */
 1143|  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.1M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1143:13): [True: 30.4M, False: 1.65M]
  |  Branch (1143:57): [True: 1.18k, False: 30.4M]
  ------------------
 1144|  1.18k|        {
 1145|  1.18k|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1145:17): [True: 957, False: 229]
  ------------------
 1146|       |                /* If the new fixed count field does not match the previous one,
 1147|       |                 * check that the previous one is NULL or that it finished
 1148|       |                 * receiving all the expected data.
 1149|       |                 */
 1150|    957|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  342|  1.91k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1150:21): [True: 532, False: 425]
  ------------------
 1151|    532|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1151:21): [True: 28, False: 504]
  ------------------
 1152|     28|                {
 1153|     28|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  930|     28|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     28|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 28]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1154|     28|                }
 1155|       |
 1156|    929|                fixed_count_field = iter.index;
 1157|    929|                fixed_count_size = 0;
 1158|    929|                fixed_count_total_size = iter.array_size;
 1159|    929|            }
 1160|       |
 1161|  1.15k|            iter.pSize = &fixed_count_size;
 1162|  1.15k|        }
 1163|       |
 1164|  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.1M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1164:13): [True: 1.61M, False: 30.4M]
  ------------------
 1165|  1.61M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  233|  1.61M|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1165:16): [True: 1.61M, False: 0]
  ------------------
 1166|  1.61M|        {
 1167|  1.61M|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1168|  1.61M|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1169|  1.61M|        }
 1170|       |
 1171|  32.0M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1171:13): [True: 1.50k, False: 32.0M]
  ------------------
 1172|  1.50k|            return false;
 1173|  32.0M|    }
 1174|       |
 1175|   199k|    if (!eof)
  ------------------
  |  Branch (1175:9): [True: 102, False: 199k]
  ------------------
 1176|    102|    {
 1177|       |        /* pb_decode_tag() returned error before end of stream */
 1178|    102|        return false;
 1179|    102|    }
 1180|       |
 1181|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1182|   199k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  342|   398k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1182:9): [True: 348, False: 199k]
  ------------------
 1183|    348|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1183:9): [True: 39, False: 309]
  ------------------
 1184|     39|    {
 1185|     39|        PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1186|     39|    }
 1187|       |
 1188|       |    /* Check that all required fields were present. */
 1189|   199k|    {
 1190|   199k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1191|       |
 1192|   199k|        if (req_field_count > 0)
  ------------------
  |  Branch (1192:13): [True: 111k, False: 87.4k]
  ------------------
 1193|   111k|        {
 1194|   111k|            pb_size_t i;
 1195|       |
 1196|   111k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  233|   111k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1196:17): [True: 0, False: 111k]
  ------------------
 1197|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  233|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1198|       |
 1199|       |            /* Check the whole words */
 1200|   111k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1200:25): [True: 0, False: 111k]
  ------------------
 1201|      0|            {
 1202|      0|                if (fields_seen.bitfield[i] != allbits)
  ------------------
  |  Branch (1202:21): [True: 0, False: 0]
  ------------------
 1203|      0|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1204|      0|            }
 1205|       |
 1206|       |            /* Check the remaining bits (if any) */
 1207|   111k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1207:17): [True: 111k, False: 0]
  ------------------
 1208|   111k|            {
 1209|   111k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1209:21): [True: 504, False: 111k]
  ------------------
 1210|   111k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1211|    504|                {
 1212|    504|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  930|    504|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    504|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 504]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1213|    504|                }
 1214|   111k|            }
 1215|   111k|        }
 1216|   199k|    }
 1217|       |
 1218|   198k|    return true;
 1219|   199k|}
pb_decode.c:pb_message_set_to_defaults:
 1012|   117k|{
 1013|   117k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   71|   117k|#  define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
 1014|   117k|    uint32_t tag = 0;
 1015|   117k|    pb_wire_type_t wire_type = PB_WT_VARINT;
 1016|   117k|    bool eof;
 1017|       |
 1018|   117k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (1018:9): [True: 0, False: 117k]
  ------------------
 1019|      0|    {
 1020|      0|        defstream = pb_istream_from_buffer(iter->descriptor->default_value, (size_t)-1);
 1021|      0|        if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1021:13): [True: 0, False: 0]
  ------------------
 1022|      0|            return false;
 1023|      0|    }
 1024|       |
 1025|   117k|    do
 1026|  1.05M|    {
 1027|  1.05M|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (1027:13): [True: 0, False: 1.05M]
  ------------------
 1028|      0|            return false;
 1029|       |
 1030|  1.05M|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (1030:13): [True: 0, False: 1.05M]
  |  Branch (1030:25): [True: 0, False: 0]
  ------------------
 1031|      0|        {
 1032|       |            /* We have a default value for this field in the defstream */
 1033|      0|            if (!decode_field(&defstream, wire_type, iter))
  ------------------
  |  Branch (1033:17): [True: 0, False: 0]
  ------------------
 1034|      0|                return false;
 1035|      0|            if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1035:17): [True: 0, False: 0]
  ------------------
 1036|      0|                return false;
 1037|       |
 1038|      0|            if (iter->pSize)
  ------------------
  |  Branch (1038:17): [True: 0, False: 0]
  ------------------
 1039|      0|                *(bool*)iter->pSize = false;
 1040|      0|        }
 1041|  1.05M|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (1041:14): [True: 937k, False: 117k]
  ------------------
 1042|       |
 1043|   117k|    return true;
 1044|   117k|}
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.89k, False: 1.04M]
  ------------------
  933|  8.89k|    {
  934|  8.89k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  935|  16.0k|        while (ext != NULL)
  ------------------
  |  Branch (935:16): [True: 7.19k, False: 8.89k]
  ------------------
  936|  7.19k|        {
  937|  7.19k|            pb_field_iter_t ext_iter;
  938|  7.19k|            if (ext->type->decode != NULL)
  ------------------
  |  Branch (938:17): [True: 0, False: 7.19k]
  ------------------
  939|      0|                ext->found = false; /* Custom type: arg is not a message descriptor */
  940|  7.19k|            else if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (940:22): [True: 7.19k, False: 0]
  ------------------
  941|  7.19k|            {
  942|  7.19k|                ext->found = false;
  943|  7.19k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (943:21): [True: 0, False: 7.19k]
  ------------------
  944|      0|                    return false;
  945|  7.19k|            }
  946|  7.19k|            ext = ext->next;
  947|  7.19k|        }
  948|  8.89k|    }
  949|  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 (949:14): [True: 33.8k, False: 1.01M]
  ------------------
  950|  33.8k|    {
  951|  33.8k|        bool init_data = true;
  952|  33.8k|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  327|  33.8k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  33.8k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  312|  67.7k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (952:13): [True: 0, False: 33.8k]
  |  Branch (952:52): [True: 0, False: 0]
  ------------------
  953|      0|        {
  954|       |            /* Set has_field to false. Still initialize the optional field
  955|       |             * itself also. */
  956|      0|            *(bool*)field->pSize = false;
  957|      0|        }
  958|  33.8k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  327|  33.8k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  33.8k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  314|  67.7k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (958:18): [True: 0, False: 33.8k]
  ------------------
  959|  33.8k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  33.8k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  33.8k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  33.8k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (959:18): [True: 26.6k, False: 7.19k]
  ------------------
  960|  26.6k|        {
  961|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
  962|       |               ONEOF: Set which_field to 0. */
  963|  26.6k|            *(pb_size_t*)field->pSize = 0;
  964|  26.6k|            init_data = false;
  965|  26.6k|        }
  966|       |
  967|  33.8k|        if (init_data)
  ------------------
  |  Branch (967:13): [True: 7.19k, False: 26.6k]
  ------------------
  968|  7.19k|        {
  969|  7.19k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  329|  14.3k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  7.19k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  7.19k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  14.3k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 7.19k, False: 0]
  |  |  ------------------
  |  |  330|  14.3k|                               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]
  |  |  ------------------
  ------------------
  970|  7.19k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (970:18): [True: 0, False: 7.19k]
  ------------------
  971|  7.19k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (971:18): [True: 0, False: 7.19k]
  ------------------
  972|  7.19k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (972:18): [True: 0, False: 7.19k]
  ------------------
  973|      0|            {
  974|       |                /* Initialize submessage to defaults.
  975|       |                 * Only needed if it has default values
  976|       |                 * or callback/submessage fields. */
  977|      0|                pb_field_iter_t submsg_iter;
  978|      0|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (978:21): [True: 0, False: 0]
  ------------------
  979|      0|                {
  980|      0|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (980:25): [True: 0, False: 0]
  ------------------
  981|      0|                        return false;
  982|      0|                }
  983|      0|            }
  984|  7.19k|            else
  985|  7.19k|            {
  986|       |                /* Initialize to zeros */
  987|  7.19k|                memset(field->pData, 0, (size_t)field->data_size);
  988|  7.19k|            }
  989|  7.19k|        }
  990|  33.8k|    }
  991|  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 (991:14): [True: 994k, False: 17.7k]
  ------------------
  992|   994k|    {
  993|       |        /* Initialize the pointer to NULL. */
  994|   994k|        *(void**)field->pField = NULL;
  995|       |
  996|       |        /* Initialize array count to 0. */
  997|   994k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  327|   994k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   994k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  314|  1.98M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (997:13): [True: 186k, False: 808k]
  ------------------
  998|   808k|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   808k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   808k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   808k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (998:13): [True: 17.7k, False: 790k]
  ------------------
  999|   204k|        {
 1000|   204k|            *(pb_size_t*)field->pSize = 0;
 1001|   204k|        }
 1002|   994k|    }
 1003|  17.7k|    else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|  17.7k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  17.7k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|  17.7k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1003:14): [True: 17.7k, False: 0]
  ------------------
 1004|  17.7k|    {
 1005|       |        /* Don't overwrite callback */
 1006|  17.7k|    }
 1007|       |
 1008|  1.05M|    return true;
 1009|  1.05M|}
pb_decode.c:decode_extension:
  906|  77.4k|{
  907|  77.4k|    size_t pos = stream->bytes_left;
  908|       |    
  909|   154k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (909:12): [True: 77.4k, False: 77.3k]
  |  Branch (909:33): [True: 77.4k, False: 0]
  ------------------
  910|  77.4k|    {
  911|  77.4k|        bool status;
  912|  77.4k|        if (extension->type->decode)
  ------------------
  |  Branch (912:13): [True: 0, False: 77.4k]
  ------------------
  913|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  914|  77.4k|        else
  915|  77.4k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  916|       |
  917|  77.4k|        if (!status)
  ------------------
  |  Branch (917:13): [True: 115, False: 77.3k]
  ------------------
  918|    115|            return false;
  919|       |        
  920|  77.3k|        extension = extension->next;
  921|  77.3k|    }
  922|       |    
  923|  77.3k|    return true;
  924|  77.4k|}
pb_decode.c:default_extension_decoder:
  889|  77.4k|{
  890|  77.4k|    pb_field_iter_t iter;
  891|       |
  892|  77.4k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (892:9): [True: 0, False: 77.4k]
  ------------------
  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|  77.4k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (895:9): [True: 73.9k, False: 3.48k]
  |  Branch (895:28): [True: 0, False: 3.48k]
  ------------------
  896|  73.9k|        return true;
  897|       |
  898|  3.48k|    extension->found = true;
  899|  3.48k|    return decode_field(stream, wire_type, &iter);
  900|  77.4k|}
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: 22.1k, False: 32.0M]
  ------------------
  862|  22.1k|    {
  863|  22.1k|        if (!pb_release_union_field(stream, field))
  ------------------
  |  Branch (863:13): [True: 0, False: 22.1k]
  ------------------
  864|      0|            return false;
  865|  22.1k|    }
  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|  10.9k|        case PB_ATYPE_STATIC:
  ------------------
  |  |  321|  10.9k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (870:9): [True: 10.9k, False: 32.0M]
  ------------------
  871|  10.9k|            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: 16.8k]
  ------------------
  874|  32.0M|            return decode_pointer_field(stream, wire_type, field);
  875|       |        
  876|  5.89k|        case PB_ATYPE_CALLBACK:
  ------------------
  |  |  323|  5.89k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (876:9): [True: 5.89k, False: 32.0M]
  ------------------
  877|  5.89k|            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:
 1258|  22.1k|{
 1259|  22.1k|    pb_field_iter_t old_field = *field;
 1260|  22.1k|    pb_size_t old_tag = *(pb_size_t*)field->pSize; /* Previous which_ value */
 1261|  22.1k|    pb_size_t new_tag = field->tag; /* New which_ value */
 1262|       |
 1263|  22.1k|    if (old_tag == 0)
  ------------------
  |  Branch (1263:9): [True: 1.71k, False: 20.4k]
  ------------------
 1264|  1.71k|        return true; /* Ok, no old data in union */
 1265|       |
 1266|  20.4k|    if (old_tag == new_tag)
  ------------------
  |  Branch (1266:9): [True: 12.1k, False: 8.27k]
  ------------------
 1267|  12.1k|        return true; /* Ok, old data is of same type => merge */
 1268|       |
 1269|       |    /* Release old data. The find can fail if the message struct contains
 1270|       |     * invalid data. */
 1271|  8.27k|    if (!pb_field_iter_find(&old_field, old_tag))
  ------------------
  |  Branch (1271:9): [True: 0, False: 8.27k]
  ------------------
 1272|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1273|       |
 1274|  8.27k|    pb_release_single_field(&old_field);
 1275|       |
 1276|  8.27k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  8.27k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  8.27k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  8.27k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1276:9): [True: 2.16k, False: 6.10k]
  ------------------
 1277|  2.16k|    {
 1278|       |        /* Initialize the pointer to NULL to make sure it is valid
 1279|       |         * even in case of error return. */
 1280|  2.16k|        *(void**)field->pField = NULL;
 1281|  2.16k|        field->pData = NULL;
 1282|  2.16k|    }
 1283|       |
 1284|       |    return true;
 1285|  8.27k|}
pb_decode.c:decode_static_field:
  498|  10.9k|{
  499|  10.9k|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  327|  10.9k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  10.9k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  500|  10.9k|    {
  501|  3.48k|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  311|  3.48k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (501:9): [True: 3.48k, False: 7.45k]
  ------------------
  502|  3.48k|            return decode_basic_field(stream, wire_type, field);
  503|       |            
  504|  1.03k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  312|  1.03k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (504:9): [True: 1.03k, False: 9.90k]
  ------------------
  505|  1.03k|            if (field->pSize != NULL)
  ------------------
  |  Branch (505:17): [True: 1.03k, False: 0]
  ------------------
  506|  1.03k|                *(bool*)field->pSize = true;
  507|  1.03k|            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: 10.9k]
  ------------------
  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.41k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  316|  6.41k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (552:9): [True: 6.41k, False: 4.52k]
  ------------------
  553|  6.41k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  329|  12.8k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  6.41k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  6.41k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  12.8k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 5.35k, False: 1.06k]
  |  |  ------------------
  |  |  330|  12.8k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  1.06k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.06k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  1.06k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 1.06k]
  |  |  ------------------
  ------------------
  554|  5.35k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (554:17): [True: 2.82k, False: 2.52k]
  ------------------
  555|  2.82k|            {
  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.82k|                memset(field->pData, 0, (size_t)field->data_size);
  564|       |
  565|       |                /* Set default values for the submessage fields. */
  566|  2.82k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (566:21): [True: 0, False: 2.82k]
  ------------------
  567|  2.82k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (567:21): [True: 0, False: 2.82k]
  ------------------
  568|  2.82k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (568:21): [True: 0, False: 2.82k]
  ------------------
  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.82k|            }
  578|  6.41k|            *(pb_size_t*)field->pSize = field->tag;
  579|       |
  580|  6.41k|            return decode_basic_field(stream, wire_type, field);
  581|       |
  582|      0|        default:
  ------------------
  |  Branch (582:9): [True: 0, False: 10.9k]
  ------------------
  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|  10.9k|    }
  585|  10.9k|}
pb_decode.c:decode_basic_field:
  427|  43.2M|{
  428|  43.2M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|  43.2M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  43.2M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  429|  43.2M|    {
  430|  3.21M|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|  3.21M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (430:9): [True: 3.21M, False: 40.0M]
  ------------------
  431|  3.21M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (431:17): [True: 2.83M, False: 385k]
  |  Branch (431:46): [True: 15, False: 2.83M]
  ------------------
  432|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  433|       |
  434|  3.21M|            return pb_dec_bool(stream, field);
  435|       |
  436|  4.75M|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|  4.75M|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (436:9): [True: 4.75M, False: 38.5M]
  ------------------
  437|  5.68M|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|  5.68M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (437:9): [True: 926k, False: 42.3M]
  ------------------
  438|  9.31M|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|  9.31M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (438:9): [True: 3.63M, False: 39.6M]
  ------------------
  439|  9.31M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (439:17): [True: 8.35M, False: 960k]
  |  Branch (439:46): [True: 59, False: 8.35M]
  ------------------
  440|     59|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     59|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     59|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 59]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  441|       |
  442|  9.31M|            return pb_dec_varint(stream, field);
  443|       |
  444|   148k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|   148k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (444:9): [True: 148k, False: 43.1M]
  ------------------
  445|   148k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (445:17): [True: 74.8k, False: 73.3k]
  |  Branch (445:45): [True: 12, False: 74.8k]
  ------------------
  446|     12|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     12|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     12|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  447|       |
  448|   148k|            return pb_decode_fixed32(stream, field->pData);
  449|       |
  450|  59.7k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|  59.7k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (450:9): [True: 59.7k, False: 43.2M]
  ------------------
  451|  59.7k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (451:17): [True: 13.7k, False: 45.9k]
  |  Branch (451:45): [True: 17, False: 13.7k]
  ------------------
  452|     17|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     17|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     17|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|  59.7k|            return pb_decode_fixed64(stream, field->pData);
  465|      0|#endif
  466|       |
  467|   516k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|   516k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (467:9): [True: 516k, False: 42.7M]
  ------------------
  468|   516k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (468:17): [True: 13, False: 516k]
  ------------------
  469|     13|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     13|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     13|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  470|       |
  471|   516k|            return pb_dec_bytes(stream, field);
  472|       |
  473|   142k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|   142k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (473:9): [True: 142k, False: 43.1M]
  ------------------
  474|   142k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (474:17): [True: 15, False: 142k]
  ------------------
  475|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  476|       |
  477|   142k|            return pb_dec_string(stream, field);
  478|       |
  479|   192k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|   192k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (479:9): [True: 192k, False: 43.0M]
  ------------------
  480|   192k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|   192k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (480:9): [True: 0, False: 43.2M]
  ------------------
  481|   192k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (481:17): [True: 29, False: 192k]
  ------------------
  482|     29|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|     29|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     29|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 29]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  483|       |
  484|   192k|            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: 13.5M]
  ------------------
  487|  29.6M|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (487:17): [True: 7, False: 29.6M]
  ------------------
  488|      7|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  930|      7|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      7|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|  29.6M|            return pb_dec_fixed_length_bytes(stream, field);
  491|       |
  492|      0|        default:
  ------------------
  |  Branch (492:9): [True: 0, False: 43.2M]
  ------------------
  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.2M|    }
  495|  43.2M|}
pb_decode.c:pb_dec_bool:
 1480|  3.21M|{
 1481|  3.21M|    return pb_decode_bool(stream, (bool*)field->pData);
 1482|  3.21M|}
pb_decode.c:pb_dec_varint:
 1485|  9.31M|{
 1486|  9.31M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  328|  9.31M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  9.31M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  270|  9.31M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1486:9): [True: 926k, False: 8.39M]
  ------------------
 1487|   926k|    {
 1488|   926k|        pb_uint64_t value, clamped;
  ------------------
  |  |   57|   926k|#define pb_uint64_t uint64_t
  ------------------
 1489|   926k|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1489:13): [True: 38, False: 926k]
  ------------------
 1490|     38|            return false;
 1491|       |
 1492|       |        /* Cast to the proper field size, while checking for overflows */
 1493|   926k|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1493:13): [True: 594k, False: 331k]
  ------------------
 1494|   594k|            clamped = *(pb_uint64_t*)field->pData = value;
 1495|   331k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1495:18): [True: 308k, False: 23.4k]
  ------------------
 1496|   308k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1497|  23.4k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1497:18): [True: 11.6k, False: 11.7k]
  ------------------
 1498|  11.6k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1499|  11.7k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1499:18): [True: 11.7k, False: 0]
  ------------------
 1500|  11.7k|            clamped = *(uint_least8_t*)field->pData = (uint_least8_t)value;
 1501|      0|        else
 1502|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1503|       |
 1504|   926k|        if (clamped != value)
  ------------------
  |  Branch (1504:13): [True: 113, False: 926k]
  ------------------
 1505|    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1506|       |
 1507|   926k|        return true;
 1508|   926k|    }
 1509|  8.39M|    else
 1510|  8.39M|    {
 1511|  8.39M|        pb_uint64_t value;
  ------------------
  |  |   57|  8.39M|#define pb_uint64_t uint64_t
  ------------------
 1512|  8.39M|        pb_int64_t svalue;
  ------------------
  |  |   56|  8.39M|#define pb_int64_t int64_t
  ------------------
 1513|  8.39M|        pb_int64_t clamped;
  ------------------
  |  |   56|  8.39M|#define pb_int64_t int64_t
  ------------------
 1514|       |
 1515|  8.39M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  328|  8.39M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  8.39M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  271|  8.39M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1515:13): [True: 3.63M, False: 4.75M]
  ------------------
 1516|  3.63M|        {
 1517|  3.63M|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1517:17): [True: 45, False: 3.63M]
  ------------------
 1518|     45|                return false;
 1519|  3.63M|        }
 1520|  4.75M|        else
 1521|  4.75M|        {
 1522|  4.75M|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1522:17): [True: 49, False: 4.75M]
  ------------------
 1523|     49|                return false;
 1524|       |
 1525|       |            /* See issue 97: Google's C++ protobuf allows negative varint values to
 1526|       |            * be cast as int32_t, instead of the int64_t that should be used when
 1527|       |            * encoding. Nanopb versions before 0.2.5 had a bug in encoding. In order to
 1528|       |            * not break decoding of such messages, we cast <=32 bit fields to
 1529|       |            * int32_t first to get the sign correct.
 1530|       |            */
 1531|  4.75M|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1531:17): [True: 680k, False: 4.07M]
  ------------------
 1532|   680k|                svalue = (pb_int64_t)value;
 1533|  4.07M|            else
 1534|  4.07M|                svalue = (int32_t)value;
 1535|  4.75M|        }
 1536|       |
 1537|       |        /* Cast to the proper field size, while checking for overflows */
 1538|  8.39M|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1538:13): [True: 4.21M, False: 4.17M]
  ------------------
 1539|  4.21M|            clamped = *(pb_int64_t*)field->pData = svalue;
 1540|  4.17M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1540:18): [True: 4.12M, False: 46.3k]
  ------------------
 1541|  4.12M|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1542|  46.3k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1542:18): [True: 23.0k, False: 23.2k]
  ------------------
 1543|  23.0k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1544|  23.2k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1544:18): [True: 23.2k, False: 0]
  ------------------
 1545|  23.2k|            clamped = *(int_least8_t*)field->pData = (int_least8_t)svalue;
 1546|      0|        else
 1547|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1548|       |
 1549|  8.39M|        if (clamped != svalue)
  ------------------
  |  Branch (1549:13): [True: 90, False: 8.39M]
  ------------------
 1550|     90|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  930|     90|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     90|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 90]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1551|       |
 1552|  8.39M|        return true;
 1553|  8.39M|    }
 1554|  9.31M|}
pb_decode.c:pb_dec_bytes:
 1557|   516k|{
 1558|   516k|    uint32_t size;
 1559|   516k|    size_t alloc_size;
 1560|   516k|    pb_bytes_array_t *dest;
 1561|       |    
 1562|   516k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1562:9): [True: 32, False: 516k]
  ------------------
 1563|     32|        return false;
 1564|       |    
 1565|   516k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  342|   516k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1565:9): [True: 31, False: 516k]
  ------------------
 1566|     31|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  930|     31|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     31|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1567|       |    
 1568|   516k|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  411|   516k|    (((size_t)(n) + offsetof(pb_bytes_array_t, bytes)) < sizeof(pb_bytes_array_t) \
  |  |  ------------------
  |  |  |  Branch (411:6): [True: 507k, False: 8.76k]
  |  |  ------------------
  |  |  412|   516k|        ? sizeof(pb_bytes_array_t) \
  |  |  413|   516k|        : ((size_t)(n) + offsetof(pb_bytes_array_t, bytes)))
  ------------------
 1569|   516k|    if (size > alloc_size)
  ------------------
  |  Branch (1569:9): [True: 0, False: 516k]
  ------------------
 1570|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1571|       |    
 1572|   516k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   516k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   516k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   516k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1572:9): [True: 516k, False: 0]
  ------------------
 1573|   516k|    {
 1574|       |#ifndef PB_ENABLE_MALLOC
 1575|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1576|       |#else
 1577|   516k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1577:13): [True: 53, False: 516k]
  ------------------
 1578|     53|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  930|     53|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     53|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 53]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1579|       |
 1580|   516k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1580:13): [True: 0, False: 516k]
  ------------------
 1581|      0|            return false;
 1582|   516k|        dest = *(pb_bytes_array_t**)field->pData;
 1583|   516k|#endif
 1584|   516k|    }
 1585|      0|    else
 1586|      0|    {
 1587|      0|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1587:13): [True: 0, False: 0]
  ------------------
 1588|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1589|      0|        dest = (pb_bytes_array_t*)field->pData;
 1590|      0|    }
 1591|       |
 1592|   516k|    dest->size = (pb_size_t)size;
 1593|   516k|    return pb_read(stream, dest->bytes, (size_t)size);
 1594|   516k|}
pb_decode.c:allocate_field:
  593|  33.3M|{    
  594|  33.3M|    void *ptr = *(void**)pData;
  595|       |    
  596|  33.3M|    if (data_size == 0 || array_size == 0)
  ------------------
  |  Branch (596:9): [True: 0, False: 33.3M]
  |  Branch (596:27): [True: 0, False: 33.3M]
  ------------------
  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.3M|    {
  615|  33.3M|        const size_t check_limit = (size_t)1 << (sizeof(size_t) * 4);
  616|  33.3M|        if (data_size >= check_limit || array_size >= check_limit)
  ------------------
  |  Branch (616:13): [True: 0, False: 33.3M]
  |  Branch (616:41): [True: 0, False: 33.3M]
  ------------------
  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.3M|    }
  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.3M|    ptr = pb_realloc(ptr, array_size * data_size);
  ------------------
  |  |    3|  33.3M|#define pb_realloc(ptr,size) realloc_with_check(ptr,size)
  ------------------
  630|  33.3M|    if (ptr == NULL)
  ------------------
  |  Branch (630:9): [True: 0, False: 33.3M]
  ------------------
  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.3M|    *(void**)pData = ptr;
  634|       |    return true;
  635|  33.3M|}
pb_decode.c:pb_dec_string:
 1597|   142k|{
 1598|   142k|    uint32_t size;
 1599|   142k|    size_t alloc_size;
 1600|   142k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1601|       |
 1602|   142k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1602:9): [True: 24, False: 142k]
  ------------------
 1603|     24|        return false;
 1604|       |
 1605|   142k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1605:9): [True: 3, False: 142k]
  ------------------
 1606|      3|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1607|       |
 1608|       |    /* Space for null terminator */
 1609|   142k|    alloc_size = (size_t)(size + 1);
 1610|       |
 1611|   142k|    if (alloc_size < size)
  ------------------
  |  Branch (1611:9): [True: 0, False: 142k]
  ------------------
 1612|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1613|       |
 1614|   142k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   142k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   142k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   142k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1614:9): [True: 141k, False: 1.02k]
  ------------------
 1615|   141k|    {
 1616|       |#ifndef PB_ENABLE_MALLOC
 1617|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1618|       |#else
 1619|   141k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1619:13): [True: 64, False: 141k]
  ------------------
 1620|     64|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  930|     64|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     64|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 64]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1621|       |
 1622|   141k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1622:13): [True: 0, False: 141k]
  ------------------
 1623|      0|            return false;
 1624|   141k|        dest = *(pb_byte_t**)field->pData;
 1625|   141k|#endif
 1626|   141k|    }
 1627|  1.02k|    else
 1628|  1.02k|    {
 1629|  1.02k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1629:13): [True: 51, False: 973]
  ------------------
 1630|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1631|  1.02k|    }
 1632|       |    
 1633|   142k|    dest[size] = 0;
 1634|       |
 1635|   142k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1635:9): [True: 4, False: 142k]
  ------------------
 1636|      4|        return false;
 1637|       |
 1638|       |#ifdef PB_VALIDATE_UTF8
 1639|       |    if (!pb_validate_utf8((const char*)dest))
 1640|       |        PB_RETURN_ERROR(stream, "invalid utf8");
 1641|       |#endif
 1642|       |
 1643|   142k|    return true;
 1644|   142k|}
pb_decode.c:pb_dec_submessage:
 1647|   192k|{
 1648|   192k|    bool status = true;
 1649|   192k|    bool submsg_consumed = false;
 1650|   192k|    pb_istream_t substream;
 1651|       |
 1652|   192k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1652:9): [True: 133, False: 192k]
  ------------------
 1653|    133|        return false;
 1654|       |    
 1655|   192k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1655:9): [True: 0, False: 192k]
  ------------------
 1656|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  930|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1657|       |    
 1658|       |    /* Submessages can have a separate message-level callback that is called
 1659|       |     * before decoding the message. Typically it is used to set callback fields
 1660|       |     * inside oneofs. */
 1661|   192k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  328|   192k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   192k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  293|   385k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1661:9): [True: 0, False: 192k]
  |  Branch (1661:58): [True: 0, False: 0]
  ------------------
 1662|      0|    {
 1663|       |        /* Message callback is stored right before pSize. */
 1664|      0|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
 1665|      0|        if (callback->funcs.decode)
  ------------------
  |  Branch (1665:13): [True: 0, False: 0]
  ------------------
 1666|      0|        {
 1667|      0|            status = callback->funcs.decode(&substream, field, &callback->arg);
 1668|       |
 1669|      0|            if (substream.bytes_left == 0)
  ------------------
  |  Branch (1669:17): [True: 0, False: 0]
  ------------------
 1670|      0|            {
 1671|      0|                submsg_consumed = true;
 1672|      0|            }
 1673|      0|        }
 1674|      0|    }
 1675|       |
 1676|       |    /* Now decode the submessage contents */
 1677|   192k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1677:9): [True: 192k, False: 0]
  |  Branch (1677:19): [True: 192k, False: 0]
  ------------------
 1678|   192k|    {
 1679|   192k|        unsigned int flags = 0;
 1680|       |
 1681|       |        /* Static required/optional fields are already initialized by top-level
 1682|       |         * pb_decode(), no need to initialize them again. */
 1683|   192k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  326|   192k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   192k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  321|   385k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1683:13): [True: 8.78k, False: 183k]
  ------------------
 1684|  8.78k|            PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  327|  8.78k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  8.78k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  314|  8.78k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1684:13): [True: 8.78k, False: 0]
  ------------------
 1685|  8.78k|        {
 1686|  8.78k|            flags = PB_DECODE_NOINIT;
  ------------------
  |  |  122|  8.78k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1687|  8.78k|        }
 1688|       |
 1689|   192k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1690|   192k|    }
 1691|       |    
 1692|   192k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1692:9): [True: 0, False: 192k]
  ------------------
 1693|      0|        return false;
 1694|       |
 1695|   192k|    return status;
 1696|   192k|}
pb_decode.c:pb_dec_fixed_length_bytes:
 1699|  29.6M|{
 1700|  29.6M|    uint32_t size;
 1701|       |
 1702|  29.6M|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1702:9): [True: 3, False: 29.6M]
  ------------------
 1703|      3|        return false;
 1704|       |
 1705|  29.6M|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  342|  29.6M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1705:9): [True: 34, False: 29.6M]
  ------------------
 1706|     34|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  930|     34|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     34|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 34]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1707|       |
 1708|  29.6M|    if (size == 0)
  ------------------
  |  Branch (1708:9): [True: 28.5M, False: 1.11M]
  ------------------
 1709|  28.5M|    {
 1710|       |        /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */
 1711|  28.5M|        memset(field->pData, 0, (size_t)field->data_size);
 1712|  28.5M|        return true;
 1713|  28.5M|    }
 1714|       |
 1715|  1.11M|    if (size != field->data_size)
  ------------------
  |  Branch (1715:9): [True: 48, False: 1.11M]
  ------------------
 1716|     48|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  930|     48|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     48|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 48]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1717|       |
 1718|  1.11M|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1719|  1.11M|}
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.61M|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  311|  1.61M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (663:9): [True: 1.61M, False: 30.4M]
  ------------------
  664|  1.63M|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  312|  1.63M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (664:9): [True: 16.5k, False: 32.0M]
  ------------------
  665|  1.64M|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  316|  1.64M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (665:9): [True: 9.85k, False: 32.0M]
  ------------------
  666|  1.64M|            if (PB_LTYPE_IS_SUBMSG(field->type) && *(void**)field->pField != NULL)
  ------------------
  |  |  329|  3.28M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  1.64M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.64M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  3.28M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 74.6k, False: 1.56M]
  |  |  ------------------
  |  |  330|  3.28M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  1.56M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  1.56M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  1.56M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 1.56M]
  |  |  ------------------
  ------------------
  |  Branch (666:52): [True: 38.0k, False: 36.6k]
  ------------------
  667|  38.0k|            {
  668|       |                /* Duplicate field, have to release the old allocation first. */
  669|       |                /* FIXME: Does this work correctly for oneofs? */
  670|  38.0k|                pb_release_single_field(field);
  671|  38.0k|            }
  672|       |        
  673|  1.64M|            if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  1.64M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.64M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  1.64M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (673:17): [True: 9.85k, False: 1.63M]
  ------------------
  674|  9.85k|            {
  675|  9.85k|                *(pb_size_t*)field->pSize = field->tag;
  676|  9.85k|            }
  677|       |
  678|  1.64M|            if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|  1.64M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.64M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|  3.28M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (678:17): [True: 85.5k, False: 1.55M]
  ------------------
  679|  1.55M|                PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|  1.55M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.55M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|  1.55M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (679:17): [True: 16.0k, False: 1.54M]
  ------------------
  680|   101k|            {
  681|       |                /* pb_dec_string and pb_dec_bytes handle allocation themselves */
  682|   101k|                field->pData = field->pField;
  683|   101k|                return decode_basic_field(stream, wire_type, field);
  684|   101k|            }
  685|  1.54M|            else
  686|  1.54M|            {
  687|  1.54M|                if (!allocate_field(stream, field->pField, field->data_size, 1))
  ------------------
  |  Branch (687:21): [True: 0, False: 1.54M]
  ------------------
  688|      0|                    return false;
  689|       |                
  690|  1.54M|                field->pData = *(void**)field->pField;
  691|  1.54M|                initialize_pointer_field(field->pData, field);
  692|  1.54M|                return decode_basic_field(stream, wire_type, field);
  693|  1.54M|            }
  694|       |    
  695|  30.4M|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  314|  30.4M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (695:9): [True: 30.4M, False: 1.64M]
  ------------------
  696|  30.4M|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (696:17): [True: 30.4M, False: 9.19k]
  ------------------
  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: 84.2k, False: 30.3M]
  ------------------
  698|  84.2k|            {
  699|       |                /* Packed array, multiple items come in at once. */
  700|  84.2k|                bool status = true;
  701|  84.2k|                pb_size_t *size = (pb_size_t*)field->pSize;
  702|  84.2k|                size_t allocated_size = *size;
  703|  84.2k|                pb_istream_t substream;
  704|       |                
  705|  84.2k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (705:21): [True: 53, False: 84.2k]
  ------------------
  706|     53|                    return false;
  707|       |                
  708|  11.3M|                while (substream.bytes_left)
  ------------------
  |  Branch (708:24): [True: 11.2M, False: 84.1k]
  ------------------
  709|  11.2M|                {
  710|  11.2M|                    if (*size == PB_SIZE_MAX)
  ------------------
  |  |  342|  11.2M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (710:25): [True: 7, False: 11.2M]
  ------------------
  711|      7|                    {
  712|      7|#ifndef PB_NO_ERRMSG
  713|      7|                        stream->errmsg = "too many array entries";
  714|      7|#endif
  715|      7|                        status = false;
  716|      7|                        break;
  717|      7|                    }
  718|       |
  719|  11.2M|                    if ((size_t)*size + 1 > allocated_size)
  ------------------
  |  Branch (719:25): [True: 853k, False: 10.4M]
  ------------------
  720|   853k|                    {
  721|       |                        /* Allocate more storage. This tries to guess the
  722|       |                         * number of remaining entries. Round the division
  723|       |                         * upwards. */
  724|   853k|                        size_t remain = (substream.bytes_left - 1) / field->data_size + 1;
  725|   853k|                        if (remain < PB_SIZE_MAX - allocated_size)
  ------------------
  |  |  342|   853k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (725:29): [True: 242k, False: 610k]
  ------------------
  726|   242k|                            allocated_size += remain;
  727|   610k|                        else
  728|   610k|                            allocated_size += 1;
  729|       |                        
  730|   853k|                        if (!allocate_field(&substream, field->pField, field->data_size, allocated_size))
  ------------------
  |  Branch (730:29): [True: 0, False: 853k]
  ------------------
  731|      0|                        {
  732|      0|                            status = false;
  733|      0|                            break;
  734|      0|                        }
  735|   853k|                    }
  736|       |
  737|       |                    /* Decode the array entry */
  738|  11.2M|                    field->pData = *(char**)field->pField + field->data_size * (*size);
  739|  11.2M|                    if (field->pData == NULL)
  ------------------
  |  Branch (739:25): [True: 0, False: 11.2M]
  ------------------
  740|      0|                    {
  741|       |                        /* Shouldn't happen, but satisfies static analyzers */
  742|      0|                        status = false;
  743|      0|                        break;
  744|      0|                    }
  745|  11.2M|                    initialize_pointer_field(field->pData, field);
  746|  11.2M|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (746:25): [True: 95, False: 11.2M]
  ------------------
  747|     95|                    {
  748|     95|                        status = false;
  749|     95|                        break;
  750|     95|                    }
  751|       |                    
  752|  11.2M|                    (*size)++;
  753|  11.2M|                }
  754|  84.2k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (754:21): [True: 0, False: 84.2k]
  ------------------
  755|      0|                    return false;
  756|       |                
  757|  84.2k|                return status;
  758|  84.2k|            }
  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.1M|{
  640|  43.1M|    if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|  43.1M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  43.1M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|  86.3M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (640:9): [True: 56.1k, False: 43.0M]
  ------------------
  641|  43.0M|        PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|  43.0M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  43.0M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|  43.0M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (641:9): [True: 500k, False: 42.5M]
  ------------------
  642|   556k|    {
  643|   556k|        *(void**)pItem = NULL;
  644|   556k|    }
  645|  42.5M|    else if (PB_LTYPE_IS_SUBMSG(field->type))
  ------------------
  |  |  329|  42.5M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  42.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  42.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  85.1M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 183k, False: 42.4M]
  |  |  ------------------
  |  |  330|  42.5M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  42.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  42.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  42.4M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 42.4M]
  |  |  ------------------
  ------------------
  646|   183k|    {
  647|       |        /* We memset to zero so that any callbacks are set to NULL.
  648|       |         * Default values will be set by pb_dec_submessage(). */
  649|   183k|        memset(pItem, 0, field->data_size);
  650|   183k|    }
  651|  43.1M|}
pb_decode.c:decode_callback_field:
  783|  5.89k|{
  784|       |    /* Clear any data that may have been decoded for another oneof field
  785|       |     * that has come before this callback field.
  786|       |     */
  787|  5.89k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  5.89k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  5.89k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  5.89k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (787:9): [True: 5.89k, False: 0]
  ------------------
  788|  5.89k|    {
  789|  5.89k|        if (*(pb_size_t*)field->pSize != 0 && *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (789:13): [True: 5.32k, False: 578]
  |  Branch (789:47): [True: 2.92k, False: 2.39k]
  ------------------
  790|  2.92k|        {
  791|  2.92k|            memset(field->pData, 0, (size_t)field->data_size);
  792|  2.92k|        }
  793|  5.89k|        *(pb_size_t*)field->pSize = field->tag;
  794|  5.89k|    }
  795|       |
  796|  5.89k|    if (!field->descriptor->field_callback)
  ------------------
  |  Branch (796:9): [True: 0, False: 5.89k]
  ------------------
  797|      0|        return pb_skip_field(stream, wire_type);
  798|       |
  799|  5.89k|    if (wire_type == PB_WT_STRING)
  ------------------
  |  Branch (799:9): [True: 1.46k, False: 4.43k]
  ------------------
  800|  1.46k|    {
  801|  1.46k|        pb_istream_t substream;
  802|  1.46k|        size_t prev_bytes_left;
  803|       |        
  804|  1.46k|        if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (804:13): [True: 45, False: 1.41k]
  ------------------
  805|     45|            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.41k|        if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  328|  1.41k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  1.41k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  293|  2.83k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (809:13): [True: 0, False: 1.41k]
  |  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.41k|        do
  824|  1.41k|        {
  825|  1.41k|            prev_bytes_left = substream.bytes_left;
  826|  1.41k|            if (!field->descriptor->field_callback(&substream, NULL, field))
  ------------------
  |  Branch (826:17): [True: 0, False: 1.41k]
  ------------------
  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.41k|        } while (substream.bytes_left > 0 && substream.bytes_left < prev_bytes_left);
  ------------------
  |  Branch (831:18): [True: 609, False: 810]
  |  Branch (831:46): [True: 0, False: 609]
  ------------------
  832|       |        
  833|  1.41k|        if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (833:13): [True: 0, False: 1.41k]
  ------------------
  834|      0|            return false;
  835|       |
  836|  1.41k|        return true;
  837|  1.41k|    }
  838|  4.43k|    else
  839|  4.43k|    {
  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.43k|        pb_istream_t substream;
  845|  4.43k|        pb_byte_t buffer[10];
  846|  4.43k|        size_t size = sizeof(buffer);
  847|       |        
  848|  4.43k|        if (!read_raw_value(stream, wire_type, buffer, &size))
  ------------------
  |  Branch (848:13): [True: 50, False: 4.38k]
  ------------------
  849|     50|            return false;
  850|  4.38k|        substream = pb_istream_from_buffer(buffer, size);
  851|       |        
  852|       |        return field->descriptor->field_callback(&substream, NULL, field);
  853|  4.43k|    }
  854|  5.89k|}
pb_decode.c:read_raw_value:
  342|  4.43k|{
  343|  4.43k|    size_t max_size = *size;
  344|  4.43k|    switch (wire_type)
  345|  4.43k|    {
  346|  2.95k|        case PB_WT_VARINT:
  ------------------
  |  Branch (346:9): [True: 2.95k, False: 1.48k]
  ------------------
  347|  2.95k|            *size = 0;
  348|  2.95k|            do
  349|  3.96k|            {
  350|  3.96k|                (*size)++;
  351|  3.96k|                if (*size > max_size)
  ------------------
  |  Branch (351:21): [True: 4, False: 3.95k]
  ------------------
  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|  3.95k|                if (!pb_read(stream, buf, 1))
  ------------------
  |  Branch (354:21): [True: 31, False: 3.92k]
  ------------------
  355|     31|                    return false;
  356|  3.95k|            } while (*buf++ & 0x80);
  ------------------
  |  Branch (356:22): [True: 1.00k, False: 2.91k]
  ------------------
  357|  2.91k|            return true;
  358|       |            
  359|    830|        case PB_WT_64BIT:
  ------------------
  |  Branch (359:9): [True: 830, False: 3.60k]
  ------------------
  360|    830|            *size = 8;
  361|    830|            return pb_read(stream, buf, 8);
  362|       |        
  363|    647|        case PB_WT_32BIT:
  ------------------
  |  Branch (363:9): [True: 647, False: 3.78k]
  ------------------
  364|    647|            *size = 4;
  365|    647|            return pb_read(stream, buf, 4);
  366|       |        
  367|      0|        case PB_WT_STRING:
  ------------------
  |  Branch (367:9): [True: 0, False: 4.43k]
  ------------------
  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.43k]
  ------------------
  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|      4|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (379:9): [True: 4, False: 4.43k]
  ------------------
  380|  4.43k|    }
  381|  4.43k|}
pb_decode.c:pb_release_single_field:
 1288|  1.13M|{
 1289|  1.13M|    pb_type_t type;
 1290|  1.13M|    type = field->type;
 1291|       |
 1292|  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 (1292:9): [True: 79.1k, False: 1.05M]
  ------------------
 1293|  79.1k|    {
 1294|  79.1k|        if (*(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (1294:13): [True: 62.1k, False: 16.9k]
  ------------------
 1295|  62.1k|            return; /* This is not the current field in the union */
 1296|  79.1k|    }
 1297|       |
 1298|       |    /* Release anything contained inside an extension or submsg.
 1299|       |     * This has to be done even if the submsg itself is statically
 1300|       |     * allocated. */
 1301|  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 (1301:9): [True: 9.13k, False: 1.06M]
  ------------------
 1302|  9.13k|    {
 1303|       |        /* Release fields from all extensions in the linked list */
 1304|  9.13k|        pb_extension_t *ext = *(pb_extension_t**)field->pData;
 1305|  16.5k|        while (ext != NULL)
  ------------------
  |  Branch (1305:16): [True: 7.43k, False: 9.13k]
  ------------------
 1306|  7.43k|        {
 1307|  7.43k|            pb_field_iter_t ext_iter;
 1308|  7.43k|            if (ext->type->decode == NULL &&
  ------------------
  |  Branch (1308:17): [True: 7.43k, False: 0]
  ------------------
 1309|  7.43k|                pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (1309:17): [True: 7.43k, False: 0]
  ------------------
 1310|  7.43k|            {
 1311|  7.43k|                pb_release_single_field(&ext_iter);
 1312|  7.43k|            }
 1313|  7.43k|            ext = ext->next;
 1314|  7.43k|        }
 1315|  9.13k|    }
 1316|  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: 926k]
  |  |  ------------------
  |  |  330|  2.12M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|   926k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|   926k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|   926k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 926k]
  |  |  ------------------
  ------------------
                  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 (1316:42): [True: 133k, False: 2.10k]
  ------------------
 1317|   133k|    {
 1318|       |        /* Release fields in submessage or submsg array */
 1319|   133k|        pb_size_t count = 1;
 1320|       |        
 1321|   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 (1321:13): [True: 123k, False: 10.2k]
  ------------------
 1322|   123k|        {
 1323|   123k|            field->pData = *(void**)field->pField;
 1324|   123k|        }
 1325|  10.2k|        else
 1326|  10.2k|        {
 1327|  10.2k|            field->pData = field->pField;
 1328|  10.2k|        }
 1329|       |        
 1330|   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 (1330:13): [True: 18.2k, False: 115k]
  ------------------
 1331|  18.2k|        {
 1332|  18.2k|            count = *(pb_size_t*)field->pSize;
 1333|       |
 1334|  18.2k|            if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  326|  18.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  18.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  321|  36.5k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1334:17): [True: 0, False: 18.2k]
  |  Branch (1334:54): [True: 0, False: 0]
  ------------------
 1335|      0|            {
 1336|       |                /* Protect against corrupted _count fields */
 1337|      0|                count = field->array_size;
 1338|      0|            }
 1339|  18.2k|        }
 1340|       |        
 1341|   133k|        if (field->pData)
  ------------------
  |  Branch (1341:13): [True: 87.2k, False: 46.1k]
  ------------------
 1342|  87.2k|        {
 1343|   281k|            for (; count > 0; count--)
  ------------------
  |  Branch (1343:20): [True: 194k, False: 87.2k]
  ------------------
 1344|   194k|            {
 1345|   194k|                pb_release(field->submsg_desc, field->pData);
 1346|   194k|                field->pData = (char*)field->pData + field->data_size;
 1347|   194k|            }
 1348|  87.2k|        }
 1349|   133k|    }
 1350|       |    
 1351|  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 (1351:9): [True: 1.03M, False: 31.1k]
  ------------------
 1352|  1.03M|    {
 1353|  1.03M|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  327|  1.03M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.03M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  314|  2.07M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1353:13): [True: 191k, False: 847k]
  ------------------
 1354|   191k|            (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|   191k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   191k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|   383k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (1354:14): [True: 9.13k, False: 182k]
  ------------------
 1355|   182k|             PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  328|   182k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   182k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                           PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  280|   182k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (1355:14): [True: 9.13k, False: 173k]
  ------------------
 1356|  18.2k|        {
 1357|       |            /* Release entries in repeated string or bytes array */
 1358|  18.2k|            void **pItem = *(void***)field->pField;
 1359|  18.2k|            pb_size_t count = *(pb_size_t*)field->pSize;
 1360|   574k|            for (; count > 0; count--)
  ------------------
  |  Branch (1360:20): [True: 556k, False: 18.2k]
  ------------------
 1361|   556k|            {
 1362|   556k|                pb_free(*pItem);
  ------------------
  |  |    4|   556k|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1363|   556k|                *pItem++ = NULL;
 1364|   556k|            }
 1365|  18.2k|        }
 1366|       |        
 1367|  1.03M|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|  1.03M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  1.03M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|  1.03M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1367:13): [True: 191k, False: 847k]
  ------------------
 1368|   191k|        {
 1369|       |            /* We are going to release the array, so set the size to 0 */
 1370|   191k|            *(pb_size_t*)field->pSize = 0;
 1371|   191k|        }
 1372|       |        
 1373|       |        /* Release main pointer */
 1374|  1.03M|        pb_free(*(void**)field->pField);
  ------------------
  |  |    4|  1.03M|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1375|       |        *(void**)field->pField = NULL;
 1376|  1.03M|    }
 1377|  1.07M|}

pb_ostream_from_buffer:
   73|  3.16k|{
   74|  3.16k|    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.16k|    stream.callback = &buf_write;
   83|  3.16k|#endif
   84|  3.16k|    stream.state = buf;
   85|  3.16k|    stream.max_size = bufsize;
   86|  3.16k|    stream.bytes_written = 0;
   87|  3.16k|#ifndef PB_NO_ERRMSG
   88|       |    stream.errmsg = NULL;
   89|  3.16k|#endif
   90|  3.16k|    return stream;
   91|  3.16k|}
pb_write:
   94|  40.2M|{
   95|  40.2M|    if (count > 0 && stream->callback != NULL)
  ------------------
  |  Branch (95:9): [True: 40.1M, False: 141k]
  |  Branch (95:22): [True: 36.1M, False: 4.02M]
  ------------------
   96|  36.1M|    {
   97|  36.1M|        if (stream->bytes_written + count < stream->bytes_written ||
  ------------------
  |  Branch (97:13): [True: 0, False: 36.1M]
  ------------------
   98|  36.1M|            stream->bytes_written + count > stream->max_size)
  ------------------
  |  Branch (98:13): [True: 200, False: 36.1M]
  ------------------
   99|    200|        {
  100|    200|            PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  930|    200|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|    200|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 200]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  101|    200|        }
  102|       |
  103|       |#ifdef PB_BUFFER_ONLY
  104|       |        if (!buf_write(stream, buf, count))
  105|       |            PB_RETURN_ERROR(stream, "io error");
  106|       |#else        
  107|  36.1M|        if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:13): [True: 0, False: 36.1M]
  ------------------
  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.1M|#endif
  110|  36.1M|    }
  111|       |    
  112|  40.2M|    stream->bytes_written += count;
  113|       |    return true;
  114|  40.2M|}
pb_encode:
  522|   111k|{
  523|   111k|    pb_field_iter_t iter;
  524|   111k|    if (!pb_field_iter_begin_const(&iter, fields, src_struct))
  ------------------
  |  Branch (524:9): [True: 34.3k, False: 76.9k]
  ------------------
  525|  34.3k|        return true; /* Empty message type */
  526|       |    
  527|   495k|    do {
  528|   495k|        if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  328|   495k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   495k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  297|   495k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (528:13): [True: 3.03k, False: 492k]
  ------------------
  529|  3.03k|        {
  530|       |            /* Special case for the extension field placeholder */
  531|  3.03k|            if (!encode_extension_field(stream, &iter))
  ------------------
  |  Branch (531:17): [True: 44, False: 2.99k]
  ------------------
  532|     44|                return false;
  533|  3.03k|        }
  534|   492k|        else
  535|   492k|        {
  536|       |            /* Regular field */
  537|   492k|            if (!encode_field(stream, &iter))
  ------------------
  |  Branch (537:17): [True: 193, False: 492k]
  ------------------
  538|    193|                return false;
  539|   492k|        }
  540|   495k|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (540:14): [True: 418k, False: 76.7k]
  ------------------
  541|       |    
  542|  76.7k|    return true;
  543|  76.9k|}
pb_encode_varint:
  617|  29.5M|{
  618|  29.5M|    if (value <= 0x7F)
  ------------------
  |  Branch (618:9): [True: 16.7M, False: 12.8M]
  ------------------
  619|  16.7M|    {
  620|       |        /* Fast path: single byte */
  621|  16.7M|        pb_byte_t byte = (pb_byte_t)value;
  622|  16.7M|        return pb_write(stream, &byte, 1);
  623|  16.7M|    }
  624|  12.8M|    else
  625|  12.8M|    {
  626|       |#ifdef PB_WITHOUT_64BIT
  627|       |        return pb_encode_varint_32(stream, value, 0);
  628|       |#else
  629|  12.8M|        return pb_encode_varint_32(stream, (uint32_t)value, (uint32_t)(value >> 32));
  630|  12.8M|#endif
  631|  12.8M|    }
  632|  29.5M|}
pb_encode_svarint:
  635|  2.88M|{
  636|  2.88M|    pb_uint64_t zigzagged;
  ------------------
  |  |   46|  2.88M|#define pb_uint64_t uint64_t
  ------------------
  637|  2.88M|    pb_uint64_t mask = ((pb_uint64_t)-1) >> 1; /* Satisfy clang -fsanitize=integer */
  ------------------
  |  |   46|  2.88M|#define pb_uint64_t uint64_t
  ------------------
  638|  2.88M|    if (value < 0)
  ------------------
  |  Branch (638:9): [True: 352k, False: 2.53M]
  ------------------
  639|   352k|        zigzagged = ~(((pb_uint64_t)value & mask) << 1);
  640|  2.53M|    else
  641|  2.53M|        zigzagged = (pb_uint64_t)value << 1;
  642|       |    
  643|  2.88M|    return pb_encode_varint(stream, zigzagged);
  644|  2.88M|}
pb_encode_fixed32:
  647|  22.0k|{
  648|  22.0k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
  649|       |    /* Fast path if we know that we're on little endian */
  650|  22.0k|    return pb_write(stream, (const pb_byte_t*)value, 4);
  651|       |#else
  652|       |    uint32_t val = *(const uint32_t*)value;
  653|       |    pb_byte_t bytes[4];
  654|       |    bytes[0] = (pb_byte_t)(val & 0xFF);
  655|       |    bytes[1] = (pb_byte_t)((val >> 8) & 0xFF);
  656|       |    bytes[2] = (pb_byte_t)((val >> 16) & 0xFF);
  657|       |    bytes[3] = (pb_byte_t)((val >> 24) & 0xFF);
  658|       |    return pb_write(stream, bytes, 4);
  659|       |#endif
  660|  22.0k|}
pb_encode_fixed64:
  664|  15.6k|{
  665|  15.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|  15.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|  15.6k|}
pb_encode_tag:
  685|  10.9M|{
  686|  10.9M|    pb_uint64_t tag = ((pb_uint64_t)field_number << 3) | wiretype;
  ------------------
  |  |   46|  10.9M|#define pb_uint64_t uint64_t
  ------------------
  687|  10.9M|    return pb_encode_varint(stream, tag);
  688|  10.9M|}
pb_encode_tag_for_field:
  691|  10.9M|{
  692|  10.9M|    pb_wire_type_t wiretype;
  693|  10.9M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|  10.9M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  10.9M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  694|  10.9M|    {
  695|  3.24k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|  3.24k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (695:9): [True: 3.24k, False: 10.9M]
  ------------------
  696|   129k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  269|   129k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (696:9): [True: 125k, False: 10.8M]
  ------------------
  697|   175k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|   175k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (697:9): [True: 46.3k, False: 10.9M]
  ------------------
  698|   194k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|   194k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (698:9): [True: 18.7k, False: 10.9M]
  ------------------
  699|   194k|            wiretype = PB_WT_VARINT;
  700|   194k|            break;
  701|       |        
  702|  17.0k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|  17.0k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (702:9): [True: 17.0k, False: 10.9M]
  ------------------
  703|  17.0k|            wiretype = PB_WT_32BIT;
  704|  17.0k|            break;
  705|       |        
  706|  9.72k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|  9.72k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (706:9): [True: 9.72k, False: 10.9M]
  ------------------
  707|  9.72k|            wiretype = PB_WT_64BIT;
  708|  9.72k|            break;
  709|       |        
  710|  89.6k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|  89.6k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (710:9): [True: 89.6k, False: 10.8M]
  ------------------
  711|   153k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|   153k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (711:9): [True: 63.5k, False: 10.9M]
  ------------------
  712|   207k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|   207k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (712:9): [True: 54.1k, False: 10.9M]
  ------------------
  713|   207k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|   207k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (713:9): [True: 0, False: 10.9M]
  ------------------
  714|  10.7M|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  303|  10.7M|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (714:9): [True: 10.5M, False: 428k]
  ------------------
  715|  10.7M|            wiretype = PB_WT_STRING;
  716|  10.7M|            break;
  717|       |        
  718|      0|        default:
  ------------------
  |  Branch (718:9): [True: 0, False: 10.9M]
  ------------------
  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|  10.9M|    }
  721|       |    
  722|  10.9M|    return pb_encode_tag(stream, wiretype, field->tag);
  723|  10.9M|}
pb_encode_string:
  726|  10.7M|{
  727|  10.7M|    if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (727:9): [True: 7, False: 10.7M]
  ------------------
  728|      7|        return false;
  729|       |    
  730|  10.7M|    return pb_write(stream, buffer, size);
  731|  10.7M|}
pb_encode_submessage:
  734|  54.0k|{
  735|       |    /* First calculate the message size using a non-writing substream. */
  736|  54.0k|    pb_ostream_t substream = PB_OSTREAM_SIZING;
  ------------------
  |  |  126|  54.0k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  737|  54.0k|#if !defined(PB_NO_ENCODE_SIZE_CHECK) || PB_NO_ENCODE_SIZE_CHECK == 0
  738|  54.0k|    bool status;
  739|  54.0k|    size_t size;
  740|  54.0k|#endif
  741|       |    
  742|  54.0k|    if (!pb_encode(&substream, fields, src_struct))
  ------------------
  |  Branch (742:9): [True: 0, False: 54.0k]
  ------------------
  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|  54.0k|    if (!pb_encode_varint(stream, (pb_uint64_t)substream.bytes_written))
  ------------------
  |  Branch (750:9): [True: 27, False: 54.0k]
  ------------------
  751|     27|        return false;
  752|       |    
  753|  54.0k|    if (stream->callback == NULL)
  ------------------
  |  Branch (753:9): [True: 0, False: 54.0k]
  ------------------
  754|      0|        return pb_write(stream, NULL, substream.bytes_written); /* Just sizing */
  755|       |    
  756|  54.0k|    if (stream->bytes_written + substream.bytes_written > stream->max_size)
  ------------------
  |  Branch (756:9): [True: 37, False: 54.0k]
  ------------------
  757|     37|        PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  930|     37|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  926|     37|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (926:53): [True: 0, False: 37]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|  54.0k|    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|  54.0k|    substream.callback = stream->callback;
  766|  54.0k|    substream.state = stream->state;
  767|  54.0k|    substream.max_size = size;
  768|  54.0k|    substream.bytes_written = 0;
  769|  54.0k|#ifndef PB_NO_ERRMSG
  770|  54.0k|    substream.errmsg = NULL;
  771|  54.0k|#endif
  772|       |    
  773|  54.0k|    status = pb_encode(&substream, fields, src_struct);
  774|       |    
  775|  54.0k|    stream->bytes_written += substream.bytes_written;
  776|  54.0k|    stream->state = substream.state;
  777|  54.0k|#ifndef PB_NO_ERRMSG
  778|  54.0k|    stream->errmsg = substream.errmsg;
  779|  54.0k|#endif
  780|       |    
  781|  54.0k|    if (substream.bytes_written != size)
  ------------------
  |  Branch (781:9): [True: 0, False: 54.0k]
  ------------------
  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|  54.0k|    return status;
  785|  54.0k|#endif
  786|  54.0k|}
pb_encode.c:buf_write:
   54|  36.1M|{
   55|  36.1M|    pb_byte_t *dest = (pb_byte_t*)stream->state;
   56|  36.1M|    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.1M|    if (buf != NULL)
  ------------------
  |  Branch (64:9): [True: 36.1M, False: 0]
  ------------------
   65|  36.1M|    {
   66|  36.1M|        memcpy(dest, buf, count * sizeof(pb_byte_t));
   67|  36.1M|    }
   68|       |
   69|       |    return true;
   70|  36.1M|}
pb_encode.c:encode_extension_field:
  497|  3.03k|{
  498|  3.03k|    const pb_extension_t *extension = *(const pb_extension_t* const *)field->pData;
  499|       |
  500|  6.02k|    while (extension)
  ------------------
  |  Branch (500:12): [True: 3.03k, False: 2.99k]
  ------------------
  501|  3.03k|    {
  502|  3.03k|        bool status;
  503|  3.03k|        if (extension->type->encode)
  ------------------
  |  Branch (503:13): [True: 0, False: 3.03k]
  ------------------
  504|      0|            status = extension->type->encode(stream, extension);
  505|  3.03k|        else
  506|  3.03k|            status = default_extension_encoder(stream, extension);
  507|       |
  508|  3.03k|        if (!status)
  ------------------
  |  Branch (508:13): [True: 44, False: 2.99k]
  ------------------
  509|     44|            return false;
  510|       |        
  511|  2.99k|        extension = extension->next;
  512|  2.99k|    }
  513|       |    
  514|  2.99k|    return true;
  515|  3.03k|}
pb_encode.c:default_extension_encoder:
  484|  3.03k|{
  485|  3.03k|    pb_field_iter_t iter;
  486|       |
  487|  3.03k|    if (!pb_field_iter_begin_extension_const(&iter, extension))
  ------------------
  |  Branch (487:9): [True: 0, False: 3.03k]
  ------------------
  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|  3.03k|    return encode_field(stream, &iter);
  491|  3.03k|}
pb_encode.c:encode_field:
  428|   495k|{
  429|       |    /* Check field presence */
  430|   495k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   495k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   495k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   495k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (430:9): [True: 21.6k, False: 473k]
  ------------------
  431|  21.6k|    {
  432|  21.6k|        if (*(const pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (432:13): [True: 21.0k, False: 595]
  ------------------
  433|  21.0k|        {
  434|       |            /* Different type oneof field */
  435|  21.0k|            return true;
  436|  21.0k|        }
  437|  21.6k|    }
  438|   473k|    else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  327|   473k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   473k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  312|   473k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (438:14): [True: 117k, False: 356k]
  ------------------
  439|   117k|    {
  440|   117k|        if (field->pSize)
  ------------------
  |  Branch (440:13): [True: 6.01k, False: 111k]
  ------------------
  441|  6.01k|        {
  442|  6.01k|            if (safe_read_bool(field->pSize) == false)
  ------------------
  |  Branch (442:17): [True: 5.81k, False: 197]
  ------------------
  443|  5.81k|            {
  444|       |                /* Missing optional field */
  445|  5.81k|                return true;
  446|  5.81k|            }
  447|  6.01k|        }
  448|   111k|        else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|   111k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   111k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|   111k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (448:18): [True: 0, False: 111k]
  ------------------
  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|   117k|    }
  455|       |
  456|   468k|    if (!field->pData)
  ------------------
  |  Branch (456:9): [True: 163k, False: 305k]
  ------------------
  457|   163k|    {
  458|   163k|        if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  327|   163k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   163k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  311|   163k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (458:13): [True: 0, False: 163k]
  ------------------
  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|   163k|        return true;
  463|   163k|    }
  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: 133, False: 305k]
  ------------------
  467|    133|    {
  468|    133|        return encode_callback_field(stream, field);
  469|    133|    }
  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.45k, False: 299k]
  ------------------
  471|  5.45k|    {
  472|  5.45k|        return encode_array(stream, field);
  473|  5.45k|    }
  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.25k|{
  126|  9.25k|    const char *p = (const char *)pSize;
  127|  9.25k|    size_t i;
  128|  16.7k|    for (i = 0; i < sizeof(bool); i++)
  ------------------
  |  Branch (128:17): [True: 9.25k, False: 7.52k]
  ------------------
  129|  9.25k|    {
  130|  9.25k|        if (p[i] != 0)
  ------------------
  |  Branch (130:13): [True: 1.73k, False: 7.52k]
  ------------------
  131|  1.73k|            return true;
  132|  9.25k|    }
  133|  7.52k|    return false;
  134|  9.25k|}
pb_encode.c:encode_callback_field:
  417|    133|{
  418|    133|    if (field->descriptor->field_callback != NULL)
  ------------------
  |  Branch (418:9): [True: 133, False: 0]
  ------------------
  419|    133|    {
  420|    133|        if (!field->descriptor->field_callback(NULL, stream, field))
  ------------------
  |  Branch (420:13): [True: 0, False: 133]
  ------------------
  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|    133|    }
  423|    133|    return true;
  424|    133|}
pb_encode.c:encode_array:
  138|  5.45k|{
  139|  5.45k|    pb_size_t i;
  140|  5.45k|    pb_size_t count;
  141|  5.45k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  142|  5.45k|    size_t size;
  143|  5.45k|#endif
  144|       |
  145|  5.45k|    count = *(pb_size_t*)field->pSize;
  146|       |
  147|  5.45k|    if (count == 0)
  ------------------
  |  Branch (147:9): [True: 0, False: 5.45k]
  ------------------
  148|      0|        return true;
  149|       |
  150|  5.45k|    if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  326|  5.45k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  5.45k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  322|  10.9k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (150:9): [True: 0, False: 5.45k]
  |  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.45k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  154|       |    /* We always pack arrays if the datatype allows it. */
  155|  5.45k|    if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  328|  5.45k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  5.45k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  276|  5.45k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (155:9): [True: 2.42k, False: 3.03k]
  ------------------
  156|  2.42k|    {
  157|  2.42k|        if (!pb_encode_tag(stream, PB_WT_STRING, field->tag))
  ------------------
  |  Branch (157:13): [True: 1, False: 2.41k]
  ------------------
  158|      1|            return false;
  159|       |        
  160|       |        /* Determine the total size of packed array. */
  161|  2.41k|        if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  328|  2.41k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  2.41k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  272|  2.41k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (161:13): [True: 372, False: 2.04k]
  ------------------
  162|    372|        {
  163|    372|            size = 4 * (size_t)count;
  164|    372|        }
  165|  2.04k|        else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  328|  2.04k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  2.04k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  273|  2.04k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (165:18): [True: 217, False: 1.83k]
  ------------------
  166|    217|        {
  167|    217|            size = 8 * (size_t)count;
  168|    217|        }
  169|  1.83k|        else
  170|  1.83k|        { 
  171|  1.83k|            pb_ostream_t sizestream = PB_OSTREAM_SIZING;
  ------------------
  |  |  126|  1.83k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  172|  1.83k|            void *pData_orig = field->pData;
  173|  3.80M|            for (i = 0; i < count; i++)
  ------------------
  |  Branch (173:25): [True: 3.80M, False: 1.83k]
  ------------------
  174|  3.80M|            {
  175|  3.80M|                if (!pb_enc_varint(&sizestream, field))
  ------------------
  |  Branch (175:21): [True: 0, False: 3.80M]
  ------------------
  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|  3.80M|                field->pData = (char*)field->pData + field->data_size;
  178|  3.80M|            }
  179|  1.83k|            field->pData = pData_orig;
  180|  1.83k|            size = sizestream.bytes_written;
  181|  1.83k|        }
  182|       |        
  183|  2.41k|        if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (183:13): [True: 3, False: 2.41k]
  ------------------
  184|      3|            return false;
  185|       |        
  186|  2.41k|        if (stream->callback == NULL)
  ------------------
  |  Branch (186:13): [True: 0, False: 2.41k]
  ------------------
  187|      0|            return pb_write(stream, NULL, size); /* Just sizing.. */
  188|       |        
  189|       |        /* Write the data */
  190|  3.79M|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (190:21): [True: 3.79M, False: 2.40k]
  ------------------
  191|  3.79M|        {
  192|  3.79M|            if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  328|  3.79M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  3.79M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  272|  7.58M|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  328|  3.78M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  3.78M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  273|  3.78M|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (192:17): [True: 4.93k, False: 3.78M]
  |  Branch (192:62): [True: 5.94k, False: 3.78M]
  ------------------
  193|  10.8k|            {
  194|  10.8k|                if (!pb_enc_fixed(stream, field))
  ------------------
  |  Branch (194:21): [True: 3, False: 10.8k]
  ------------------
  195|      3|                    return false;
  196|  10.8k|            }
  197|  3.78M|            else
  198|  3.78M|            {
  199|  3.78M|                if (!pb_enc_varint(stream, field))
  ------------------
  |  Branch (199:21): [True: 6, False: 3.78M]
  ------------------
  200|      6|                    return false;
  201|  3.78M|            }
  202|       |
  203|  3.79M|            field->pData = (char*)field->pData + field->data_size;
  204|  3.79M|        }
  205|  2.41k|    }
  206|  3.03k|    else /* Unpacked fields */
  207|  3.03k|#endif
  208|  3.03k|    {
  209|  10.6M|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (209:21): [True: 10.6M, False: 3.02k]
  ------------------
  210|  10.6M|        {
  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.6M|            if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  326|  10.6M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  10.6M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  322|  21.3M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (215:17): [True: 10.6M, False: 0]
  ------------------
  216|  10.6M|                (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  328|  10.6M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  10.6M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  284|  21.3M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (216:18): [True: 10.8k, False: 10.6M]
  ------------------
  217|  10.6M|                 PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  328|  10.6M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  10.6M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                               PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  280|  10.6M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (217:18): [True: 86.2k, False: 10.5M]
  ------------------
  218|  97.0k|            {
  219|  97.0k|                bool status;
  220|  97.0k|                void *pData_orig = field->pData;
  221|  97.0k|                field->pData = *(void* const*)field->pData;
  222|       |
  223|  97.0k|                if (!field->pData)
  ------------------
  |  Branch (223:21): [True: 0, False: 97.0k]
  ------------------
  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|  97.0k|                else
  230|  97.0k|                {
  231|  97.0k|                    status = encode_basic_field(stream, field);
  232|  97.0k|                }
  233|       |
  234|  97.0k|                field->pData = pData_orig;
  235|       |
  236|  97.0k|                if (!status)
  ------------------
  |  Branch (236:21): [True: 3, False: 97.0k]
  ------------------
  237|      3|                    return false;
  238|  97.0k|            }
  239|  10.5M|            else
  240|  10.5M|            {
  241|  10.5M|                if (!encode_basic_field(stream, field))
  ------------------
  |  Branch (241:21): [True: 13, False: 10.5M]
  ------------------
  242|     13|                    return false;
  243|  10.5M|            }
  244|  10.6M|            field->pData = (char*)field->pData + field->data_size;
  245|  10.6M|        }
  246|  3.03k|    }
  247|       |    
  248|  5.42k|    return true;
  249|  5.45k|}
pb_encode.c:pb_enc_varint:
  798|  7.77M|{
  799|  7.77M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  328|  7.77M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  7.77M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  270|  7.77M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (799:9): [True: 734k, False: 7.04M]
  ------------------
  800|   734k|    {
  801|       |        /* Perform unsigned integer extension */
  802|   734k|        pb_uint64_t value = 0;
  ------------------
  |  |   46|   734k|#define pb_uint64_t uint64_t
  ------------------
  803|       |
  804|   734k|        if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (804:13): [True: 6.14k, False: 728k]
  ------------------
  805|  6.14k|            value = *(const uint_least8_t*)field->pData;
  806|   728k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (806:18): [True: 6.14k, False: 722k]
  ------------------
  807|  6.14k|            value = *(const uint_least16_t*)field->pData;
  808|   722k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (808:18): [True: 261k, False: 460k]
  ------------------
  809|   261k|            value = *(const uint32_t*)field->pData;
  810|   460k|        else if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (810:18): [True: 460k, False: 0]
  ------------------
  811|   460k|            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|   734k|        return pb_encode_varint(stream, value);
  816|   734k|    }
  817|  7.04M|    else
  818|  7.04M|    {
  819|       |        /* Perform signed integer extension */
  820|  7.04M|        pb_int64_t value = 0;
  ------------------
  |  |   45|  7.04M|#define pb_int64_t int64_t
  ------------------
  821|       |
  822|  7.04M|        if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (822:13): [True: 1.14M, False: 5.89M]
  ------------------
  823|  1.14M|            value = *(const int_least8_t*)field->pData;
  824|  5.89M|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (824:18): [True: 12.2k, False: 5.88M]
  ------------------
  825|  12.2k|            value = *(const int_least16_t*)field->pData;
  826|  5.88M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (826:18): [True: 2.73M, False: 3.14M]
  ------------------
  827|  2.73M|            value = *(const int32_t*)field->pData;
  828|  3.14M|        else if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (828:18): [True: 3.14M, False: 0]
  ------------------
  829|  3.14M|            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.04M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  328|  7.04M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  7.04M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  271|  7.04M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (833:13): [True: 2.88M, False: 4.16M]
  ------------------
  834|  2.88M|            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.16M|        else
  840|  4.16M|            return pb_encode_varint(stream, (pb_uint64_t)value);
  841|       |
  842|  7.04M|    }
  843|  7.77M|}
pb_encode.c:pb_enc_fixed:
  846|  37.6k|{
  847|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  848|       |    if (field->data_size == sizeof(float) && PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  849|       |    {
  850|       |        return pb_encode_float_as_double(stream, *(float*)field->pData);
  851|       |    }
  852|       |#endif
  853|       |
  854|  37.6k|    if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (854:9): [True: 22.0k, False: 15.6k]
  ------------------
  855|  22.0k|    {
  856|  22.0k|        return pb_encode_fixed32(stream, field->pData);
  857|  22.0k|    }
  858|  15.6k|#ifndef PB_WITHOUT_64BIT
  859|  15.6k|    else if (field->data_size == sizeof(uint64_t))
  ------------------
  |  Branch (859:14): [True: 15.6k, False: 0]
  ------------------
  860|  15.6k|    {
  861|  15.6k|        return pb_encode_fixed64(stream, field->pData);
  862|  15.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|  37.6k|}
pb_encode.c:encode_basic_field:
  372|  10.9M|{
  373|  10.9M|    if (!field->pData)
  ------------------
  |  Branch (373:9): [True: 0, False: 10.9M]
  ------------------
  374|      0|    {
  375|       |        /* Missing pointer field */
  376|      0|        return true;
  377|      0|    }
  378|       |
  379|  10.9M|    if (!pb_encode_tag_for_field(stream, field))
  ------------------
  |  Branch (379:9): [True: 73, False: 10.9M]
  ------------------
  380|     73|        return false;
  381|       |
  382|  10.9M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  328|  10.9M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  10.9M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  383|  10.9M|    {
  384|  3.24k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  268|  3.24k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (384:9): [True: 3.24k, False: 10.9M]
  ------------------
  385|  3.24k|            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.8M]
  ------------------
  388|   172k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  270|   172k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (388:9): [True: 46.3k, False: 10.9M]
  ------------------
  389|   190k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  271|   190k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (389:9): [True: 18.7k, False: 10.9M]
  ------------------
  390|   190k|            return pb_enc_varint(stream, field);
  391|       |
  392|  17.0k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  272|  17.0k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (392:9): [True: 17.0k, False: 10.9M]
  ------------------
  393|  26.8k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  273|  26.8k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (393:9): [True: 9.72k, False: 10.9M]
  ------------------
  394|  26.8k|            return pb_enc_fixed(stream, field);
  395|       |
  396|  89.6k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  280|  89.6k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (396:9): [True: 89.6k, False: 10.8M]
  ------------------
  397|  89.6k|            return pb_enc_bytes(stream, field);
  398|       |
  399|  63.5k|        case PB_LTYPE_STRING:
  ------------------
  |  |  284|  63.5k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (399:9): [True: 63.5k, False: 10.9M]
  ------------------
  400|  63.5k|            return pb_enc_string(stream, field);
  401|       |
  402|  54.0k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  288|  54.0k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (402:9): [True: 54.0k, False: 10.9M]
  ------------------
  403|  54.0k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  293|  54.0k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (403:9): [True: 0, False: 10.9M]
  ------------------
  404|  54.0k|            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: 428k]
  ------------------
  407|  10.5M|            return pb_enc_fixed_length_bytes(stream, field);
  408|       |
  409|      0|        default:
  ------------------
  |  Branch (409:9): [True: 0, False: 10.9M]
  ------------------
  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|  10.9M|    }
  412|  10.9M|}
pb_encode.c:pb_enc_bool:
  791|  3.24k|{
  792|  3.24k|    uint32_t value = safe_read_bool(field->pData) ? 1 : 0;
  ------------------
  |  Branch (792:22): [True: 1.53k, False: 1.70k]
  ------------------
  793|  3.24k|    PB_UNUSED(field);
  ------------------
  |  |  172|  3.24k|#define PB_UNUSED(x) (void)(x)
  ------------------
  794|  3.24k|    return pb_encode_varint(stream, value);
  795|  3.24k|}
pb_encode.c:pb_enc_bytes:
  871|  89.6k|{
  872|  89.6k|    const pb_bytes_array_t *bytes = NULL;
  873|       |
  874|  89.6k|    bytes = (const pb_bytes_array_t*)field->pData;
  875|       |    
  876|  89.6k|    if (bytes == NULL)
  ------------------
  |  Branch (876:9): [True: 0, False: 89.6k]
  ------------------
  877|      0|    {
  878|       |        /* Treat null pointer as an empty bytes field */
  879|      0|        return pb_encode_string(stream, NULL, 0);
  880|      0|    }
  881|       |    
  882|  89.6k|    if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  326|  89.6k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  89.6k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  321|   179k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (882:9): [True: 0, False: 89.6k]
  ------------------
  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|  89.6k|    return pb_encode_string(stream, bytes->bytes, (size_t)bytes->size);
  889|  89.6k|}
pb_encode.c:pb_enc_string:
  892|  63.5k|{
  893|  63.5k|    size_t size = 0;
  894|  63.5k|    size_t max_size = (size_t)field->data_size;
  895|  63.5k|    const char *str = (const char*)field->pData;
  896|       |    
  897|  63.5k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|  63.5k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  63.5k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|  63.5k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (897:9): [True: 63.3k, False: 197]
  ------------------
  898|  63.3k|    {
  899|  63.3k|        max_size = (size_t)-1;
  900|  63.3k|    }
  901|    197|    else
  902|    197|    {
  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|    197|        if (max_size == 0)
  ------------------
  |  Branch (908:13): [True: 0, False: 197]
  ------------------
  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|    197|        max_size -= 1;
  912|    197|    }
  913|       |
  914|       |
  915|  63.5k|    if (str == NULL)
  ------------------
  |  Branch (915:9): [True: 0, False: 63.5k]
  ------------------
  916|      0|    {
  917|      0|        size = 0; /* Treat null pointer as an empty string */
  918|      0|    }
  919|  63.5k|    else
  920|  63.5k|    {
  921|  63.5k|        const char *p = str;
  922|       |
  923|       |        /* strnlen() is not always available, so just use a loop */
  924|   266k|        while (size < max_size && *p != '\0')
  ------------------
  |  Branch (924:16): [True: 266k, False: 16]
  |  Branch (924:35): [True: 203k, False: 63.5k]
  ------------------
  925|   203k|        {
  926|   203k|            size++;
  927|   203k|            p++;
  928|   203k|        }
  929|       |
  930|  63.5k|        if (*p != '\0')
  ------------------
  |  Branch (930:13): [True: 0, False: 63.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|  63.5k|    }
  935|       |
  936|       |#ifdef PB_VALIDATE_UTF8
  937|       |    if (!pb_validate_utf8(str))
  938|       |        PB_RETURN_ERROR(stream, "invalid utf8");
  939|       |#endif
  940|       |
  941|  63.5k|    return pb_encode_string(stream, (const pb_byte_t*)str, size);
  942|  63.5k|}
pb_encode.c:pb_enc_submessage:
  945|  54.0k|{
  946|  54.0k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (946:9): [True: 0, False: 54.0k]
  ------------------
  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|  54.0k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  328|  54.0k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  54.0k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  293|   108k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (949:9): [True: 0, False: 54.0k]
  |  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|  54.0k|    return pb_encode_submessage(stream, field->submsg_desc, field->pData);
  961|  54.0k|}
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|  12.8M|{
  584|  12.8M|    size_t i = 0;
  585|  12.8M|    pb_byte_t buffer[10];
  586|  12.8M|    pb_byte_t byte = (pb_byte_t)(low & 0x7F);
  587|  12.8M|    low >>= 7;
  588|       |
  589|  28.3M|    while (i < 4 && (low != 0 || high != 0))
  ------------------
  |  Branch (589:12): [True: 27.5M, False: 791k]
  |  Branch (589:22): [True: 15.4M, False: 12.0M]
  |  Branch (589:34): [True: 5.51k, False: 12.0M]
  ------------------
  590|  15.5M|    {
  591|  15.5M|        byte |= 0x80;
  592|  15.5M|        buffer[i++] = byte;
  593|  15.5M|        byte = (pb_byte_t)(low & 0x7F);
  594|  15.5M|        low >>= 7;
  595|  15.5M|    }
  596|       |
  597|  12.8M|    if (high)
  ------------------
  |  Branch (597:9): [True: 749k, False: 12.0M]
  ------------------
  598|   749k|    {
  599|   749k|        byte = (pb_byte_t)(byte | ((high & 0x07) << 4));
  600|   749k|        high >>= 3;
  601|       |
  602|  3.93M|        while (high)
  ------------------
  |  Branch (602:16): [True: 3.18M, False: 749k]
  ------------------
  603|  3.18M|        {
  604|  3.18M|            byte |= 0x80;
  605|  3.18M|            buffer[i++] = byte;
  606|  3.18M|            byte = (pb_byte_t)(high & 0x7F);
  607|  3.18M|            high >>= 7;
  608|  3.18M|        }
  609|   749k|    }
  610|       |
  611|  12.8M|    buffer[i++] = byte;
  612|       |
  613|  12.8M|    return pb_write(stream, buffer, i);
  614|  12.8M|}

malloc_with_check:
   58|  1.13M|{
   59|  1.13M|    const size_t check2 = CHECK2;
  ------------------
  |  |   18|  1.13M|#define CHECK2 ((size_t)0x600DCAFE)
  ------------------
   60|  1.13M|    char *buf = NULL;
   61|       |
   62|  1.13M|    if (size <= g_max_alloc_bytes - g_alloc_bytes)
  ------------------
  |  Branch (62:9): [True: 1.13M, False: 0]
  ------------------
   63|  1.13M|    {
   64|  1.13M|        buf = malloc(round_blocksize(size + GUARD_SIZE));
  ------------------
  |  |   15|  1.13M|#define GUARD_SIZE (sizeof(size_t)*3)
  ------------------
   65|  1.13M|    }
   66|       |
   67|  1.13M|    if (buf)
  ------------------
  |  Branch (67:9): [True: 1.13M, False: 0]
  ------------------
   68|  1.13M|    {
   69|  1.13M|        ((size_t*)buf)[0] = size;
   70|  1.13M|        ((size_t*)buf)[1] = CHECK1;
  ------------------
  |  |   17|  1.13M|#define CHECK1 ((size_t)0xDEADBEEF)
  ------------------
   71|  1.13M|        memcpy(buf + PREFIX_SIZE + size, &check2, sizeof(check2));
  ------------------
  |  |   16|  1.13M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   72|       |
   73|  1.13M|        g_alloc_count++;
   74|  1.13M|        g_alloc_bytes += size;
   75|  1.13M|        if (DEBUG_MALLOC) fprintf(stderr, "Alloc 0x%04x/%u\n", (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   25|  1.13M|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (25:22): [Folded, False: 1.13M]
  |  |  ------------------
  ------------------
                      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.13M|        return buf + PREFIX_SIZE;
  ------------------
  |  |   16|  1.13M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   77|  1.13M|    }
   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.13M|}
free_with_check:
   87|  1.60M|{
   88|  1.60M|    if (mem)
  ------------------
  |  Branch (88:9): [True: 1.13M, False: 474k]
  ------------------
   89|  1.13M|    {
   90|  1.13M|        char *buf = (char*)mem - PREFIX_SIZE;
  ------------------
  |  |   16|  1.13M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   91|  1.13M|        size_t check2 = 0;
   92|  1.13M|        size_t size = ((size_t*)buf)[0];
   93|  1.13M|        if (DEBUG_MALLOC) fprintf(stderr, "Release 0x%04x/%u\n", (unsigned)(uintptr_t)mem, (unsigned)size);
  ------------------
  |  |   25|  1.13M|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (25:22): [Folded, False: 1.13M]
  |  |  ------------------
  ------------------
   94|  1.13M|        assert(((size_t*)buf)[1] == CHECK1);
  ------------------
  |  Branch (94:9): [True: 0, False: 1.13M]
  |  Branch (94:9): [True: 1.13M, False: 0]
  ------------------
   95|  1.13M|        memcpy(&check2, buf + PREFIX_SIZE + size, sizeof(check2));
  ------------------
  |  |   16|  1.13M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   96|  1.13M|        assert(check2 == CHECK2);
  ------------------
  |  Branch (96:9): [True: 0, False: 1.13M]
  |  Branch (96:9): [True: 1.13M, False: 0]
  ------------------
   97|  1.13M|        assert(g_alloc_count > 0);
  ------------------
  |  Branch (97:9): [True: 0, False: 1.13M]
  |  Branch (97:9): [True: 1.13M, False: 0]
  ------------------
   98|  1.13M|        assert(g_alloc_bytes >= size);
  ------------------
  |  Branch (98:9): [True: 0, False: 1.13M]
  |  Branch (98:9): [True: 1.13M, False: 0]
  ------------------
   99|  1.13M|        ((size_t*)buf)[1] = 0;
  100|  1.13M|        memset(buf + PREFIX_SIZE + size, 0, sizeof(check2));
  ------------------
  |  |   16|  1.13M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  101|  1.13M|        g_alloc_count--;
  102|  1.13M|        g_alloc_bytes -= size;
  103|  1.13M|        free(buf);
  104|  1.13M|    }
  105|  1.60M|}
realloc_with_check:
  109|  33.3M|{
  110|  33.3M|    if (!ptr && size)
  ------------------
  |  Branch (110:9): [True: 1.12M, False: 32.2M]
  |  Branch (110:17): [True: 1.12M, False: 0]
  ------------------
  111|  1.12M|    {
  112|       |        /* Allocate new block and write guard values */
  113|  1.12M|        return malloc_with_check(size);
  114|  1.12M|    }
  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: 329k, False: 31.9M]
  ------------------
  133|   329k|            {
  134|   329k|                buf = realloc(buf, new_rounded);
  135|   329k|            }
  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.3M|}
get_alloc_count:
  172|  19.5k|{
  173|  19.5k|    return g_alloc_count;
  174|  19.5k|}
get_allocation_size:
  178|   694k|{
  179|   694k|    char *buf = (char*)mem - PREFIX_SIZE;
  ------------------
  |  |   16|   694k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  180|   694k|    return ((size_t*)buf)[0];
  181|   694k|}
malloc_wrappers.c:round_blocksize:
   39|  65.6M|{
   40|  65.6M|    if (size < 256)
  ------------------
  |  Branch (40:9): [True: 3.67M, False: 61.9M]
  ------------------
   41|  3.67M|    {
   42|  3.67M|        return size;
   43|  3.67M|    }
   44|  61.9M|    else
   45|  61.9M|    {
   46|  61.9M|        return (size + 1023) / 1024 * 1024;
   47|  61.9M|    }
   48|  65.6M|}

flakystream_callback:
    5|  34.5M|{
    6|  34.5M|    flakystream_t *state = stream->state;
    7|       |
    8|  34.5M|    if (state->position + count > state->msglen)
  ------------------
  |  Branch (8:9): [True: 1.69k, False: 34.5M]
  ------------------
    9|  1.69k|    {
   10|  1.69k|        stream->bytes_left = 0;
   11|  1.69k|        return false;
   12|  1.69k|    }
   13|  34.5M|    else if (state->position + count > state->fail_after)
  ------------------
  |  Branch (13:14): [True: 0, False: 34.5M]
  ------------------
   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|  34.5M|    memcpy(buf, state->buffer + state->position, count);
   19|  34.5M|    state->position += count;
   20|       |    return true;
   21|  34.5M|}
flakystream_init:
   24|  1.69k|{
   25|  1.69k|    memset(stream, 0, sizeof(*stream));
   26|  1.69k|    stream->stream.callback = flakystream_callback;
   27|       |    stream->stream.bytes_left = SIZE_MAX;
   28|  1.69k|    stream->stream.state = stream;
   29|  1.69k|    stream->buffer = buffer;
   30|  1.69k|    stream->position = 0;
   31|  1.69k|    stream->msglen = msglen;
   32|  1.69k|    stream->fail_after = fail_after;
   33|  1.69k|}

do_roundtrip:
  210|  1.69k|{
  211|  1.69k|    bool status;
  212|  1.69k|    uint32_t checksum2, checksum3;
  213|  1.69k|    size_t msglen2, msglen3;
  214|  1.69k|    uint8_t *buf2 = malloc_with_check(g_bufsize);
  215|  1.69k|    void *msg = malloc_with_check(structsize);
  216|       |
  217|       |    /* For proto2 types, we also test extension fields */
  218|  1.69k|    alltypes_static_TestExtension extmsg = alltypes_static_TestExtension_init_zero;
  ------------------
  |  |  260|  1.69k|#define alltypes_static_TestExtension_init_zero  {false, ""}
  ------------------
  219|  1.69k|    pb_extension_t ext = pb_extension_init_zero;
  ------------------
  |  |  513|  1.69k|#define pb_extension_init_zero {NULL,NULL,NULL,false}
  ------------------
  220|  1.69k|    pb_extension_t **ext_field = NULL;
  221|  1.69k|    ext.type = &alltypes_static_TestExtension_testextension;
  222|  1.69k|    ext.dest = &extmsg;
  223|  1.69k|    ext.next = NULL;
  224|       |
  225|  1.69k|    assert(buf2 && msg);
  ------------------
  |  Branch (225:5): [True: 0, False: 1.69k]
  |  Branch (225:5): [True: 0, False: 0]
  |  Branch (225:5): [True: 1.69k, False: 0]
  |  Branch (225:5): [True: 1.69k, False: 0]
  ------------------
  226|       |
  227|  1.69k|    if (msgtype == alltypes_static_AllTypes_fields)
  ------------------
  |  |  520|  1.69k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (227:9): [True: 0, False: 1.69k]
  ------------------
  228|      0|    {
  229|      0|        ext_field = &((alltypes_static_AllTypes*)msg)->extensions;
  230|      0|    }
  231|  1.69k|    else if (msgtype == alltypes_pointer_AllTypes_fields)
  ------------------
  |  |  494|  1.69k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  |  Branch (231:14): [True: 1.69k, False: 0]
  ------------------
  232|  1.69k|    {
  233|  1.69k|        ext_field = &((alltypes_pointer_AllTypes*)msg)->extensions;
  234|  1.69k|    }
  235|       |    
  236|       |    /* Decode and encode the input data.
  237|       |     * This will bring it into canonical format.
  238|       |     */
  239|  1.69k|    {
  240|  1.69k|        pb_istream_t stream = pb_istream_from_buffer(buffer, msglen);
  241|  1.69k|        memset(msg, 0, structsize);
  242|  1.69k|        if (ext_field) *ext_field = &ext;
  ------------------
  |  Branch (242:13): [True: 1.69k, False: 0]
  ------------------
  243|  1.69k|        status = pb_decode(&stream, msgtype, msg);
  244|  1.69k|        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.69k]
  ------------------
  245|  1.69k|        assert(status);
  ------------------
  |  Branch (245:9): [True: 0, False: 1.69k]
  |  Branch (245:9): [True: 1.69k, False: 0]
  ------------------
  246|       |
  247|  1.69k|        validate_message(msg, structsize, msgtype);
  248|  1.69k|    }
  249|       |    
  250|  1.69k|    {
  251|  1.69k|        pb_ostream_t stream = pb_ostream_from_buffer(buf2, g_bufsize);
  252|  1.69k|        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.69k|        if (!status && strcmp(PB_GET_ERROR(&stream), "stream full") != 0)
  ------------------
  |  |  927|    237|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (927:31): [True: 237, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (256:13): [True: 237, False: 1.46k]
  |  Branch (256:24): [True: 0, False: 237]
  ------------------
  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.69k|        msglen2 = stream.bytes_written;
  263|  1.69k|        checksum2 = xor32_checksum(buf2, msglen2);
  264|  1.69k|    }
  265|       |    
  266|  1.69k|    pb_release(msgtype, msg);
  267|       |
  268|       |    /* Then decode from canonical format and re-encode. Result should remain the same. */
  269|  1.69k|    if (status)
  ------------------
  |  Branch (269:9): [True: 1.46k, False: 237]
  ------------------
  270|  1.46k|    {
  271|  1.46k|        pb_istream_t stream = pb_istream_from_buffer(buf2, msglen2);
  272|  1.46k|        memset(msg, 0, structsize);
  273|  1.46k|        if (ext_field) *ext_field = &ext;
  ------------------
  |  Branch (273:13): [True: 1.46k, False: 0]
  ------------------
  274|  1.46k|        status = pb_decode(&stream, msgtype, msg);
  275|  1.46k|        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.46k]
  ------------------
  276|  1.46k|        assert(status);
  ------------------
  |  Branch (276:9): [True: 0, False: 1.46k]
  |  Branch (276:9): [True: 1.46k, False: 0]
  ------------------
  277|       |
  278|  1.46k|        validate_message(msg, structsize, msgtype);
  279|  1.46k|    }
  280|       |    
  281|  1.69k|    if (status)
  ------------------
  |  Branch (281:9): [True: 1.46k, False: 237]
  ------------------
  282|  1.46k|    {
  283|  1.46k|        pb_ostream_t stream = pb_ostream_from_buffer(buf2, g_bufsize);
  284|  1.46k|        status = pb_encode(&stream, msgtype, msg);
  285|  1.46k|        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.46k]
  ------------------
  286|  1.46k|        assert(status);
  ------------------
  |  Branch (286:9): [True: 0, False: 1.46k]
  |  Branch (286:9): [True: 1.46k, False: 0]
  ------------------
  287|  1.46k|        msglen3 = stream.bytes_written;
  288|  1.46k|        checksum3 = xor32_checksum(buf2, msglen3);
  289|       |
  290|  1.46k|        assert(msglen2 == msglen3);
  ------------------
  |  Branch (290:9): [True: 0, False: 1.46k]
  |  Branch (290:9): [True: 1.46k, False: 0]
  ------------------
  291|  1.46k|        assert(checksum2 == checksum3);
  ------------------
  |  Branch (291:9): [True: 0, False: 1.46k]
  |  Branch (291:9): [True: 1.46k, False: 0]
  ------------------
  292|  1.46k|    }
  293|       |    
  294|  1.69k|    pb_release(msgtype, msg);
  295|  1.69k|    free_with_check(msg);
  296|  1.69k|    free_with_check(buf2);
  297|  1.69k|}
do_roundtrips:
  301|  4.03k|{
  302|  4.03k|    size_t initial_alloc_count = get_alloc_count();
  303|  4.03k|    PB_UNUSED(expect_valid); /* Potentially unused depending on configuration */
  ------------------
  |  |  172|  4.03k|#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|  4.03k|#ifdef FUZZTEST_PROTO2_POINTER
  323|  4.03k|    if (do_decode(data, size, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, 0, expect_valid))
  ------------------
  |  |  494|  4.03k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  |  Branch (323:9): [True: 1.69k, False: 2.33k]
  ------------------
  324|  1.69k|    {
  325|  1.69k|        do_roundtrip(data, size, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields);
  ------------------
  |  |  494|  1.69k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  326|  1.69k|        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, 0, true);
  ------------------
  |  |  494|  1.69k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  327|  1.69k|    }
  328|  4.03k|#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: 4.03k]
  |  Branch (360:5): [True: 4.03k, False: 0]
  ------------------
  361|  4.03k|}
LLVMFuzzerTestOneInput:
  365|  4.04k|{
  366|  4.04k|    if (size > g_bufsize)
  ------------------
  |  Branch (366:9): [True: 4, False: 4.03k]
  ------------------
  367|      4|        return 0;
  368|       |
  369|  4.03k|    do_roundtrips(data, size, false);
  370|       |
  371|  4.03k|    return 0;
  372|  4.04k|}
fuzztest.c:xor32_checksum:
   53|  3.16k|{
   54|  3.16k|    const uint8_t *buf = (const uint8_t*)data;
   55|  3.16k|    uint32_t checksum = 1234;
   56|  85.5M|    for (; len > 0; len--)
  ------------------
  |  Branch (56:12): [True: 85.5M, False: 3.16k]
  ------------------
   57|  85.5M|    {
   58|  85.5M|        checksum ^= checksum << 13;
   59|  85.5M|        checksum ^= checksum >> 17;
   60|  85.5M|        checksum ^= checksum << 5;
   61|  85.5M|        checksum += *buf++;
   62|  85.5M|    }
   63|  3.16k|    return checksum;
   64|  3.16k|}
fuzztest.c:do_decode:
   67|  4.03k|{
   68|  4.03k|    bool status;
   69|  4.03k|    pb_istream_t stream;
   70|  4.03k|    size_t initial_alloc_count = get_alloc_count();
   71|  4.03k|    uint8_t *buf2 = malloc_with_check(g_bufsize); /* This is just to match the amount of memory allocations in do_roundtrips(). */
   72|  4.03k|    void *msg = malloc_with_check(structsize);
   73|  4.03k|    alltypes_static_TestExtension extmsg = alltypes_static_TestExtension_init_zero;
  ------------------
  |  |  260|  4.03k|#define alltypes_static_TestExtension_init_zero  {false, ""}
  ------------------
   74|  4.03k|    pb_extension_t ext = pb_extension_init_zero;
  ------------------
  |  |  513|  4.03k|#define pb_extension_init_zero {NULL,NULL,NULL,false}
  ------------------
   75|  4.03k|    assert(msg);
  ------------------
  |  Branch (75:5): [True: 0, False: 4.03k]
  |  Branch (75:5): [True: 4.03k, False: 0]
  ------------------
   76|       |
   77|  4.03k|    memset(msg, 0, structsize);
   78|  4.03k|    ext.type = &alltypes_static_TestExtension_testextension;
   79|  4.03k|    ext.dest = &extmsg;
   80|  4.03k|    ext.next = NULL;
   81|       |
   82|  4.03k|    if (msgtype == alltypes_static_AllTypes_fields)
  ------------------
  |  |  520|  4.03k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (82:9): [True: 0, False: 4.03k]
  ------------------
   83|      0|    {
   84|      0|        ((alltypes_static_AllTypes*)msg)->extensions = &ext;
   85|      0|    }
   86|  4.03k|    else if (msgtype == alltypes_pointer_AllTypes_fields)
  ------------------
  |  |  494|  4.03k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  |  Branch (86:14): [True: 4.03k, False: 0]
  ------------------
   87|  4.03k|    {
   88|  4.03k|        ((alltypes_pointer_AllTypes*)msg)->extensions = &ext;
   89|  4.03k|    }
   90|       |
   91|  4.03k|    stream = pb_istream_from_buffer(buffer, msglen);
   92|  4.03k|    status = pb_decode_ex(&stream, msgtype, msg, flags);
   93|       |
   94|  4.03k|    if (status)
  ------------------
  |  Branch (94:9): [True: 1.69k, False: 2.33k]
  ------------------
   95|  1.69k|    {
   96|  1.69k|        validate_message(msg, structsize, msgtype);
   97|  1.69k|    }
   98|       |
   99|  4.03k|    if (assert_success)
  ------------------
  |  Branch (99:9): [True: 0, False: 4.03k]
  ------------------
  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|  4.03k|    if (status)
  ------------------
  |  Branch (105:9): [True: 1.69k, False: 2.33k]
  ------------------
  106|  1.69k|    {
  107|       |        /* On error return, pb_release() should be called automatically. */
  108|  1.69k|        pb_release(msgtype, msg);
  109|  1.69k|    }
  110|       |
  111|  4.03k|    free_with_check(msg);
  112|  4.03k|    free_with_check(buf2);
  113|  4.03k|    assert(get_alloc_count() == initial_alloc_count);
  ------------------
  |  Branch (113:5): [True: 0, False: 4.03k]
  |  Branch (113:5): [True: 4.03k, False: 0]
  ------------------
  114|       |    
  115|  4.03k|    return status;
  116|  4.03k|}
fuzztest.c:do_stream_decode:
  119|  1.69k|{
  120|  1.69k|    bool status;
  121|  1.69k|    flakystream_t stream;
  122|  1.69k|    size_t initial_alloc_count = get_alloc_count();
  123|  1.69k|    void *msg = malloc_with_check(structsize);
  124|  1.69k|    assert(msg);
  ------------------
  |  Branch (124:5): [True: 0, False: 1.69k]
  |  Branch (124:5): [True: 1.69k, False: 0]
  ------------------
  125|       |
  126|  1.69k|    memset(msg, 0, structsize);
  127|  1.69k|    flakystream_init(&stream, buffer, msglen, fail_after);
  128|  1.69k|    status = pb_decode_ex(&stream.stream, msgtype, msg, flags);
  129|       |
  130|  1.69k|    if (status)
  ------------------
  |  Branch (130:9): [True: 1.69k, False: 0]
  ------------------
  131|  1.69k|    {
  132|  1.69k|        validate_message(msg, structsize, msgtype);
  133|  1.69k|    }
  134|       |
  135|  1.69k|    if (assert_success)
  ------------------
  |  Branch (135:9): [True: 1.69k, False: 0]
  ------------------
  136|  1.69k|    {
  137|  1.69k|        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.69k]
  ------------------
  138|  1.69k|        assert(status);
  ------------------
  |  Branch (138:9): [True: 0, False: 1.69k]
  |  Branch (138:9): [True: 1.69k, False: 0]
  ------------------
  139|  1.69k|    }
  140|       |
  141|  1.69k|    if (status)
  ------------------
  |  Branch (141:9): [True: 1.69k, False: 0]
  ------------------
  142|  1.69k|    {
  143|       |        /* On error return, pb_release() should be called automatically. */
  144|  1.69k|        pb_release(msgtype, msg);
  145|  1.69k|    }
  146|       |
  147|  1.69k|    free_with_check(msg);
  148|  1.69k|    assert(get_alloc_count() == initial_alloc_count);
  ------------------
  |  Branch (148:5): [True: 0, False: 1.69k]
  |  Branch (148:5): [True: 1.69k, False: 0]
  ------------------
  149|       |
  150|  1.69k|    return status;
  151|  1.69k|}

validate_static:
    7|  19.6k|{
    8|  19.6k|    pb_size_t count = 1;
    9|  19.6k|    pb_size_t i;
   10|  19.6k|    bool truebool = true;
   11|  19.6k|    bool falsebool = false;
   12|       |
   13|  19.6k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  327|  19.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  19.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  314|  39.3k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 0, False: 19.6k]
  |  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.6k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  327|  19.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  19.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  312|  39.3k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 0, False: 19.6k]
  |  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.6k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|  19.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  19.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|  19.6k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 19.6k, False: 0]
  ------------------
   26|  19.6k|    {
   27|  19.6k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 19.2k, False: 387]
  ------------------
   28|  19.2k|        {
   29|       |            /* Some different field in oneof */
   30|  19.2k|            return;
   31|  19.2k|        }
   32|  19.6k|    }
   33|       |
   34|    774|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 387, False: 387]
  ------------------
   35|    387|    {
   36|    387|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|    387|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  328|    387|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|    387|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  284|    387|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 0, False: 387]
  ------------------
   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|    387|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|    387|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|    387|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|    387|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 0, False: 387]
  ------------------
   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|    387|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  328|    387|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|    387|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  268|    387|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 0, False: 387]
  ------------------
   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|    387|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  329|    387|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|    387|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|    387|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|    774|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 348, False: 39]
  |  |  ------------------
  |  |  330|    387|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|     39|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|     39|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|     39|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 39]
  |  |  ------------------
  ------------------
   56|    348|        {
   57|    348|            validate_message(pData, 0, iter->submsg_desc);
   58|    348|        }
   59|    387|    }
   60|    387|}
validate_pointer:
   63|   728k|{
   64|   728k|    pb_size_t count = 1;
   65|   728k|    pb_size_t i;
   66|   728k|    bool truebool = true;
   67|   728k|    bool falsebool = false;
   68|       |
   69|   728k|    if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  327|   728k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   728k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  316|   728k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (69:9): [True: 13.1k, False: 715k]
  ------------------
   70|  13.1k|    {
   71|  13.1k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (71:13): [True: 12.5k, False: 577]
  ------------------
   72|  12.5k|        {
   73|       |            /* Some different field in oneof */
   74|  12.5k|            return;
   75|  12.5k|        }
   76|  13.1k|    }
   77|   715k|    else if (!iter->pData)
  ------------------
  |  Branch (77:14): [True: 302k, False: 413k]
  ------------------
   78|   302k|    {
   79|       |        /* Nothing allocated */
   80|   302k|        if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize != &iter->array_size)
  ------------------
  |  |  327|   302k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   302k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize != &iter->array_size)
  ------------------
  |  |  314|   604k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (80:13): [True: 125k, False: 176k]
  |  Branch (80:58): [True: 113k, False: 12.7k]
  ------------------
   81|   113k|        {
   82|   113k|            assert(*(pb_size_t*)iter->pSize == 0);
  ------------------
  |  Branch (82:13): [True: 0, False: 113k]
  |  Branch (82:13): [True: 113k, False: 0]
  ------------------
   83|   113k|        }
   84|   302k|        return;
   85|   302k|    }
   86|       |
   87|   413k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   413k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   413k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   413k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (87:9): [True: 12.0k, False: 401k]
  ------------------
   88|  12.0k|    {
   89|       |        /* Check that enough memory has been allocated for array */
   90|  12.0k|        size_t allocated_size = get_allocation_size(iter->pData);
   91|  12.0k|        count = *(pb_size_t*)iter->pSize;
   92|  12.0k|        assert(allocated_size >= count * iter->data_size);
  ------------------
  |  Branch (92:9): [True: 0, False: 12.0k]
  |  Branch (92:9): [True: 12.0k, False: 0]
  ------------------
   93|  12.0k|    }
   94|   401k|    else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  328|   401k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   401k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  284|   803k|#define PB_LTYPE_STRING 0x07U
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  328|   338k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|   338k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  280|   338k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (94:14): [True: 338k, False: 63.9k]
  |  Branch (94:57): [True: 330k, False: 7.27k]
  ------------------
   95|   330k|    {
   96|   330k|        size_t allocated_size = get_allocation_size(iter->pData);
   97|   330k|        assert(allocated_size >= iter->data_size);
  ------------------
  |  Branch (97:9): [True: 0, False: 330k]
  |  Branch (97:9): [True: 330k, False: 0]
  ------------------
   98|   330k|    }
   99|       |
  100|  39.1M|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (100:17): [True: 38.7M, False: 413k]
  ------------------
  101|  38.7M|    {
  102|  38.7M|        void *pData = (char*)iter->pData + iter->data_size * i;
  103|       |
  104|  38.7M|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  328|  38.7M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  38.7M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  284|  38.7M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (104:13): [True: 87.1k, False: 38.6M]
  ------------------
  105|  87.1k|        {
  106|       |            /* Check that enough memory is allocated for string and that
  107|       |               the string is properly terminated. */
  108|  87.1k|            const char *str = pData;
  109|       |
  110|  87.1k|            if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|  87.1k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|  87.1k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|  87.1k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (110:17): [True: 23.1k, False: 63.9k]
  ------------------
  111|  23.1k|            {
  112|       |                /* String arrays are stored as array of pointers */
  113|  23.1k|                str = ((const char**)iter->pData)[i];
  114|  23.1k|            }
  115|       |
  116|  87.1k|            assert(strlen(str) + 1 <= get_allocation_size(str));
  ------------------
  |  Branch (116:13): [True: 0, False: 87.1k]
  |  Branch (116:13): [True: 87.1k, False: 0]
  ------------------
  117|  87.1k|        }
  118|  38.6M|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  328|  38.6M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  38.6M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  280|  38.6M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (118:18): [True: 264k, False: 38.3M]
  ------------------
  119|   264k|        {
  120|       |            /* Bytes length must be at most statically allocated size */
  121|   264k|            const pb_bytes_array_t *bytes = pData;
  122|       |
  123|   264k|            if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  327|   264k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  317|   264k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  314|   264k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (123:17): [True: 257k, False: 7.27k]
  ------------------
  124|   257k|            {
  125|       |                /* Bytes arrays are stored as array of pointers */
  126|   257k|                bytes = ((const pb_bytes_array_t**)iter->pData)[i];
  127|   257k|            }
  128|       |
  129|   264k|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= get_allocation_size(bytes));
  ------------------
  |  Branch (129:13): [True: 0, False: 264k]
  |  Branch (129:13): [True: 0, False: 264k]
  |  Branch (129:13): [True: 257k, False: 7.00k]
  |  Branch (129:13): [True: 264k, False: 0]
  ------------------
  130|   264k|        }
  131|  38.3M|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  328|  38.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  307|  38.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  268|  38.3M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (131:18): [True: 1.14M, False: 37.2M]
  ------------------
  132|  1.14M|        {
  133|       |            /* Bool fields must have valid value */
  134|  1.14M|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (134:13): [True: 1.14M, False: 0]
  |  Branch (134:13): [True: 0, False: 0]
  |  Branch (134:13): [True: 331k, False: 814k]
  |  Branch (134:13): [True: 814k, False: 0]
  ------------------
  135|  1.14M|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
  136|  1.14M|        }
  137|  37.2M|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  329|  37.2M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  328|  37.2M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  37.2M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  74.4M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (329:32): [True: 113k, False: 37.1M]
  |  |  ------------------
  |  |  330|  37.2M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  328|  37.1M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  307|  37.1M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  293|  37.1M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (330:32): [True: 0, False: 37.1M]
  |  |  ------------------
  ------------------
  138|   113k|        {
  139|   113k|            validate_message(pData, 0, iter->submsg_desc);
  140|   113k|        }
  141|  38.7M|    }
  142|   413k|}
validate_message:
  145|   120k|{
  146|   120k|    pb_field_iter_t iter;
  147|       |
  148|   120k|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 83.4k, False: 37.3k]
  ------------------
  149|  83.4k|    {
  150|  83.4k|        do
  151|   768k|        {
  152|   768k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  326|   768k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   768k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  321|   768k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 19.6k, False: 748k]
  ------------------
  153|  19.6k|            {
  154|  19.6k|                validate_static(&iter);
  155|  19.6k|            }
  156|   748k|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  326|   748k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   748k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  322|   748k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 728k, False: 19.6k]
  ------------------
  157|   728k|            {
  158|   728k|                validate_pointer(&iter);
  159|   728k|            }
  160|   768k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 684k, False: 83.4k]
  ------------------
  161|  83.4k|    }
  162|   120k|}

