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

pb_read:
   82|  3.07M|{
   83|  3.07M|    if (count == 0)
  ------------------
  |  Branch (83:9): [True: 191k, False: 2.88M]
  ------------------
   84|   191k|        return true;
   85|       |
   86|  2.88M|#ifndef PB_BUFFER_ONLY
   87|  2.88M|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (87:6): [True: 360k, False: 2.52M]
  |  Branch (87:21): [True: 81.4k, False: 278k]
  ------------------
   88|  81.4k|	{
   89|       |		/* Skip input bytes */
   90|  81.4k|		pb_byte_t tmp[16];
   91|   594k|		while (count > 16)
  ------------------
  |  Branch (91:10): [True: 512k, False: 81.4k]
  ------------------
   92|   512k|		{
   93|   512k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (93:8): [True: 0, False: 512k]
  ------------------
   94|      0|				return false;
   95|       |			
   96|   512k|			count -= 16;
   97|   512k|		}
   98|       |		
   99|  81.4k|		return pb_read(stream, tmp, count);
  100|  81.4k|	}
  101|  2.80M|#endif
  102|       |
  103|  2.80M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (103:9): [True: 232, False: 2.80M]
  ------------------
  104|    232|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  920|    232|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|    232|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 232]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  105|       |    
  106|  2.80M|#ifndef PB_BUFFER_ONLY
  107|  2.80M|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:9): [True: 0, False: 2.80M]
  ------------------
  108|      0|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|       |#else
  110|       |    if (!buf_read(stream, buf, count))
  111|       |        return false;
  112|       |#endif
  113|       |    
  114|  2.80M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (114:9): [True: 0, False: 2.80M]
  ------------------
  115|      0|        stream->bytes_left = 0;
  116|  2.80M|    else
  117|  2.80M|        stream->bytes_left -= count;
  118|       |
  119|       |    return true;
  120|  2.80M|}
pb_istream_from_buffer:
  143|   107k|{
  144|   107k|    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|   107k|    union {
  149|   107k|        void *state;
  150|   107k|        const void *c_state;
  151|   107k|    } state;
  152|       |#ifdef PB_BUFFER_ONLY
  153|       |    stream.callback = NULL;
  154|       |#else
  155|   107k|    stream.callback = &buf_read;
  156|   107k|#endif
  157|   107k|    state.c_state = buf;
  158|   107k|    stream.state = state.state;
  159|   107k|    stream.bytes_left = msglen;
  160|   107k|#ifndef PB_NO_ERRMSG
  161|       |    stream.errmsg = NULL;
  162|   107k|#endif
  163|   107k|    return stream;
  164|   107k|}
pb_decode_varint32:
  172|  9.68M|{
  173|  9.68M|    pb_byte_t byte;
  174|  9.68M|    uint32_t result;
  175|       |    
  176|  9.68M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (176:9): [True: 1.46k, False: 9.68M]
  ------------------
  177|  1.46k|    {
  178|  1.46k|        return false;
  179|  1.46k|    }
  180|       |    
  181|  9.68M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (181:9): [True: 8.41M, False: 1.26M]
  ------------------
  182|  8.41M|    {
  183|       |        /* Quick case, 1 byte value */
  184|  8.41M|        result = byte;
  185|  8.41M|    }
  186|  1.26M|    else
  187|  1.26M|    {
  188|       |        /* Multibyte case */
  189|  1.26M|        uint_fast8_t bitpos = 7;
  190|  1.26M|        result = byte & 0x7F;
  191|       |        
  192|  1.26M|        do
  193|  1.58M|        {
  194|  1.58M|            if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (194:17): [True: 44, False: 1.58M]
  ------------------
  195|     44|                return false;
  196|       |            
  197|  1.58M|            if (bitpos >= 32)
  ------------------
  |  Branch (197:17): [True: 17.8k, False: 1.57M]
  ------------------
  198|  17.8k|            {
  199|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  200|  17.8k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (200:44): [True: 17.4k, False: 469]
  ------------------
  201|  17.8k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (201:41): [True: 4.86k, False: 13.0k]
  ------------------
  202|  13.0k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (202:27): [True: 12.9k, False: 12]
  |  Branch (202:50): [True: 12.9k, False: 47]
  ------------------
  203|       |
  204|  17.8k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (204:21): [True: 2, False: 17.8k]
  |  Branch (204:37): [True: 58, False: 17.8k]
  ------------------
  205|     60|                {
  206|     60|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  920|     60|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     60|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 60]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  207|     60|                }
  208|  17.8k|            }
  209|  1.57M|            else if (bitpos == 28)
  ------------------
  |  Branch (209:22): [True: 13.6k, False: 1.55M]
  ------------------
  210|  13.6k|            {
  211|  13.6k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (211:21): [True: 4.68k, False: 8.99k]
  |  Branch (211:43): [True: 16, False: 4.66k]
  ------------------
  212|     16|                {
  213|     16|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  920|     16|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     16|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  214|     16|                }
  215|  13.6k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  216|  13.6k|            }
  217|  1.55M|            else
  218|  1.55M|            {
  219|  1.55M|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  220|  1.55M|            }
  221|  1.58M|            bitpos = (uint_fast8_t)(bitpos + 7);
  222|  1.58M|        } while (byte & 0x80);
  ------------------
  |  Branch (222:18): [True: 322k, False: 1.26M]
  ------------------
  223|  1.26M|   }
  224|       |   
  225|  9.68M|   *dest = result;
  226|       |   return true;
  227|  9.68M|}
pb_decode_varint:
  231|  5.72M|{
  232|  5.72M|    pb_byte_t byte;
  233|  5.72M|    uint_fast8_t bitpos = 0;
  234|  5.72M|    uint64_t result = 0;
  235|       |    
  236|  5.72M|    do
  237|  7.07M|    {
  238|  7.07M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (238:13): [True: 52, False: 7.07M]
  ------------------
  239|     52|            return false;
  240|       |
  241|  7.07M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (241:13): [True: 59.7k, False: 7.01M]
  |  Branch (241:29): [True: 27, False: 59.7k]
  ------------------
  242|     27|            PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  920|     27|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     27|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 27]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  243|       |
  244|  7.07M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  245|  7.07M|        bitpos = (uint_fast8_t)(bitpos + 7);
  246|  7.07M|    } while (byte & 0x80);
  ------------------
  |  Branch (246:14): [True: 1.34M, False: 5.72M]
  ------------------
  247|       |    
  248|  5.72M|    *dest = result;
  249|       |    return true;
  250|  5.72M|}
pb_decode_tag:
  279|  8.87M|{
  280|  8.87M|    uint32_t temp;
  281|  8.87M|    *eof = false;
  282|  8.87M|    *wire_type = (pb_wire_type_t) 0;
  283|  8.87M|    *tag = 0;
  284|       |
  285|  8.87M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (285:9): [True: 271k, False: 8.60M]
  ------------------
  286|   271k|    {
  287|   271k|        *eof = true;
  288|   271k|        return false;
  289|   271k|    }
  290|       |
  291|  8.60M|    if (!pb_decode_varint32(stream, &temp))
  ------------------
  |  Branch (291:9): [True: 1.43k, False: 8.60M]
  ------------------
  292|  1.43k|    {
  293|  1.43k|#ifndef PB_BUFFER_ONLY
  294|       |        /* Workaround for issue #1017
  295|       |         *
  296|       |         * Callback streams don't set bytes_left to 0 on eof until after being called by pb_decode_varint32,
  297|       |         * which results in "io error" being raised. This contrasts the behavior of buffer streams who raise
  298|       |         * no error on eof as bytes_left is already 0 on entry. This causes legitimate errors (e.g. missing
  299|       |         * required fields) to be incorrectly reported by callback streams.
  300|       |         */
  301|  1.43k|        if (stream->callback != buf_read && stream->bytes_left == 0)
  ------------------
  |  Branch (301:13): [True: 1.33k, False: 99]
  |  Branch (301:45): [True: 1.33k, False: 0]
  ------------------
  302|  1.33k|        {
  303|  1.33k|#ifndef PB_NO_ERRMSG
  304|  1.33k|            if (strcmp(stream->errmsg, "io error") == 0)
  ------------------
  |  Branch (304:17): [True: 1.33k, False: 0]
  ------------------
  305|  1.33k|                stream->errmsg = NULL;
  306|  1.33k|#endif
  307|  1.33k|            *eof = true;
  308|  1.33k|        }
  309|  1.43k|#endif
  310|  1.43k|        return false;
  311|  1.43k|    }
  312|       |    
  313|  8.60M|    *tag = temp >> 3;
  314|  8.60M|    *wire_type = (pb_wire_type_t)(temp & 7);
  315|       |    return true;
  316|  8.60M|}
pb_skip_field:
  319|  1.39M|{
  320|  1.39M|    switch (wire_type)
  321|  1.39M|    {
  322|   971k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (322:9): [True: 971k, False: 424k]
  ------------------
  323|  90.0k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (323:9): [True: 90.0k, False: 1.30M]
  ------------------
  324|   195k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (324:9): [True: 195k, False: 1.19M]
  ------------------
  325|   137k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (325:9): [True: 137k, False: 1.25M]
  ------------------
  326|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (326:2): [True: 0, False: 1.39M]
  ------------------
  327|       |            /* Calling pb_skip_field with a PB_WT_PACKED is an error.
  328|       |             * Explicitly handle this case and fallthrough to default to avoid
  329|       |             * compiler warnings.
  330|       |             */
  331|     93|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  920|     93|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     93|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 93]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (331:9): [True: 93, False: 1.39M]
  ------------------
  332|  1.39M|    }
  333|  1.39M|}
pb_make_string_substream:
  384|   358k|{
  385|   358k|    uint32_t size;
  386|   358k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (386:9): [True: 64, False: 358k]
  ------------------
  387|     64|        return false;
  388|       |    
  389|   358k|    *substream = *stream;
  390|   358k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (390:9): [True: 85, False: 358k]
  ------------------
  391|     85|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  920|     85|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     85|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 85]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  392|       |    
  393|   358k|    substream->bytes_left = (size_t)size;
  394|   358k|    stream->bytes_left -= (size_t)size;
  395|       |    return true;
  396|   358k|}
pb_close_string_substream:
  399|   358k|{
  400|   358k|    if (substream->bytes_left) {
  ------------------
  |  Branch (400:9): [True: 22.7k, False: 335k]
  ------------------
  401|  22.7k|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (401:13): [True: 0, False: 22.7k]
  ------------------
  402|      0|            return false;
  403|  22.7k|    }
  404|       |
  405|   358k|    stream->state = substream->state;
  406|       |
  407|   358k|#ifndef PB_NO_ERRMSG
  408|   358k|    stream->errmsg = substream->errmsg;
  409|   358k|#endif
  410|       |    return true;
  411|   358k|}
pb_decode_ex:
 1199|  8.42k|{
 1200|  8.42k|    bool status;
 1201|       |
 1202|  8.42k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  111|  8.42k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1202:9): [True: 8.42k, False: 0]
  ------------------
 1203|  8.42k|    {
 1204|  8.42k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1205|  8.42k|    }
 1206|      0|    else
 1207|      0|    {
 1208|      0|      pb_istream_t substream;
 1209|      0|      if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1209:11): [True: 0, False: 0]
  ------------------
 1210|      0|        return false;
 1211|       |
 1212|      0|      status = pb_decode_inner(&substream, fields, dest_struct, flags);
 1213|       |
 1214|      0|      if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1214:11): [True: 0, False: 0]
  ------------------
 1215|      0|        status = false;
 1216|      0|    }
 1217|       |    
 1218|       |#ifdef PB_ENABLE_MALLOC
 1219|       |    if (!status)
 1220|       |        pb_release(fields, dest_struct);
 1221|       |#endif
 1222|       |    
 1223|  8.42k|    return status;
 1224|  8.42k|}
pb_decode:
 1227|  4.01k|{
 1228|  4.01k|    return pb_decode_ex(stream, fields, dest_struct, 0);
 1229|  4.01k|}
pb_release:
 1372|  6.69k|{
 1373|       |    /* Nothing to release without PB_ENABLE_MALLOC. */
 1374|  6.69k|    PB_UNUSED(fields);
  ------------------
  |  |  169|  6.69k|#define PB_UNUSED(x) (void)(x)
  ------------------
 1375|  6.69k|    PB_UNUSED(dest_struct);
  ------------------
  |  |  169|  6.69k|#define PB_UNUSED(x) (void)(x)
  ------------------
 1376|  6.69k|}
pb_decode_bool:
 1382|   254k|{
 1383|   254k|    uint32_t value;
 1384|   254k|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1384:9): [True: 17, False: 254k]
  ------------------
 1385|     17|        return false;
 1386|       |
 1387|   254k|    *(bool*)dest = (value != 0);
 1388|       |    return true;
 1389|   254k|}
pb_decode_svarint:
 1392|   192k|{
 1393|   192k|    pb_uint64_t value;
  ------------------
  |  |   57|   192k|#define pb_uint64_t uint64_t
  ------------------
 1394|   192k|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1394:9): [True: 24, False: 192k]
  ------------------
 1395|     24|        return false;
 1396|       |    
 1397|   192k|    if (value & 1)
  ------------------
  |  Branch (1397:9): [True: 32.8k, False: 159k]
  ------------------
 1398|  32.8k|        *dest = (pb_int64_t)(~(value >> 1));
 1399|   159k|    else
 1400|   159k|        *dest = (pb_int64_t)(value >> 1);
 1401|       |    
 1402|       |    return true;
 1403|   192k|}
pb_decode_fixed32:
 1406|   294k|{
 1407|   294k|    union {
 1408|   294k|        uint32_t fixed32;
 1409|   294k|        pb_byte_t bytes[4];
 1410|   294k|    } u;
 1411|       |
 1412|   294k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1412:9): [True: 14, False: 294k]
  ------------------
 1413|     14|        return false;
 1414|       |
 1415|   294k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1416|       |    /* fast path - if we know that we're on little endian, assign directly */
 1417|   294k|    *(uint32_t*)dest = u.fixed32;
 1418|       |#else
 1419|       |    *(uint32_t*)dest = ((uint32_t)u.bytes[0] << 0) |
 1420|       |                       ((uint32_t)u.bytes[1] << 8) |
 1421|       |                       ((uint32_t)u.bytes[2] << 16) |
 1422|       |                       ((uint32_t)u.bytes[3] << 24);
 1423|       |#endif
 1424|       |    return true;
 1425|   294k|}
pb_decode_fixed64:
 1429|   237k|{
 1430|   237k|    union {
 1431|   237k|        uint64_t fixed64;
 1432|   237k|        pb_byte_t bytes[8];
 1433|   237k|    } u;
 1434|       |
 1435|   237k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1435:9): [True: 16, False: 237k]
  ------------------
 1436|     16|        return false;
 1437|       |
 1438|   237k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1439|       |    /* fast path - if we know that we're on little endian, assign directly */
 1440|   237k|    *(uint64_t*)dest = u.fixed64;
 1441|       |#else
 1442|       |    *(uint64_t*)dest = ((uint64_t)u.bytes[0] << 0) |
 1443|       |                       ((uint64_t)u.bytes[1] << 8) |
 1444|       |                       ((uint64_t)u.bytes[2] << 16) |
 1445|       |                       ((uint64_t)u.bytes[3] << 24) |
 1446|       |                       ((uint64_t)u.bytes[4] << 32) |
 1447|       |                       ((uint64_t)u.bytes[5] << 40) |
 1448|       |                       ((uint64_t)u.bytes[6] << 48) |
 1449|       |                       ((uint64_t)u.bytes[7] << 56);
 1450|       |#endif
 1451|       |    return true;
 1452|   237k|}
pb_decode.c:buf_read:
   69|  16.1M|{
   70|  16.1M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   71|  16.1M|    stream->state = (pb_byte_t*)stream->state + count;
   72|       |    
   73|  16.1M|    if (buf != NULL)
  ------------------
  |  Branch (73:9): [True: 15.8M, False: 278k]
  ------------------
   74|  15.8M|    {
   75|  15.8M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   76|  15.8M|    }
   77|       |    
   78|       |    return true;
   79|  16.1M|}
pb_decode.c:pb_readbyte:
  125|  18.3M|{
  126|  18.3M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (126:9): [True: 226, False: 18.3M]
  ------------------
  127|    226|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  920|    226|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|    226|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 226]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|       |
  129|  18.3M|#ifndef PB_BUFFER_ONLY
  130|  18.3M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (130:9): [True: 1.33k, False: 18.3M]
  ------------------
  131|  1.33k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  920|  1.33k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|  1.33k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 1.33k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|       |#else
  133|       |    *buf = *(const pb_byte_t*)stream->state;
  134|       |    stream->state = (pb_byte_t*)stream->state + 1;
  135|       |#endif
  136|       |
  137|  18.3M|    stream->bytes_left--;
  138|       |    
  139|       |    return true;    
  140|  18.3M|}
pb_decode.c:pb_skip_varint:
  254|   971k|{
  255|   971k|    pb_byte_t byte;
  256|   971k|    do
  257|  1.21M|    {
  258|  1.21M|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (258:13): [True: 71, False: 1.21M]
  ------------------
  259|     71|            return false;
  260|  1.21M|    } while (byte & 0x80);
  ------------------
  |  Branch (260:14): [True: 246k, False: 971k]
  ------------------
  261|   971k|    return true;
  262|   971k|}
pb_decode.c:pb_skip_string:
  265|   195k|{
  266|   195k|    uint32_t length;
  267|   195k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (267:9): [True: 57, False: 195k]
  ------------------
  268|     57|        return false;
  269|       |    
  270|   195k|    if ((size_t)length != length)
  ------------------
  |  Branch (270:9): [True: 0, False: 195k]
  ------------------
  271|      0|    {
  272|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  273|      0|    }
  274|       |
  275|   195k|    return pb_read(stream, NULL, (size_t)length);
  276|   195k|}
pb_decode.c:pb_decode_inner:
 1028|   274k|{
 1029|       |    /* If the message contains extension fields, the extension handlers
 1030|       |     * are called when tag number is >= extension_range_start. This precheck
 1031|       |     * is just for speed, and the handlers will check for precise match.
 1032|       |     */
 1033|   274k|    uint32_t extension_range_start = 0;
 1034|   274k|    pb_extension_t *extensions = NULL;
 1035|       |
 1036|       |    /* 'fixed_count_field' and 'fixed_count_size' track position of a repeated fixed
 1037|       |     * count field. This can only handle _one_ repeated fixed count field that
 1038|       |     * is unpacked and unordered among other (non repeated fixed count) fields.
 1039|       |     */
 1040|   274k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  339|   274k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
 1041|   274k|    pb_size_t fixed_count_size = 0;
 1042|   274k|    pb_size_t fixed_count_total_size = 0;
 1043|       |
 1044|       |    /* Tag and wire type of next field from the input stream */
 1045|   274k|    uint32_t tag;
 1046|   274k|    pb_wire_type_t wire_type;
 1047|   274k|    bool eof;
 1048|       |
 1049|       |    /* Track presence of required fields */
 1050|   274k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1051|   274k|    const uint32_t allbits = ~(uint32_t)0;
 1052|       |
 1053|       |    /* Descriptor for the structure field matching the tag decoded from stream */
 1054|   274k|    pb_field_iter_t iter;
 1055|       |
 1056|   274k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1056:9): [True: 147k, False: 126k]
  ------------------
 1057|   147k|    {
 1058|   147k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |  110|   147k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1058:13): [True: 12.5k, False: 135k]
  ------------------
 1059|  12.5k|        {
 1060|  12.5k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1060:17): [True: 0, False: 12.5k]
  ------------------
 1061|      0|                PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1062|  12.5k|        }
 1063|   147k|    }
 1064|       |
 1065|  8.32M|    while (pb_decode_tag(stream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1065:12): [True: 8.05M, False: 272k]
  ------------------
 1066|  8.05M|    {
 1067|  8.05M|        if (tag == 0)
  ------------------
  |  Branch (1067:13): [True: 58, False: 8.05M]
  ------------------
 1068|     58|        {
 1069|     58|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  112|     58|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1069:15): [True: 0, False: 58]
  ------------------
 1070|      0|          {
 1071|      0|            eof = true;
 1072|      0|            break;
 1073|      0|          }
 1074|     58|          else
 1075|     58|          {
 1076|     58|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  920|     58|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     58|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1077|     58|          }
 1078|     58|        }
 1079|       |
 1080|  8.05M|        if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|  6.65M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  6.65M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|  6.65M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1080:13): [True: 1.40M, False: 6.65M]
  |  Branch (1080:48): [True: 400, False: 6.65M]
  ------------------
 1081|  1.40M|        {
 1082|       |            /* No match found, check if it matches an extension. */
 1083|  1.40M|            if (extension_range_start == 0)
  ------------------
  |  Branch (1083:17): [True: 25.6k, False: 1.37M]
  ------------------
 1084|  25.6k|            {
 1085|  25.6k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1085:21): [True: 3.64k, False: 21.9k]
  ------------------
 1086|  3.64k|                {
 1087|  3.64k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1088|  3.64k|                    extension_range_start = iter.tag;
 1089|  3.64k|                }
 1090|       |
 1091|  25.6k|                if (!extensions)
  ------------------
  |  Branch (1091:21): [True: 22.8k, False: 2.73k]
  ------------------
 1092|  22.8k|                {
 1093|  22.8k|                    extension_range_start = (uint32_t)-1;
 1094|  22.8k|                }
 1095|  25.6k|            }
 1096|       |
 1097|  1.40M|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1097:17): [True: 136k, False: 1.26M]
  ------------------
 1098|   136k|            {
 1099|   136k|                size_t pos = stream->bytes_left;
 1100|       |
 1101|   136k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1101:21): [True: 42, False: 136k]
  ------------------
 1102|     42|                    return false;
 1103|       |
 1104|   136k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1104:21): [True: 5.74k, False: 130k]
  ------------------
 1105|  5.74k|                {
 1106|       |                    /* The field was handled */
 1107|  5.74k|                    continue;
 1108|  5.74k|                }
 1109|   136k|            }
 1110|       |
 1111|       |            /* No match found, skip data */
 1112|  1.39M|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1112:17): [True: 334, False: 1.39M]
  ------------------
 1113|    334|                return false;
 1114|  1.39M|            continue;
 1115|  1.39M|        }
 1116|       |
 1117|       |        /* If a repeated fixed count field was found, get size from
 1118|       |         * 'fixed_count_field' as there is no counter contained in the struct.
 1119|       |         */
 1120|  6.65M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  324|  6.65M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  6.65M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  311|  13.3M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1120:13): [True: 46.3k, False: 6.60M]
  |  Branch (1120:57): [True: 4.67k, False: 41.6k]
  ------------------
 1121|  4.67k|        {
 1122|  4.67k|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1122:17): [True: 4.19k, False: 489]
  ------------------
 1123|       |                /* If the new fixed count field does not match the previous one,
 1124|       |                 * check that the previous one is NULL or that it finished
 1125|       |                 * receiving all the expected data.
 1126|       |                 */
 1127|  4.19k|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  339|  8.38k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1127:21): [True: 2.54k, False: 1.65k]
  ------------------
 1128|  2.54k|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1128:21): [True: 3, False: 2.53k]
  ------------------
 1129|      3|                {
 1130|      3|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  920|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1131|      3|                }
 1132|       |
 1133|  4.18k|                fixed_count_field = iter.index;
 1134|  4.18k|                fixed_count_size = 0;
 1135|  4.18k|                fixed_count_total_size = iter.array_size;
 1136|  4.18k|            }
 1137|       |
 1138|  4.67k|            iter.pSize = &fixed_count_size;
 1139|  4.67k|        }
 1140|       |
 1141|  6.65M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  324|  6.65M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  6.65M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  308|  13.3M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1141:13): [True: 6.18M, False: 468k]
  ------------------
 1142|  6.18M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  230|  6.18M|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1142:16): [True: 6.18M, False: 0]
  ------------------
 1143|  6.18M|        {
 1144|  6.18M|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1145|  6.18M|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1146|  6.18M|        }
 1147|       |
 1148|  6.65M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1148:13): [True: 1.13k, False: 6.65M]
  ------------------
 1149|  1.13k|            return false;
 1150|  6.65M|    }
 1151|       |
 1152|   272k|    if (!eof)
  ------------------
  |  Branch (1152:9): [True: 99, False: 272k]
  ------------------
 1153|     99|    {
 1154|       |        /* pb_decode_tag() returned error before end of stream */
 1155|     99|        return false;
 1156|     99|    }
 1157|       |
 1158|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1159|   272k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  339|   544k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1159:9): [True: 1.60k, False: 270k]
  ------------------
 1160|  1.60k|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1160:9): [True: 6, False: 1.60k]
  ------------------
 1161|      6|    {
 1162|      6|        PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  920|      6|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      6|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1163|      6|    }
 1164|       |
 1165|       |    /* Check that all required fields were present. */
 1166|   272k|    {
 1167|   272k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1168|       |
 1169|   272k|        if (req_field_count > 0)
  ------------------
  |  Branch (1169:13): [True: 140k, False: 132k]
  ------------------
 1170|   140k|        {
 1171|   140k|            pb_size_t i;
 1172|       |
 1173|   140k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  230|   140k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1173:17): [True: 0, False: 140k]
  ------------------
 1174|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  230|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1175|       |
 1176|       |            /* Check the whole words */
 1177|   140k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1177:25): [True: 0, False: 140k]
  ------------------
 1178|      0|            {
 1179|      0|                if (fields_seen.bitfield[i] != allbits)
  ------------------
  |  Branch (1179:21): [True: 0, False: 0]
  ------------------
 1180|      0|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1181|      0|            }
 1182|       |
 1183|       |            /* Check the remaining bits (if any) */
 1184|   140k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1184:17): [True: 140k, False: 0]
  ------------------
 1185|   140k|            {
 1186|   140k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1186:21): [True: 310, False: 140k]
  ------------------
 1187|   140k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1188|    310|                {
 1189|    310|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  920|    310|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|    310|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 310]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1190|    310|                }
 1191|   140k|            }
 1192|   140k|        }
 1193|   272k|    }
 1194|       |
 1195|   272k|    return true;
 1196|   272k|}
pb_decode.c:pb_message_set_to_defaults:
  989|  98.1k|{
  990|  98.1k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   60|  98.1k|#define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
  991|  98.1k|    uint32_t tag = 0;
  992|  98.1k|    pb_wire_type_t wire_type = PB_WT_VARINT;
  993|  98.1k|    bool eof;
  994|       |
  995|  98.1k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (995:9): [True: 92.4k, False: 5.74k]
  ------------------
  996|  92.4k|    {
  997|  92.4k|        defstream = pb_istream_from_buffer(iter->descriptor->default_value, (size_t)-1);
  998|  92.4k|        if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (998:13): [True: 0, False: 92.4k]
  ------------------
  999|      0|            return false;
 1000|  92.4k|    }
 1001|       |
 1002|  98.1k|    do
 1003|   897k|    {
 1004|   897k|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (1004:13): [True: 0, False: 897k]
  ------------------
 1005|      0|            return false;
 1006|       |
 1007|   897k|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (1007:13): [True: 833k, False: 64.7k]
  |  Branch (1007:25): [True: 450k, False: 382k]
  ------------------
 1008|   450k|        {
 1009|       |            /* We have a default value for this field in the defstream */
 1010|   450k|            if (!decode_field(&defstream, wire_type, iter))
  ------------------
  |  Branch (1010:17): [True: 0, False: 450k]
  ------------------
 1011|      0|                return false;
 1012|   450k|            if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1012:17): [True: 0, False: 450k]
  ------------------
 1013|      0|                return false;
 1014|       |
 1015|   450k|            if (iter->pSize)
  ------------------
  |  Branch (1015:17): [True: 223k, False: 227k]
  ------------------
 1016|   223k|                *(bool*)iter->pSize = false;
 1017|   450k|        }
 1018|   897k|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (1018:14): [True: 799k, False: 98.1k]
  ------------------
 1019|       |
 1020|  98.1k|    return true;
 1021|  98.1k|}
pb_decode.c:pb_field_set_to_default:
  907|   897k|{
  908|   897k|    pb_type_t type;
  909|   897k|    type = field->type;
  910|       |
  911|   897k|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|   897k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   897k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|   897k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (911:9): [True: 8.42k, False: 889k]
  ------------------
  912|  8.42k|    {
  913|  8.42k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  914|  14.1k|        while (ext != NULL)
  ------------------
  |  Branch (914:16): [True: 5.74k, False: 8.42k]
  ------------------
  915|  5.74k|        {
  916|  5.74k|            pb_field_iter_t ext_iter;
  917|  5.74k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (917:17): [True: 5.74k, False: 0]
  ------------------
  918|  5.74k|            {
  919|  5.74k|                ext->found = false;
  920|  5.74k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (920:21): [True: 0, False: 5.74k]
  ------------------
  921|      0|                    return false;
  922|  5.74k|            }
  923|  5.74k|            ext = ext->next;
  924|  5.74k|        }
  925|  8.42k|    }
  926|   889k|    else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  323|   889k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   889k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  318|   889k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (926:14): [True: 836k, False: 52.7k]
  ------------------
  927|   836k|    {
  928|   836k|        bool init_data = true;
  929|   836k|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  324|   836k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   836k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  309|  1.67M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (929:13): [True: 240k, False: 596k]
  |  Branch (929:52): [True: 240k, False: 0]
  ------------------
  930|   240k|        {
  931|       |            /* Set has_field to false. Still initialize the optional field
  932|       |             * itself also. */
  933|   240k|            *(bool*)field->pSize = false;
  934|   240k|        }
  935|   596k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  324|   596k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   596k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  311|  1.19M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (935:18): [True: 148k, False: 447k]
  ------------------
  936|   447k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|   447k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   447k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|   447k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (936:18): [True: 25.2k, False: 422k]
  ------------------
  937|   174k|        {
  938|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
  939|       |               ONEOF: Set which_field to 0. */
  940|   174k|            *(pb_size_t*)field->pSize = 0;
  941|   174k|            init_data = false;
  942|   174k|        }
  943|       |
  944|   836k|        if (init_data)
  ------------------
  |  Branch (944:13): [True: 662k, False: 174k]
  ------------------
  945|   662k|        {
  946|   662k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  326|  1.32M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|   662k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|   662k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  1.32M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 64.7k, False: 598k]
  |  |  ------------------
  |  |  327|  1.32M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|   598k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|   598k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|   598k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 598k]
  |  |  ------------------
  ------------------
  947|  64.7k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (947:18): [True: 25.2k, False: 39.4k]
  ------------------
  948|  39.4k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (948:18): [True: 0, False: 39.4k]
  ------------------
  949|  39.4k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (949:18): [True: 0, False: 39.4k]
  ------------------
  950|  25.2k|            {
  951|       |                /* Initialize submessage to defaults.
  952|       |                 * Only needed if it has default values
  953|       |                 * or callback/submessage fields. */
  954|  25.2k|                pb_field_iter_t submsg_iter;
  955|  25.2k|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (955:21): [True: 25.2k, False: 0]
  ------------------
  956|  25.2k|                {
  957|  25.2k|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (957:25): [True: 0, False: 25.2k]
  ------------------
  958|      0|                        return false;
  959|  25.2k|                }
  960|  25.2k|            }
  961|   637k|            else
  962|   637k|            {
  963|       |                /* Initialize to zeros */
  964|   637k|                memset(field->pData, 0, (size_t)field->data_size);
  965|   637k|            }
  966|   662k|        }
  967|   836k|    }
  968|  52.7k|    else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|  52.7k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  52.7k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|  52.7k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (968:14): [True: 0, False: 52.7k]
  ------------------
  969|      0|    {
  970|       |        /* Initialize the pointer to NULL. */
  971|      0|        *(void**)field->pField = NULL;
  972|       |
  973|       |        /* Initialize array count to 0. */
  974|      0|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  324|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  311|      0|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (974:13): [True: 0, False: 0]
  ------------------
  975|      0|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|      0|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (975:13): [True: 0, False: 0]
  ------------------
  976|      0|        {
  977|      0|            *(pb_size_t*)field->pSize = 0;
  978|      0|        }
  979|      0|    }
  980|  52.7k|    else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|  52.7k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  52.7k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  320|  52.7k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (980:14): [True: 52.7k, False: 0]
  ------------------
  981|  52.7k|    {
  982|       |        /* Don't overwrite callback */
  983|  52.7k|    }
  984|       |
  985|   897k|    return true;
  986|   897k|}
pb_decode.c:decode_extension:
  885|   136k|{
  886|   136k|    size_t pos = stream->bytes_left;
  887|       |    
  888|   272k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (888:12): [True: 136k, False: 136k]
  |  Branch (888:33): [True: 136k, False: 0]
  ------------------
  889|   136k|    {
  890|   136k|        bool status;
  891|   136k|        if (extension->type->decode)
  ------------------
  |  Branch (891:13): [True: 0, False: 136k]
  ------------------
  892|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  893|   136k|        else
  894|   136k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  895|       |
  896|   136k|        if (!status)
  ------------------
  |  Branch (896:13): [True: 42, False: 136k]
  ------------------
  897|     42|            return false;
  898|       |        
  899|   136k|        extension = extension->next;
  900|   136k|    }
  901|       |    
  902|   136k|    return true;
  903|   136k|}
pb_decode.c:default_extension_decoder:
  868|   136k|{
  869|   136k|    pb_field_iter_t iter;
  870|       |
  871|   136k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (871:9): [True: 0, False: 136k]
  ------------------
  872|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  873|       |
  874|   136k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (874:9): [True: 130k, False: 5.78k]
  |  Branch (874:28): [True: 0, False: 5.78k]
  ------------------
  875|   130k|        return true;
  876|       |
  877|  5.78k|    extension->found = true;
  878|  5.78k|    return decode_field(stream, wire_type, &iter);
  879|   136k|}
pb_decode.c:decode_field:
  836|  7.11M|{
  837|       |#ifdef PB_ENABLE_MALLOC
  838|       |    /* When decoding an oneof field, check if there is old data that must be
  839|       |     * released first. */
  840|       |    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  841|       |    {
  842|       |        if (!pb_release_union_field(stream, field))
  843|       |            return false;
  844|       |    }
  845|       |#endif
  846|       |
  847|  7.11M|    switch (PB_ATYPE(field->type))
  ------------------
  |  |  323|  7.11M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  7.11M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
  848|  7.11M|    {
  849|  7.04M|        case PB_ATYPE_STATIC:
  ------------------
  |  |  318|  7.04M|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (849:9): [True: 7.04M, False: 65.8k]
  ------------------
  850|  7.04M|            return decode_static_field(stream, wire_type, field);
  851|       |        
  852|      0|        case PB_ATYPE_POINTER:
  ------------------
  |  |  319|      0|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (852:9): [True: 0, False: 7.11M]
  ------------------
  853|      0|            return decode_pointer_field(stream, wire_type, field);
  854|       |        
  855|  65.8k|        case PB_ATYPE_CALLBACK:
  ------------------
  |  |  320|  65.8k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (855:9): [True: 65.8k, False: 7.04M]
  ------------------
  856|  65.8k|            return decode_callback_field(stream, wire_type, field);
  857|       |        
  858|      0|        default:
  ------------------
  |  Branch (858:9): [True: 0, False: 7.11M]
  ------------------
  859|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  860|  7.11M|    }
  861|  7.11M|}
pb_decode.c:decode_static_field:
  489|  7.04M|{
  490|  7.04M|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  324|  7.04M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  7.04M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  491|  7.04M|    {
  492|  6.37M|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  308|  6.37M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (492:9): [True: 6.37M, False: 671k]
  ------------------
  493|  6.37M|            return decode_basic_field(stream, wire_type, field);
  494|       |            
  495|   457k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  309|   457k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (495:9): [True: 457k, False: 6.58M]
  ------------------
  496|   457k|            if (field->pSize != NULL)
  ------------------
  |  Branch (496:17): [True: 457k, False: 0]
  ------------------
  497|   457k|                *(bool*)field->pSize = true;
  498|   457k|            return decode_basic_field(stream, wire_type, field);
  499|       |    
  500|  37.0k|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  311|  37.0k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (500:9): [True: 37.0k, False: 7.00M]
  ------------------
  501|  37.0k|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (501:17): [True: 24.4k, False: 12.6k]
  ------------------
  502|  24.4k|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  325|  24.4k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  24.4k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  273|  24.4k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (502:20): [True: 11.7k, False: 12.6k]
  ------------------
  503|  11.7k|            {
  504|       |                /* Packed array */
  505|  11.7k|                bool status = true;
  506|  11.7k|                pb_istream_t substream;
  507|  11.7k|                pb_size_t *size = (pb_size_t*)field->pSize;
  508|  11.7k|                field->pData = (char*)field->pField + field->data_size * (*size);
  509|       |
  510|  11.7k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (510:21): [True: 53, False: 11.6k]
  ------------------
  511|     53|                    return false;
  512|       |
  513|  50.0k|                while (substream.bytes_left > 0 && *size < field->array_size)
  ------------------
  |  Branch (513:24): [True: 38.4k, False: 11.6k]
  |  Branch (513:52): [True: 38.4k, False: 26]
  ------------------
  514|  38.4k|                {
  515|  38.4k|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (515:25): [True: 28, False: 38.3k]
  ------------------
  516|     28|                    {
  517|     28|                        status = false;
  518|     28|                        break;
  519|     28|                    }
  520|  38.3k|                    (*size)++;
  521|  38.3k|                    field->pData = (char*)field->pData + field->data_size;
  522|  38.3k|                }
  523|       |
  524|  11.6k|                if (substream.bytes_left != 0)
  ------------------
  |  Branch (524:21): [True: 47, False: 11.6k]
  ------------------
  525|     47|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  920|     47|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     47|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  526|  11.6k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (526:21): [True: 0, False: 11.6k]
  ------------------
  527|      0|                    return false;
  528|       |
  529|  11.6k|                return status;
  530|  11.6k|            }
  531|  25.3k|            else
  532|  25.3k|            {
  533|       |                /* Repeated field */
  534|  25.3k|                pb_size_t *size = (pb_size_t*)field->pSize;
  535|  25.3k|                field->pData = (char*)field->pField + field->data_size * (*size);
  536|       |
  537|  25.3k|                if ((*size)++ >= field->array_size)
  ------------------
  |  Branch (537:21): [True: 3, False: 25.3k]
  ------------------
  538|      3|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  920|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  539|       |
  540|  25.3k|                return decode_basic_field(stream, wire_type, field);
  541|  25.3k|            }
  542|       |
  543|   176k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  313|   176k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (543:9): [True: 176k, False: 6.86M]
  ------------------
  544|   176k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  326|   353k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|   176k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|   176k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|   353k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 137k, False: 39.4k]
  |  |  ------------------
  |  |  327|   353k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|  39.4k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  39.4k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|  39.4k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 39.4k, False: 0]
  |  |  ------------------
  ------------------
  545|   176k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (545:17): [True: 92.7k, False: 84.2k]
  ------------------
  546|  92.7k|            {
  547|       |                /* We memset to zero so that any callbacks are set to NULL.
  548|       |                 * This is because the callbacks might otherwise have values
  549|       |                 * from some other union field.
  550|       |                 * If callbacks are needed inside oneof field, use .proto
  551|       |                 * option submsg_callback to have a separate callback function
  552|       |                 * that can set the fields before submessage is decoded.
  553|       |                 * pb_dec_submessage() will set any default values. */
  554|  92.7k|                memset(field->pData, 0, (size_t)field->data_size);
  555|       |
  556|       |                /* Set default values for the submessage fields. */
  557|  92.7k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (557:21): [True: 54.6k, False: 38.1k]
  ------------------
  558|  38.1k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (558:21): [True: 0, False: 38.1k]
  ------------------
  559|  38.1k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (559:21): [True: 0, False: 38.1k]
  ------------------
  560|  54.6k|                {
  561|  54.6k|                    pb_field_iter_t submsg_iter;
  562|  54.6k|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (562:25): [True: 54.6k, False: 0]
  ------------------
  563|  54.6k|                    {
  564|  54.6k|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (564:29): [True: 0, False: 54.6k]
  ------------------
  565|      0|                            PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  566|  54.6k|                    }
  567|  54.6k|                }
  568|  92.7k|            }
  569|   176k|            *(pb_size_t*)field->pSize = field->tag;
  570|       |
  571|   176k|            return decode_basic_field(stream, wire_type, field);
  572|       |
  573|      0|        default:
  ------------------
  |  Branch (573:9): [True: 0, False: 7.04M]
  ------------------
  574|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  575|  7.04M|    }
  576|  7.04M|}
pb_decode.c:decode_basic_field:
  418|  7.07M|{
  419|  7.07M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  325|  7.07M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  7.07M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  420|  7.07M|    {
  421|   254k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  265|   254k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (421:9): [True: 254k, False: 6.81M]
  ------------------
  422|   254k|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (422:17): [True: 1.38k, False: 252k]
  |  Branch (422:46): [True: 11, False: 1.37k]
  ------------------
  423|     11|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     11|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     11|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  424|       |
  425|   254k|            return pb_dec_bool(stream, field);
  426|       |
  427|  4.37M|        case PB_LTYPE_VARINT:
  ------------------
  |  |  266|  4.37M|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (427:9): [True: 4.37M, False: 2.69M]
  ------------------
  428|  5.53M|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  267|  5.53M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (428:9): [True: 1.15M, False: 5.91M]
  ------------------
  429|  5.72M|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  268|  5.72M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (429:9): [True: 192k, False: 6.88M]
  ------------------
  430|  5.72M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (430:17): [True: 25.6k, False: 5.69M]
  |  Branch (430:46): [True: 53, False: 25.6k]
  ------------------
  431|     53|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     53|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     53|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 53]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  432|       |
  433|  5.72M|            return pb_dec_varint(stream, field);
  434|       |
  435|   294k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  269|   294k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (435:9): [True: 294k, False: 6.77M]
  ------------------
  436|   294k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (436:17): [True: 6.28k, False: 288k]
  |  Branch (436:45): [True: 17, False: 6.26k]
  ------------------
  437|     17|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     17|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     17|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  438|       |
  439|   294k|            return pb_decode_fixed32(stream, field->pData);
  440|       |
  441|   237k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  270|   237k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (441:9): [True: 237k, False: 6.83M]
  ------------------
  442|   237k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (442:17): [True: 5.16k, False: 232k]
  |  Branch (442:45): [True: 10, False: 5.15k]
  ------------------
  443|     10|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     10|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     10|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  444|       |
  445|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  446|       |            if (field->data_size == sizeof(float))
  447|       |            {
  448|       |                return pb_decode_double_as_float(stream, (float*)field->pData);
  449|       |            }
  450|       |#endif
  451|       |
  452|       |#ifdef PB_WITHOUT_64BIT
  453|       |            PB_RETURN_ERROR(stream, "invalid data_size");
  454|       |#else
  455|   237k|            return pb_decode_fixed64(stream, field->pData);
  456|      0|#endif
  457|       |
  458|  50.3k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  277|  50.3k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (458:9): [True: 50.3k, False: 7.02M]
  ------------------
  459|  50.3k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (459:17): [True: 10, False: 50.2k]
  ------------------
  460|     10|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     10|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     10|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  461|       |
  462|  50.2k|            return pb_dec_bytes(stream, field);
  463|       |
  464|   192k|        case PB_LTYPE_STRING:
  ------------------
  |  |  281|   192k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (464:9): [True: 192k, False: 6.88M]
  ------------------
  465|   192k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (465:17): [True: 9, False: 192k]
  ------------------
  466|      9|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|      9|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      9|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  467|       |
  468|   192k|            return pb_dec_string(stream, field);
  469|       |
  470|   249k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  285|   249k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (470:9): [True: 249k, False: 6.82M]
  ------------------
  471|   289k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  290|   289k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (471:9): [True: 39.4k, False: 7.03M]
  ------------------
  472|   289k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (472:17): [True: 15, False: 289k]
  ------------------
  473|     15|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     15|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     15|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  474|       |
  475|   289k|            return pb_dec_submessage(stream, field);
  476|       |
  477|  28.7k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  300|  28.7k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (477:9): [True: 28.7k, False: 7.04M]
  ------------------
  478|  28.7k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (478:17): [True: 6, False: 28.6k]
  ------------------
  479|      6|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|      6|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      6|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  480|       |
  481|  28.6k|            return pb_dec_fixed_length_bytes(stream, field);
  482|       |
  483|      0|        default:
  ------------------
  |  Branch (483:9): [True: 0, False: 7.07M]
  ------------------
  484|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  485|  7.07M|    }
  486|  7.07M|}
pb_decode.c:pb_dec_bool:
 1456|   254k|{
 1457|   254k|    return pb_decode_bool(stream, (bool*)field->pData);
 1458|   254k|}
pb_decode.c:pb_dec_varint:
 1461|  5.72M|{
 1462|  5.72M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  325|  5.72M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  5.72M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  267|  5.72M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1462:9): [True: 1.15M, False: 4.56M]
  ------------------
 1463|  1.15M|    {
 1464|  1.15M|        pb_uint64_t value, clamped;
  ------------------
  |  |   57|  1.15M|#define pb_uint64_t uint64_t
  ------------------
 1465|  1.15M|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1465:13): [True: 23, False: 1.15M]
  ------------------
 1466|     23|            return false;
 1467|       |
 1468|       |        /* Cast to the proper field size, while checking for overflows */
 1469|  1.15M|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1469:13): [True: 961k, False: 195k]
  ------------------
 1470|   961k|            clamped = *(pb_uint64_t*)field->pData = value;
 1471|   195k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1471:18): [True: 168k, False: 26.4k]
  ------------------
 1472|   168k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1473|  26.4k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1473:18): [True: 13.2k, False: 13.2k]
  ------------------
 1474|  13.2k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1475|  13.2k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1475:18): [True: 13.2k, False: 0]
  ------------------
 1476|  13.2k|            clamped = *(uint_least8_t*)field->pData = (uint_least8_t)value;
 1477|      0|        else
 1478|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1479|       |
 1480|  1.15M|        if (clamped != value)
  ------------------
  |  Branch (1480:13): [True: 112, False: 1.15M]
  ------------------
 1481|    112|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  920|    112|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|    112|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 112]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1482|       |
 1483|  1.15M|        return true;
 1484|  1.15M|    }
 1485|  4.56M|    else
 1486|  4.56M|    {
 1487|  4.56M|        pb_uint64_t value;
  ------------------
  |  |   57|  4.56M|#define pb_uint64_t uint64_t
  ------------------
 1488|  4.56M|        pb_int64_t svalue;
  ------------------
  |  |   56|  4.56M|#define pb_int64_t int64_t
  ------------------
 1489|  4.56M|        pb_int64_t clamped;
  ------------------
  |  |   56|  4.56M|#define pb_int64_t int64_t
  ------------------
 1490|       |
 1491|  4.56M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  325|  4.56M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  4.56M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  268|  4.56M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1491:13): [True: 192k, False: 4.37M]
  ------------------
 1492|   192k|        {
 1493|   192k|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1493:17): [True: 24, False: 192k]
  ------------------
 1494|     24|                return false;
 1495|   192k|        }
 1496|  4.37M|        else
 1497|  4.37M|        {
 1498|  4.37M|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1498:17): [True: 32, False: 4.37M]
  ------------------
 1499|     32|                return false;
 1500|       |
 1501|       |            /* See issue 97: Google's C++ protobuf allows negative varint values to
 1502|       |            * be cast as int32_t, instead of the int64_t that should be used when
 1503|       |            * encoding. Nanopb versions before 0.2.5 had a bug in encoding. In order to
 1504|       |            * not break decoding of such messages, we cast <=32 bit fields to
 1505|       |            * int32_t first to get the sign correct.
 1506|       |            */
 1507|  4.37M|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1507:17): [True: 153k, False: 4.22M]
  ------------------
 1508|   153k|                svalue = (pb_int64_t)value;
 1509|  4.22M|            else
 1510|  4.22M|                svalue = (int32_t)value;
 1511|  4.37M|        }
 1512|       |
 1513|       |        /* Cast to the proper field size, while checking for overflows */
 1514|  4.56M|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1514:13): [True: 246k, False: 4.32M]
  ------------------
 1515|   246k|            clamped = *(pb_int64_t*)field->pData = svalue;
 1516|  4.32M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1516:18): [True: 4.26M, False: 52.5k]
  ------------------
 1517|  4.26M|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1518|  52.5k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1518:18): [True: 26.2k, False: 26.3k]
  ------------------
 1519|  26.2k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1520|  26.3k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1520:18): [True: 26.3k, False: 0]
  ------------------
 1521|  26.3k|            clamped = *(int_least8_t*)field->pData = (int_least8_t)svalue;
 1522|      0|        else
 1523|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1524|       |
 1525|  4.56M|        if (clamped != svalue)
  ------------------
  |  Branch (1525:13): [True: 99, False: 4.56M]
  ------------------
 1526|     99|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  920|     99|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     99|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 99]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1527|       |
 1528|  4.56M|        return true;
 1529|  4.56M|    }
 1530|  5.72M|}
pb_decode.c:pb_dec_bytes:
 1533|  50.2k|{
 1534|  50.2k|    uint32_t size;
 1535|  50.2k|    size_t alloc_size;
 1536|  50.2k|    pb_bytes_array_t *dest;
 1537|       |    
 1538|  50.2k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1538:9): [True: 4, False: 50.2k]
  ------------------
 1539|      4|        return false;
 1540|       |    
 1541|  50.2k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  339|  50.2k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1541:9): [True: 31, False: 50.2k]
  ------------------
 1542|     31|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  920|     31|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     31|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1543|       |    
 1544|  50.2k|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  403|  50.2k|#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes))
  ------------------
 1545|  50.2k|    if (size > alloc_size)
  ------------------
  |  Branch (1545:9): [True: 0, False: 50.2k]
  ------------------
 1546|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1547|       |    
 1548|  50.2k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|  50.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  50.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|  50.2k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1548:9): [True: 0, False: 50.2k]
  ------------------
 1549|      0|    {
 1550|      0|#ifndef PB_ENABLE_MALLOC
 1551|      0|        PB_RETURN_ERROR(stream, "no malloc support");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1552|       |#else
 1553|       |        if (stream->bytes_left < size)
 1554|       |            PB_RETURN_ERROR(stream, "end-of-stream");
 1555|       |
 1556|       |        if (!allocate_field(stream, field->pData, alloc_size, 1))
 1557|       |            return false;
 1558|       |        dest = *(pb_bytes_array_t**)field->pData;
 1559|       |#endif
 1560|      0|    }
 1561|  50.2k|    else
 1562|  50.2k|    {
 1563|  50.2k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1563:13): [True: 54, False: 50.2k]
  ------------------
 1564|     54|            PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  920|     54|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     54|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 54]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1565|  50.2k|        dest = (pb_bytes_array_t*)field->pData;
 1566|  50.2k|    }
 1567|       |
 1568|  50.2k|    dest->size = (pb_size_t)size;
 1569|  50.2k|    return pb_read(stream, dest->bytes, (size_t)size);
 1570|  50.2k|}
pb_decode.c:pb_dec_string:
 1573|   192k|{
 1574|   192k|    uint32_t size;
 1575|   192k|    size_t alloc_size;
 1576|   192k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1577|       |
 1578|   192k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1578:9): [True: 5, False: 192k]
  ------------------
 1579|      5|        return false;
 1580|       |
 1581|   192k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1581:9): [True: 2, False: 192k]
  ------------------
 1582|      2|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  920|      2|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      2|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1583|       |
 1584|       |    /* Space for null terminator */
 1585|   192k|    alloc_size = (size_t)(size + 1);
 1586|       |
 1587|   192k|    if (alloc_size < size)
  ------------------
  |  Branch (1587:9): [True: 0, False: 192k]
  ------------------
 1588|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1589|       |
 1590|   192k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|   192k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   192k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|   192k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1590:9): [True: 0, False: 192k]
  ------------------
 1591|      0|    {
 1592|      0|#ifndef PB_ENABLE_MALLOC
 1593|      0|        PB_RETURN_ERROR(stream, "no malloc support");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1594|       |#else
 1595|       |        if (stream->bytes_left < size)
 1596|       |            PB_RETURN_ERROR(stream, "end-of-stream");
 1597|       |
 1598|       |        if (!allocate_field(stream, field->pData, alloc_size, 1))
 1599|       |            return false;
 1600|       |        dest = *(pb_byte_t**)field->pData;
 1601|       |#endif
 1602|      0|    }
 1603|   192k|    else
 1604|   192k|    {
 1605|   192k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1605:13): [True: 80, False: 192k]
  ------------------
 1606|     80|            PB_RETURN_ERROR(stream, "string overflow");
  ------------------
  |  |  920|     80|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     80|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 80]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1607|   192k|    }
 1608|       |    
 1609|   192k|    dest[size] = 0;
 1610|       |
 1611|   192k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1611:9): [True: 7, False: 192k]
  ------------------
 1612|      7|        return false;
 1613|       |
 1614|       |#ifdef PB_VALIDATE_UTF8
 1615|       |    if (!pb_validate_utf8((const char*)dest))
 1616|       |        PB_RETURN_ERROR(stream, "invalid utf8");
 1617|       |#endif
 1618|       |
 1619|   192k|    return true;
 1620|   192k|}
pb_decode.c:pb_dec_submessage:
 1623|   289k|{
 1624|   289k|    bool status = true;
 1625|   289k|    bool submsg_consumed = false;
 1626|   289k|    pb_istream_t substream;
 1627|       |
 1628|   289k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1628:9): [True: 96, False: 289k]
  ------------------
 1629|     96|        return false;
 1630|       |    
 1631|   289k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1631:9): [True: 0, False: 289k]
  ------------------
 1632|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1633|       |    
 1634|       |    /* Submessages can have a separate message-level callback that is called
 1635|       |     * before decoding the message. Typically it is used to set callback fields
 1636|       |     * inside oneofs. */
 1637|   289k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  325|   289k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   289k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  290|   578k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1637:9): [True: 39.4k, False: 249k]
  |  Branch (1637:58): [True: 39.4k, False: 0]
  ------------------
 1638|  39.4k|    {
 1639|       |        /* Message callback is stored right before pSize. */
 1640|  39.4k|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
 1641|  39.4k|        if (callback->funcs.decode)
  ------------------
  |  Branch (1641:13): [True: 39.4k, False: 0]
  ------------------
 1642|  39.4k|        {
 1643|  39.4k|            status = callback->funcs.decode(&substream, field, &callback->arg);
 1644|       |
 1645|  39.4k|            if (substream.bytes_left == 0)
  ------------------
  |  Branch (1645:17): [True: 23.5k, False: 15.8k]
  ------------------
 1646|  23.5k|            {
 1647|  23.5k|                submsg_consumed = true;
 1648|  23.5k|            }
 1649|  39.4k|        }
 1650|  39.4k|    }
 1651|       |
 1652|       |    /* Now decode the submessage contents */
 1653|   289k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1653:9): [True: 289k, False: 0]
  |  Branch (1653:19): [True: 265k, False: 23.5k]
  ------------------
 1654|   265k|    {
 1655|   265k|        unsigned int flags = 0;
 1656|       |
 1657|       |        /* Static required/optional fields are already initialized by top-level
 1658|       |         * pb_decode(), no need to initialize them again. */
 1659|   265k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  323|   265k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   265k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  318|   531k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1659:13): [True: 265k, False: 0]
  ------------------
 1660|   265k|            PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  324|   265k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   265k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  311|   265k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1660:13): [True: 260k, False: 5.39k]
  ------------------
 1661|   260k|        {
 1662|   260k|            flags = PB_DECODE_NOINIT;
  ------------------
  |  |  110|   260k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1663|   260k|        }
 1664|       |
 1665|   265k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1666|   265k|    }
 1667|       |    
 1668|   289k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1668:9): [True: 0, False: 289k]
  ------------------
 1669|      0|        return false;
 1670|       |
 1671|   289k|    return status;
 1672|   289k|}
pb_decode.c:pb_dec_fixed_length_bytes:
 1675|  28.6k|{
 1676|  28.6k|    uint32_t size;
 1677|       |
 1678|  28.6k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1678:9): [True: 4, False: 28.6k]
  ------------------
 1679|      4|        return false;
 1680|       |
 1681|  28.6k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  339|  28.6k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1681:9): [True: 30, False: 28.6k]
  ------------------
 1682|     30|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  920|     30|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     30|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 30]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1683|       |
 1684|  28.6k|    if (size == 0)
  ------------------
  |  Branch (1684:9): [True: 14.5k, False: 14.1k]
  ------------------
 1685|  14.5k|    {
 1686|       |        /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */
 1687|  14.5k|        memset(field->pData, 0, (size_t)field->data_size);
 1688|  14.5k|        return true;
 1689|  14.5k|    }
 1690|       |
 1691|  14.1k|    if (size != field->data_size)
  ------------------
  |  Branch (1691:9): [True: 45, False: 14.0k]
  ------------------
 1692|     45|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  920|     45|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     45|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 45]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1693|       |
 1694|  14.0k|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1695|  14.1k|}
pb_decode.c:decode_callback_field:
  774|  65.8k|{
  775|  65.8k|    if (!field->descriptor->field_callback)
  ------------------
  |  Branch (775:9): [True: 0, False: 65.8k]
  ------------------
  776|      0|        return pb_skip_field(stream, wire_type);
  777|       |
  778|  65.8k|    if (wire_type == PB_WT_STRING)
  ------------------
  |  Branch (778:9): [True: 57.5k, False: 8.30k]
  ------------------
  779|  57.5k|    {
  780|  57.5k|        pb_istream_t substream;
  781|  57.5k|        size_t prev_bytes_left;
  782|       |        
  783|  57.5k|        if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (783:13): [True: 0, False: 57.5k]
  ------------------
  784|      0|            return false;
  785|       |
  786|       |        /* If the callback field is inside a submsg, first call the submsg_callback which
  787|       |         * should set the decoder for the callback field. */
  788|  57.5k|        if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  325|  57.5k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  57.5k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  290|   115k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (788:13): [True: 0, False: 57.5k]
  |  Branch (788:62): [True: 0, False: 0]
  ------------------
  789|      0|            pb_callback_t* callback;
  790|      0|            *(pb_size_t*)field->pSize = field->tag;
  791|      0|            callback = (pb_callback_t*)field->pSize - 1;
  792|       |
  793|      0|            if (callback->funcs.decode)
  ------------------
  |  Branch (793:17): [True: 0, False: 0]
  ------------------
  794|      0|            {
  795|      0|                if (!callback->funcs.decode(&substream, field, &callback->arg)) {
  ------------------
  |  Branch (795:21): [True: 0, False: 0]
  ------------------
  796|      0|                    PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "submsg callback failed");
  ------------------
  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  Branch (916:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  797|      0|                    return false;
  798|      0|                }
  799|      0|            }
  800|      0|        }
  801|       |        
  802|  57.5k|        do
  803|  57.5k|        {
  804|  57.5k|            prev_bytes_left = substream.bytes_left;
  805|  57.5k|            if (!field->descriptor->field_callback(&substream, NULL, field))
  ------------------
  |  Branch (805:17): [True: 0, False: 57.5k]
  ------------------
  806|      0|            {
  807|      0|                PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "callback failed");
  ------------------
  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  Branch (916:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  808|      0|                return false;
  809|      0|            }
  810|  57.5k|        } while (substream.bytes_left > 0 && substream.bytes_left < prev_bytes_left);
  ------------------
  |  Branch (810:18): [True: 22.6k, False: 34.8k]
  |  Branch (810:46): [True: 0, False: 22.6k]
  ------------------
  811|       |        
  812|  57.5k|        if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (812:13): [True: 0, False: 57.5k]
  ------------------
  813|      0|            return false;
  814|       |
  815|  57.5k|        return true;
  816|  57.5k|    }
  817|  8.30k|    else
  818|  8.30k|    {
  819|       |        /* Copy the single scalar value to stack.
  820|       |         * This is required so that we can limit the stream length,
  821|       |         * which in turn allows to use same callback for packed and
  822|       |         * not-packed fields. */
  823|  8.30k|        pb_istream_t substream;
  824|  8.30k|        pb_byte_t buffer[10];
  825|  8.30k|        size_t size = sizeof(buffer);
  826|       |        
  827|  8.30k|        if (!read_raw_value(stream, wire_type, buffer, &size))
  ------------------
  |  Branch (827:13): [True: 0, False: 8.30k]
  ------------------
  828|      0|            return false;
  829|  8.30k|        substream = pb_istream_from_buffer(buffer, size);
  830|       |        
  831|       |        return field->descriptor->field_callback(&substream, NULL, field);
  832|  8.30k|    }
  833|  65.8k|}
pb_decode.c:read_raw_value:
  339|  8.30k|{
  340|  8.30k|    size_t max_size = *size;
  341|  8.30k|    switch (wire_type)
  342|  8.30k|    {
  343|  6.89k|        case PB_WT_VARINT:
  ------------------
  |  Branch (343:9): [True: 6.89k, False: 1.40k]
  ------------------
  344|  6.89k|            *size = 0;
  345|  6.89k|            do
  346|  22.3k|            {
  347|  22.3k|                (*size)++;
  348|  22.3k|                if (*size > max_size)
  ------------------
  |  Branch (348:21): [True: 0, False: 22.3k]
  ------------------
  349|      0|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  350|       |
  351|  22.3k|                if (!pb_read(stream, buf, 1))
  ------------------
  |  Branch (351:21): [True: 0, False: 22.3k]
  ------------------
  352|      0|                    return false;
  353|  22.3k|            } while (*buf++ & 0x80);
  ------------------
  |  Branch (353:22): [True: 15.4k, False: 6.89k]
  ------------------
  354|  6.89k|            return true;
  355|       |            
  356|    507|        case PB_WT_64BIT:
  ------------------
  |  Branch (356:9): [True: 507, False: 7.79k]
  ------------------
  357|    507|            *size = 8;
  358|    507|            return pb_read(stream, buf, 8);
  359|       |        
  360|    899|        case PB_WT_32BIT:
  ------------------
  |  Branch (360:9): [True: 899, False: 7.40k]
  ------------------
  361|    899|            *size = 4;
  362|    899|            return pb_read(stream, buf, 4);
  363|       |        
  364|      0|        case PB_WT_STRING:
  ------------------
  |  Branch (364:9): [True: 0, False: 8.30k]
  ------------------
  365|       |            /* Calling read_raw_value with a PB_WT_STRING is an error.
  366|       |             * Explicitly handle this case and fallthrough to default to avoid
  367|       |             * compiler warnings.
  368|       |             */
  369|       |
  370|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (370:2): [True: 0, False: 8.30k]
  ------------------
  371|       |            /* Calling read_raw_value with a PB_WT_PACKED is an error.
  372|       |             * Explicitly handle this case and fallthrough to default to avoid
  373|       |             * compiler warnings.
  374|       |             */
  375|       |
  376|      0|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (376:9): [True: 0, False: 8.30k]
  ------------------
  377|  8.30k|    }
  378|  8.30k|}

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

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

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

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

validate_static:
    7|   506k|{
    8|   506k|    pb_size_t count = 1;
    9|   506k|    pb_size_t i;
   10|   506k|    bool truebool = true;
   11|   506k|    bool falsebool = false;
   12|       |
   13|   506k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  324|   506k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   506k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  311|  1.01M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 112k, False: 394k]
  |  Branch (13:54): [True: 112k, False: 0]
  ------------------
   14|   112k|    {
   15|       |        /* Array count must be between 0 and statically allocated size */
   16|   112k|        count = *(pb_size_t*)iter->pSize;
   17|   112k|        assert(count <= iter->array_size);
  ------------------
  |  Branch (17:9): [True: 0, False: 112k]
  |  Branch (17:9): [True: 112k, False: 0]
  ------------------
   18|   112k|    }
   19|   394k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  324|   394k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   394k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  309|   788k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 122k, False: 271k]
  |  Branch (19:59): [True: 122k, False: 0]
  ------------------
   20|   122k|    {
   21|       |        /* Boolean has_ field must have a valid value */
   22|   122k|        assert(memcmp(iter->pSize, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (22:9): [True: 122k, False: 0]
  |  Branch (22:9): [True: 0, False: 0]
  |  Branch (22:9): [True: 10.7k, False: 111k]
  |  Branch (22:9): [True: 111k, False: 0]
  ------------------
   23|   122k|               memcmp(iter->pSize, &falsebool, sizeof(bool)) == 0);
   24|   122k|    }
   25|   271k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|   271k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   271k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|   271k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 16.0k, False: 255k]
  ------------------
   26|  16.0k|    {
   27|  16.0k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 14.4k, False: 1.62k]
  ------------------
   28|  14.4k|        {
   29|       |            /* Some different field in oneof */
   30|  14.4k|            return;
   31|  14.4k|        }
   32|  16.0k|    }
   33|       |
   34|   960k|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 467k, False: 492k]
  ------------------
   35|   467k|    {
   36|   467k|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|   467k|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  325|   467k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   467k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  281|   467k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 28.5k, False: 439k]
  ------------------
   39|  28.5k|        {
   40|       |            /* String length must be at most statically allocated size */
   41|  28.5k|            assert(strlen(pData) + 1 <= iter->data_size);
  ------------------
  |  Branch (41:13): [True: 0, False: 28.5k]
  |  Branch (41:13): [True: 28.5k, False: 0]
  ------------------
   42|  28.5k|        }
   43|   439k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  325|   439k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   439k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  277|   439k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 12.8k, False: 426k]
  ------------------
   44|  12.8k|        {
   45|       |            /* Bytes length must be at most statically allocated size */
   46|  12.8k|            pb_bytes_array_t *bytes = pData;
   47|  12.8k|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= iter->data_size);
  ------------------
  |  Branch (47:13): [True: 0, False: 12.8k]
  |  Branch (47:13): [True: 12.8k, False: 0]
  ------------------
   48|  12.8k|        }
   49|   426k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  325|   426k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   426k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  265|   426k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 12.1k, False: 414k]
  ------------------
   50|  12.1k|        {
   51|       |            /* Bool fields must have valid value */
   52|  12.1k|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (52:13): [True: 12.1k, False: 0]
  |  Branch (52:13): [True: 0, False: 0]
  |  Branch (52:13): [True: 5.02k, False: 7.15k]
  |  Branch (52:13): [True: 7.15k, False: 0]
  ------------------
   53|  12.1k|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
   54|  12.1k|        }
   55|   414k|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  326|   414k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|   414k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|   414k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|   828k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 44.3k, False: 369k]
  |  |  ------------------
  |  |  327|   414k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|   369k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|   369k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|   369k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 369k]
  |  |  ------------------
  ------------------
   56|  44.3k|        {
   57|  44.3k|            validate_message(pData, 0, iter->submsg_desc);
   58|  44.3k|        }
   59|   467k|    }
   60|   492k|}
validate_message:
  145|  49.7k|{
  146|  49.7k|    pb_field_iter_t iter;
  147|       |
  148|  49.7k|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 36.7k, False: 12.9k]
  ------------------
  149|  36.7k|    {
  150|  36.7k|        do
  151|   511k|        {
  152|   511k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  323|   511k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   511k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  318|   511k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 506k, False: 5.35k]
  ------------------
  153|   506k|            {
  154|   506k|                validate_static(&iter);
  155|   506k|            }
  156|  5.35k|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|  5.35k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  5.35k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|  5.35k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 0, False: 5.35k]
  ------------------
  157|      0|            {
  158|      0|                validate_pointer(&iter);
  159|      0|            }
  160|   511k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 475k, False: 36.7k]
  ------------------
  161|  36.7k|    }
  162|  49.7k|}

