pb_field_iter_begin:
  157|   696k|{
  158|   696k|    memset(iter, 0, sizeof(*iter));
  159|       |
  160|   696k|    iter->descriptor = desc;
  161|   696k|    iter->message = message;
  162|       |
  163|   696k|    return load_descriptor_values(iter);
  164|   696k|}
pb_field_iter_begin_extension:
  167|  26.4k|{
  168|  26.4k|    const pb_msgdesc_t *msg = (const pb_msgdesc_t*)extension->type->arg;
  169|  26.4k|    bool status;
  170|       |
  171|  26.4k|    uint32_t word0 = PB_PROGMEM_READU32(msg->field_info[0]);
  ------------------
  |  |  155|  26.4k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  172|  26.4k|    if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  286|  26.4k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|  26.4k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  282|  26.4k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (172:9): [True: 0, False: 26.4k]
  ------------------
  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|  26.4k|    else
  180|  26.4k|    {
  181|  26.4k|        status = pb_field_iter_begin(iter, msg, extension->dest);
  182|  26.4k|    }
  183|       |
  184|  26.4k|    iter->pSize = &extension->found;
  185|  26.4k|    return status;
  186|  26.4k|}
pb_field_iter_next:
  189|  5.16M|{
  190|  5.16M|    advance_iterator(iter);
  191|  5.16M|    (void)load_descriptor_values(iter);
  192|  5.16M|    return iter->index != 0;
  193|  5.16M|}
pb_field_iter_find:
  196|  1.31M|{
  197|  1.31M|    if (iter->tag == tag)
  ------------------
  |  Branch (197:9): [True: 732k, False: 581k]
  ------------------
  198|   732k|    {
  199|   732k|        return true; /* Nothing to do, correct field already. */
  200|   732k|    }
  201|   581k|    else if (tag > iter->descriptor->largest_tag)
  ------------------
  |  Branch (201:14): [True: 31.3k, False: 549k]
  ------------------
  202|  31.3k|    {
  203|  31.3k|        return false;
  204|  31.3k|    }
  205|   549k|    else
  206|   549k|    {
  207|   549k|        pb_size_t start = iter->index;
  208|   549k|        uint32_t fieldinfo;
  209|       |
  210|   549k|        if (tag < iter->tag)
  ------------------
  |  Branch (210:13): [True: 179k, False: 370k]
  ------------------
  211|   179k|        {
  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|   179k|            iter->index = iter->descriptor->field_count;
  216|   179k|        }
  217|       |
  218|   549k|        do
  219|  12.5M|        {
  220|       |            /* Advance iterator but don't load values yet */
  221|  12.5M|            advance_iterator(iter);
  222|       |
  223|       |            /* Do fast check for tag number match */
  224|  12.5M|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  155|  12.5M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  225|       |
  226|  12.5M|            if (((fieldinfo >> 2) & 0x3F) == (tag & 0x3F))
  ------------------
  |  Branch (226:17): [True: 558k, False: 12.0M]
  ------------------
  227|   558k|            {
  228|       |                /* Good candidate, check further */
  229|   558k|                (void)load_descriptor_values(iter);
  230|       |
  231|   558k|                if (iter->tag == tag &&
  ------------------
  |  Branch (231:21): [True: 510k, False: 48.7k]
  ------------------
  232|   558k|                    PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  288|   510k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   510k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                                  PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  257|   510k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (232:21): [True: 509k, False: 305]
  ------------------
  233|   509k|                {
  234|       |                    /* Found it */
  235|   509k|                    return true;
  236|   509k|                }
  237|   558k|            }
  238|  12.5M|        } while (iter->index != start);
  ------------------
  |  Branch (238:18): [True: 12.0M, False: 40.1k]
  ------------------
  239|       |
  240|       |        /* Searched all the way back to start, and found nothing. */
  241|  40.1k|        (void)load_descriptor_values(iter);
  242|  40.1k|        return false;
  243|   549k|    }
  244|  1.31M|}
pb_field_iter_find_extension:
  247|  7.46k|{
  248|  7.46k|    if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  288|  7.46k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|  7.46k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  257|  7.46k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (248:9): [True: 0, False: 7.46k]
  ------------------
  249|      0|    {
  250|      0|        return true;
  251|      0|    }
  252|  7.46k|    else
  253|  7.46k|    {
  254|  7.46k|        pb_size_t start = iter->index;
  255|  7.46k|        uint32_t fieldinfo;
  256|       |
  257|  7.46k|        do
  258|   220k|        {
  259|       |            /* Advance iterator but don't load values yet */
  260|   220k|            advance_iterator(iter);
  261|       |
  262|       |            /* Do fast check for field type */
  263|   220k|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  155|   220k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  264|       |
  265|   220k|            if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  288|   220k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   220k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  257|   220k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (265:17): [True: 3.63k, False: 216k]
  ------------------
  266|  3.63k|            {
  267|  3.63k|                return load_descriptor_values(iter);
  268|  3.63k|            }
  269|   220k|        } while (iter->index != start);
  ------------------
  |  Branch (269:18): [True: 212k, False: 3.83k]
  ------------------
  270|       |
  271|       |        /* Searched all the way back to start, and found nothing. */
  272|  3.83k|        (void)load_descriptor_values(iter);
  273|  3.83k|        return false;
  274|  7.46k|    }
  275|  7.46k|}
pb_field_iter_begin_const:
  291|    941|{
  292|    941|    return pb_field_iter_begin(iter, desc, pb_const_cast(message));
  293|    941|}
pb_default_field_callback:
  301|  99.5k|{
  302|  99.5k|    if (field->data_size == sizeof(pb_callback_t))
  ------------------
  |  Branch (302:9): [True: 99.5k, False: 0]
  ------------------
  303|  99.5k|    {
  304|  99.5k|        pb_callback_t *pCallback = (pb_callback_t*)field->pData;
  305|       |
  306|  99.5k|        if (pCallback != NULL)
  ------------------
  |  Branch (306:13): [True: 99.5k, False: 0]
  ------------------
  307|  99.5k|        {
  308|  99.5k|            if (istream != NULL && pCallback->funcs.decode != NULL)
  ------------------
  |  Branch (308:17): [True: 99.5k, False: 0]
  |  Branch (308:36): [True: 2.03k, False: 97.4k]
  ------------------
  309|  2.03k|            {
  310|  2.03k|                return pCallback->funcs.decode(istream, field, &pCallback->arg);
  311|  2.03k|            }
  312|       |
  313|  97.4k|            if (ostream != NULL && pCallback->funcs.encode != NULL)
  ------------------
  |  Branch (313:17): [True: 0, False: 97.4k]
  |  Branch (313:36): [True: 0, False: 0]
  ------------------
  314|      0|            {
  315|      0|                return pCallback->funcs.encode(ostream, field, &pCallback->arg);
  316|      0|            }
  317|  97.4k|        }
  318|  99.5k|    }
  319|       |
  320|  97.4k|    return true; /* Success, but didn't do anything */
  321|       |
  322|  99.5k|}
pb_common.c:load_descriptor_values:
    9|  6.47M|{
   10|  6.47M|    uint32_t word0;
   11|  6.47M|    uint32_t data_offset;
   12|  6.47M|    int_least8_t size_offset;
   13|       |
   14|  6.47M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (14:9): [True: 195k, False: 6.27M]
  ------------------
   15|   195k|        return false;
   16|       |
   17|  6.27M|    word0 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  155|  6.27M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   18|  6.27M|    iter->type = (pb_type_t)((word0 >> 8) & 0xFF);
   19|       |
   20|  6.27M|    switch(word0 & 3)
   21|  6.27M|    {
   22|   813k|        case 0: {
  ------------------
  |  Branch (22:9): [True: 813k, False: 5.46M]
  ------------------
   23|       |            /* 1-word format */
   24|   813k|            iter->array_size = 1;
   25|   813k|            iter->tag = (pb_size_t)((word0 >> 2) & 0x3F);
   26|   813k|            size_offset = (int_least8_t)((word0 >> 24) & 0x0F);
   27|   813k|            data_offset = (word0 >> 16) & 0xFF;
   28|   813k|            iter->data_size = (pb_size_t)((word0 >> 28) & 0x0F);
   29|   813k|            break;
   30|      0|        }
   31|       |
   32|  4.83M|        case 1: {
  ------------------
  |  Branch (32:9): [True: 4.83M, False: 1.44M]
  ------------------
   33|       |            /* 2-word format */
   34|  4.83M|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  155|  4.83M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   35|       |
   36|  4.83M|            iter->array_size = (pb_size_t)((word0 >> 16) & 0x0FFF);
   37|  4.83M|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 28) << 6));
   38|  4.83M|            size_offset = (int_least8_t)((word0 >> 28) & 0x0F);
   39|  4.83M|            data_offset = word1 & 0xFFFF;
   40|  4.83M|            iter->data_size = (pb_size_t)((word1 >> 16) & 0x0FFF);
   41|  4.83M|            break;
   42|      0|        }
   43|       |
   44|   532k|        case 2: {
  ------------------
  |  Branch (44:9): [True: 532k, False: 5.74M]
  ------------------
   45|       |            /* 4-word format */
   46|   532k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  155|   532k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   47|   532k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  155|   532k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   48|   532k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  155|   532k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   49|       |
   50|   532k|            iter->array_size = (pb_size_t)(word0 >> 16);
   51|   532k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   52|   532k|            size_offset = (int_least8_t)(word1 & 0xFF);
   53|   532k|            data_offset = word2;
   54|   532k|            iter->data_size = (pb_size_t)word3;
   55|   532k|            break;
   56|      0|        }
   57|       |
   58|  97.2k|        default: {
  ------------------
  |  Branch (58:9): [True: 97.2k, False: 6.17M]
  ------------------
   59|       |            /* 8-word format */
   60|  97.2k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  155|  97.2k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   61|  97.2k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  155|  97.2k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   62|  97.2k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  155|  97.2k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   63|  97.2k|            uint32_t word4 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 4]);
  ------------------
  |  |  155|  97.2k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   64|       |
   65|  97.2k|            iter->array_size = (pb_size_t)word4;
   66|  97.2k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   67|  97.2k|            size_offset = (int_least8_t)(word1 & 0xFF);
   68|  97.2k|            data_offset = word2;
   69|  97.2k|            iter->data_size = (pb_size_t)word3;
   70|  97.2k|            break;
   71|      0|        }
   72|  6.27M|    }
   73|       |
   74|  6.27M|    if (!iter->message)
  ------------------
  |  Branch (74:9): [True: 0, False: 6.27M]
  ------------------
   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|  6.27M|    else
   81|  6.27M|    {
   82|  6.27M|        iter->pField = (char*)iter->message + data_offset;
   83|       |
   84|  6.27M|        if (size_offset)
  ------------------
  |  Branch (84:13): [True: 2.28M, False: 3.99M]
  ------------------
   85|  2.28M|        {
   86|  2.28M|            iter->pSize = (char*)iter->pField - size_offset;
   87|  2.28M|        }
   88|  3.99M|        else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  287|  3.99M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|  3.99M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  274|  7.99M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (88:18): [True: 367k, False: 3.62M]
  ------------------
   89|  3.99M|                 (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  286|   367k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|   367k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                               (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  281|   735k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (89:19): [True: 65.5k, False: 301k]
  ------------------
   90|   367k|                  PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  286|   301k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|   301k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                                PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  282|   301k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (90:19): [True: 29.8k, False: 272k]
  ------------------
   91|  95.4k|        {
   92|       |            /* Fixed count array */
   93|  95.4k|            iter->pSize = &iter->array_size;
   94|  95.4k|        }
   95|  3.89M|        else
   96|  3.89M|        {
   97|  3.89M|            iter->pSize = NULL;
   98|  3.89M|        }
   99|       |
  100|  6.27M|        if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  286|  6.27M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|  6.27M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  282|  12.5M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (100:13): [True: 1.37M, False: 4.90M]
  |  Branch (100:57): [True: 1.37M, False: 0]
  ------------------
  101|  1.37M|        {
  102|  1.37M|            iter->pData = *(void**)iter->pField;
  103|  1.37M|        }
  104|  4.90M|        else
  105|  4.90M|        {
  106|  4.90M|            iter->pData = iter->pField;
  107|  4.90M|        }
  108|  6.27M|    }
  109|       |
  110|  6.27M|    if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  289|  6.27M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  6.27M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|  6.27M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  248|  12.5M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (289:32): [True: 834k, False: 5.44M]
  |  |  ------------------
  |  |  290|  6.27M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  288|  5.44M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|  5.44M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  253|  5.44M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (290:32): [True: 155k, False: 5.28M]
  |  |  ------------------
  ------------------
  111|   990k|    {
  112|   990k|        iter->submsg_desc = iter->descriptor->submsg_info[iter->submessage_index];
  113|   990k|    }
  114|  5.28M|    else
  115|  5.28M|    {
  116|  5.28M|        iter->submsg_desc = NULL;
  117|  5.28M|    }
  118|       |
  119|  6.27M|    return true;
  120|  6.27M|}
pb_common.c:advance_iterator:
  123|  17.9M|{
  124|  17.9M|    iter->index++;
  125|       |
  126|  17.9M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (126:9): [True: 648k, False: 17.3M]
  ------------------
  127|   648k|    {
  128|       |        /* Restart */
  129|   648k|        iter->index = 0;
  130|   648k|        iter->field_info_index = 0;
  131|   648k|        iter->submessage_index = 0;
  132|   648k|        iter->required_field_index = 0;
  133|   648k|    }
  134|  17.3M|    else
  135|  17.3M|    {
  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|  17.3M|        uint32_t prev_descriptor = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  155|  17.3M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  143|  17.3M|        pb_type_t prev_type = (prev_descriptor >> 8) & 0xFF;
  144|  17.3M|        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|  17.3M|        iter->field_info_index = (pb_size_t)(iter->field_info_index + descriptor_len);
  151|  17.3M|        iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  287|  17.3M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|  17.3M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  271|  17.3M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  152|  17.3M|        iter->submessage_index = (pb_size_t)(iter->submessage_index + PB_LTYPE_IS_SUBMSG(prev_type));
  ------------------
  |  |  289|  17.3M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  17.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|  17.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  248|  34.6M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (289:32): [True: 2.15M, False: 15.1M]
  |  |  ------------------
  |  |  290|  17.3M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  288|  15.1M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|  15.1M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  253|  15.1M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (290:32): [True: 130k, False: 15.0M]
  |  |  ------------------
  ------------------
  153|  17.3M|    }
  154|  17.9M|}
pb_common.c:pb_const_cast:
  278|    941|{
  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|    941|    union {
  283|    941|        void *p1;
  284|    941|        const void *p2;
  285|    941|    } t;
  286|    941|    t.p2 = p;
  287|    941|    return t.p1;
  288|    941|}

pb_read:
   82|   899k|{
   83|   899k|    if (count == 0)
  ------------------
  |  Branch (83:9): [True: 81.7k, False: 818k]
  ------------------
   84|  81.7k|        return true;
   85|       |
   86|   818k|#ifndef PB_BUFFER_ONLY
   87|   818k|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (87:6): [True: 78.1k, False: 740k]
  |  Branch (87:21): [True: 15.6k, False: 62.5k]
  ------------------
   88|  15.6k|	{
   89|       |		/* Skip input bytes */
   90|  15.6k|		pb_byte_t tmp[16];
   91|   304k|		while (count > 16)
  ------------------
  |  Branch (91:10): [True: 289k, False: 14.9k]
  ------------------
   92|   289k|		{
   93|   289k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (93:8): [True: 771, False: 288k]
  ------------------
   94|    771|				return false;
   95|       |			
   96|   288k|			count -= 16;
   97|   288k|		}
   98|       |		
   99|  14.9k|		return pb_read(stream, tmp, count);
  100|  15.6k|	}
  101|   802k|#endif
  102|       |
  103|   802k|    if (stream->bytes_left < count)
  ------------------
  |  Branch (103:9): [True: 842, False: 801k]
  ------------------
  104|    842|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  889|    842|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    842|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 842]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  105|       |    
  106|   801k|#ifndef PB_BUFFER_ONLY
  107|   801k|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:9): [True: 2.56k, False: 799k]
  ------------------
  108|  2.56k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  889|  2.56k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|  2.56k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 1.56k, False: 1.00k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|       |#else
  110|       |    if (!buf_read(stream, buf, count))
  111|       |        return false;
  112|       |#endif
  113|       |    
  114|   799k|    if (stream->bytes_left < count)
  ------------------
  |  Branch (114:9): [True: 0, False: 799k]
  ------------------
  115|      0|        stream->bytes_left = 0;
  116|   799k|    else
  117|   799k|        stream->bytes_left -= count;
  118|       |
  119|   799k|    return true;
  120|   801k|}
pb_istream_from_buffer:
  143|   111k|{
  144|   111k|    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|   111k|    union {
  149|   111k|        void *state;
  150|   111k|        const void *c_state;
  151|   111k|    } state;
  152|       |#ifdef PB_BUFFER_ONLY
  153|       |    stream.callback = NULL;
  154|       |#else
  155|   111k|    stream.callback = &buf_read;
  156|   111k|#endif
  157|   111k|    state.c_state = buf;
  158|   111k|    stream.state = state.state;
  159|   111k|    stream.bytes_left = msglen;
  160|   111k|#ifndef PB_NO_ERRMSG
  161|   111k|    stream.errmsg = NULL;
  162|   111k|#endif
  163|   111k|    return stream;
  164|   111k|}
pb_decode_varint32:
  237|   520k|{
  238|   520k|    return pb_decode_varint32_eof(stream, dest, NULL);
  239|   520k|}
pb_decode_varint:
  243|   892k|{
  244|   892k|    pb_byte_t byte;
  245|   892k|    uint_fast8_t bitpos = 0;
  246|   892k|    uint64_t result = 0;
  247|       |    
  248|   892k|    do
  249|  1.70M|    {
  250|  1.70M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (250:13): [True: 1.01k, False: 1.70M]
  ------------------
  251|  1.01k|            return false;
  252|       |
  253|  1.70M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (253:13): [True: 51.9k, False: 1.65M]
  |  Branch (253:29): [True: 125, False: 51.8k]
  ------------------
  254|    125|            PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  889|    125|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    125|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 125]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  255|       |
  256|  1.70M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  257|  1.70M|        bitpos = (uint_fast8_t)(bitpos + 7);
  258|  1.70M|    } while (byte & 0x80);
  ------------------
  |  Branch (258:14): [True: 814k, False: 891k]
  ------------------
  259|       |    
  260|   891k|    *dest = result;
  261|   891k|    return true;
  262|   892k|}
pb_decode_tag:
  291|  1.78M|{
  292|  1.78M|    uint32_t temp;
  293|  1.78M|    *eof = false;
  294|  1.78M|    *wire_type = (pb_wire_type_t) 0;
  295|  1.78M|    *tag = 0;
  296|       |    
  297|  1.78M|    if (!pb_decode_varint32_eof(stream, &temp, eof))
  ------------------
  |  Branch (297:9): [True: 2.68k, False: 1.77M]
  ------------------
  298|  2.68k|    {
  299|  2.68k|        return false;
  300|  2.68k|    }
  301|       |    
  302|  1.77M|    *tag = temp >> 3;
  303|  1.77M|    *wire_type = (pb_wire_type_t)(temp & 7);
  304|  1.77M|    return true;
  305|  1.78M|}
pb_skip_field:
  308|  71.4k|{
  309|  71.4k|    switch (wire_type)
  310|  71.4k|    {
  311|  21.9k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (311:9): [True: 21.9k, False: 49.4k]
  ------------------
  312|  4.16k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (312:9): [True: 4.16k, False: 67.2k]
  ------------------
  313|  31.3k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (313:9): [True: 31.3k, False: 40.0k]
  ------------------
  314|  13.3k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (314:9): [True: 13.3k, False: 58.0k]
  ------------------
  315|    514|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  889|    514|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    514|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 514]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (315:9): [True: 514, False: 70.9k]
  ------------------
  316|  71.4k|    }
  317|  71.4k|}
pb_make_string_substream:
  362|   293k|{
  363|   293k|    uint32_t size;
  364|   293k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (364:9): [True: 799, False: 292k]
  ------------------
  365|    799|        return false;
  366|       |    
  367|   292k|    *substream = *stream;
  368|   292k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (368:9): [True: 5.82k, False: 286k]
  ------------------
  369|  5.82k|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  889|  5.82k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|  5.82k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 5.82k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  370|       |    
  371|   286k|    substream->bytes_left = (size_t)size;
  372|   286k|    stream->bytes_left -= (size_t)size;
  373|   286k|    return true;
  374|   292k|}
pb_close_string_substream:
  377|   286k|{
  378|   286k|    if (substream->bytes_left) {
  ------------------
  |  Branch (378:9): [True: 48.2k, False: 238k]
  ------------------
  379|  48.2k|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (379:13): [True: 1.10k, False: 47.1k]
  ------------------
  380|  1.10k|            return false;
  381|  48.2k|    }
  382|       |
  383|   285k|    stream->state = substream->state;
  384|       |
  385|   285k|#ifndef PB_NO_ERRMSG
  386|   285k|    stream->errmsg = substream->errmsg;
  387|   285k|#endif
  388|   285k|    return true;
  389|   286k|}
pb_decode_ex:
 1154|  8.14k|{
 1155|  8.14k|    bool status;
 1156|       |
 1157|  8.14k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  100|  8.14k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1157:9): [True: 4.07k, False: 4.07k]
  ------------------
 1158|  4.07k|    {
 1159|  4.07k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1160|  4.07k|    }
 1161|  4.07k|    else
 1162|  4.07k|    {
 1163|  4.07k|      pb_istream_t substream;
 1164|  4.07k|      if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1164:11): [True: 2.86k, False: 1.21k]
  ------------------
 1165|  2.86k|        return false;
 1166|       |
 1167|  1.21k|      status = pb_decode_inner(&substream, fields, dest_struct, flags);
 1168|       |
 1169|  1.21k|      if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1169:11): [True: 0, False: 1.21k]
  ------------------
 1170|      0|        return false;
 1171|  1.21k|    }
 1172|       |    
 1173|  5.28k|#ifdef PB_ENABLE_MALLOC
 1174|  5.28k|    if (!status)
  ------------------
  |  Branch (1174:9): [True: 5.20k, False: 84]
  ------------------
 1175|  5.20k|        pb_release(fields, dest_struct);
 1176|  5.28k|#endif
 1177|       |    
 1178|  5.28k|    return status;
 1179|  8.14k|}
pb_decode:
 1182|  12.2k|{
 1183|  12.2k|    bool status;
 1184|       |
 1185|  12.2k|    status = pb_decode_inner(stream, fields, dest_struct, 0);
 1186|       |
 1187|  12.2k|#ifdef PB_ENABLE_MALLOC
 1188|  12.2k|    if (!status)
  ------------------
  |  Branch (1188:9): [True: 12.1k, False: 68]
  ------------------
 1189|  12.1k|        pb_release(fields, dest_struct);
 1190|  12.2k|#endif
 1191|       |
 1192|  12.2k|    return status;
 1193|  12.2k|}
pb_release:
 1320|   422k|{
 1321|   422k|    pb_field_iter_t iter;
 1322|       |    
 1323|   422k|    if (!dest_struct)
  ------------------
  |  Branch (1323:9): [True: 0, False: 422k]
  ------------------
 1324|      0|        return; /* Ignore NULL pointers, similar to free() */
 1325|       |
 1326|   422k|    if (!pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1326:9): [True: 137k, False: 285k]
  ------------------
 1327|   137k|        return; /* Empty message type */
 1328|       |    
 1329|   285k|    do
 1330|  3.58M|    {
 1331|  3.58M|        pb_release_single_field(&iter);
 1332|  3.58M|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (1332:14): [True: 3.30M, False: 285k]
  ------------------
 1333|   285k|}
pb_decode_bool:
 1346|  31.2k|{
 1347|  31.2k|    uint32_t value;
 1348|  31.2k|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1348:9): [True: 261, False: 31.0k]
  ------------------
 1349|    261|        return false;
 1350|       |
 1351|  31.0k|    *(bool*)dest = (value != 0);
 1352|  31.0k|    return true;
 1353|  31.2k|}
pb_decode_svarint:
 1356|   108k|{
 1357|   108k|    pb_uint64_t value;
  ------------------
  |  |   57|   108k|#define pb_uint64_t uint64_t
  ------------------
 1358|   108k|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1358:9): [True: 317, False: 108k]
  ------------------
 1359|    317|        return false;
 1360|       |    
 1361|   108k|    if (value & 1)
  ------------------
  |  Branch (1361:9): [True: 6.34k, False: 101k]
  ------------------
 1362|  6.34k|        *dest = (pb_int64_t)(~(value >> 1));
 1363|   101k|    else
 1364|   101k|        *dest = (pb_int64_t)(value >> 1);
 1365|       |    
 1366|   108k|    return true;
 1367|   108k|}
pb_decode_fixed32:
 1370|   178k|{
 1371|   178k|    union {
 1372|   178k|        uint32_t fixed32;
 1373|   178k|        pb_byte_t bytes[4];
 1374|   178k|    } u;
 1375|       |
 1376|   178k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1376:9): [True: 244, False: 178k]
  ------------------
 1377|    244|        return false;
 1378|       |
 1379|       |#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1380|       |    /* fast path - if we know that we're on little endian, assign directly */
 1381|       |    *(uint32_t*)dest = u.fixed32;
 1382|       |#else
 1383|   178k|    *(uint32_t*)dest = ((uint32_t)u.bytes[0] << 0) |
 1384|   178k|                       ((uint32_t)u.bytes[1] << 8) |
 1385|   178k|                       ((uint32_t)u.bytes[2] << 16) |
 1386|   178k|                       ((uint32_t)u.bytes[3] << 24);
 1387|   178k|#endif
 1388|   178k|    return true;
 1389|   178k|}
pb_decode_fixed64:
 1393|  91.0k|{
 1394|  91.0k|    union {
 1395|  91.0k|        uint64_t fixed64;
 1396|  91.0k|        pb_byte_t bytes[8];
 1397|  91.0k|    } u;
 1398|       |
 1399|  91.0k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1399:9): [True: 290, False: 90.7k]
  ------------------
 1400|    290|        return false;
 1401|       |
 1402|       |#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1403|       |    /* fast path - if we know that we're on little endian, assign directly */
 1404|       |    *(uint64_t*)dest = u.fixed64;
 1405|       |#else
 1406|  90.7k|    *(uint64_t*)dest = ((uint64_t)u.bytes[0] << 0) |
 1407|  90.7k|                       ((uint64_t)u.bytes[1] << 8) |
 1408|  90.7k|                       ((uint64_t)u.bytes[2] << 16) |
 1409|  90.7k|                       ((uint64_t)u.bytes[3] << 24) |
 1410|  90.7k|                       ((uint64_t)u.bytes[4] << 32) |
 1411|  90.7k|                       ((uint64_t)u.bytes[5] << 40) |
 1412|  90.7k|                       ((uint64_t)u.bytes[6] << 48) |
 1413|  90.7k|                       ((uint64_t)u.bytes[7] << 56);
 1414|  90.7k|#endif
 1415|  90.7k|    return true;
 1416|  91.0k|}
pb_decode.c:buf_read:
   69|  3.64M|{
   70|  3.64M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   71|  3.64M|    stream->state = (pb_byte_t*)stream->state + count;
   72|       |    
   73|  3.64M|    if (buf != NULL)
  ------------------
  |  Branch (73:9): [True: 3.58M, False: 62.1k]
  ------------------
   74|  3.58M|    {
   75|  3.58M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   76|  3.58M|    }
   77|       |    
   78|  3.64M|    return true;
   79|  3.64M|}
pb_decode.c:pb_decode_varint32_eof:
  171|  2.30M|{
  172|  2.30M|    pb_byte_t byte;
  173|  2.30M|    uint32_t result;
  174|       |    
  175|  2.30M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (175:9): [True: 3.32k, False: 2.29M]
  ------------------
  176|  3.32k|    {
  177|  3.32k|        if (stream->bytes_left == 0)
  ------------------
  |  Branch (177:13): [True: 2.05k, False: 1.27k]
  ------------------
  178|  2.05k|        {
  179|  2.05k|            if (eof)
  ------------------
  |  Branch (179:17): [True: 1.19k, False: 861]
  ------------------
  180|  1.19k|            {
  181|  1.19k|                *eof = true;
  182|  1.19k|            }
  183|  2.05k|        }
  184|       |
  185|  3.32k|        return false;
  186|  3.32k|    }
  187|       |    
  188|  2.29M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (188:9): [True: 1.78M, False: 514k]
  ------------------
  189|  1.78M|    {
  190|       |        /* Quick case, 1 byte value */
  191|  1.78M|        result = byte;
  192|  1.78M|    }
  193|   514k|    else
  194|   514k|    {
  195|       |        /* Multibyte case */
  196|   514k|        uint_fast8_t bitpos = 7;
  197|   514k|        result = byte & 0x7F;
  198|       |        
  199|   514k|        do
  200|   557k|        {
  201|   557k|            if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (201:17): [True: 474, False: 557k]
  ------------------
  202|    474|                return false;
  203|       |            
  204|   557k|            if (bitpos >= 32)
  ------------------
  |  Branch (204:17): [True: 3.11k, False: 554k]
  ------------------
  205|  3.11k|            {
  206|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  207|  3.11k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (207:44): [True: 2.69k, False: 421]
  ------------------
  208|  3.11k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (208:41): [True: 1.12k, False: 1.99k]
  ------------------
  209|  3.11k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (209:27): [True: 1.90k, False: 84]
  |  Branch (209:50): [True: 1.65k, False: 256]
  ------------------
  210|       |
  211|  3.11k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (211:21): [True: 29, False: 3.08k]
  |  Branch (211:37): [True: 325, False: 2.76k]
  ------------------
  212|    354|                {
  213|    354|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  889|    354|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    354|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 354]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  214|    354|                }
  215|  3.11k|            }
  216|   554k|            else if (bitpos == 28)
  ------------------
  |  Branch (216:22): [True: 2.82k, False: 551k]
  ------------------
  217|  2.82k|            {
  218|  2.82k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (218:21): [True: 1.72k, False: 1.10k]
  |  Branch (218:43): [True: 108, False: 1.61k]
  ------------------
  219|    108|                {
  220|    108|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  889|    108|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    108|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 108]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  221|    108|                }
  222|  2.71k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  223|  2.71k|            }
  224|   551k|            else
  225|   551k|            {
  226|   551k|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  227|   551k|            }
  228|   557k|            bitpos = (uint_fast8_t)(bitpos + 7);
  229|   557k|        } while (byte & 0x80);
  ------------------
  |  Branch (229:18): [True: 43.7k, False: 513k]
  ------------------
  230|   514k|   }
  231|       |   
  232|  2.29M|   *dest = result;
  233|  2.29M|   return true;
  234|  2.29M|}
pb_decode.c:pb_readbyte:
  125|  4.56M|{
  126|  4.56M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (126:9): [True: 1.10k, False: 4.56M]
  ------------------
  127|  1.10k|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  889|  1.10k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|  1.10k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 1.10k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|       |
  129|  4.56M|#ifndef PB_BUFFER_ONLY
  130|  4.56M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (130:9): [True: 3.71k, False: 4.56M]
  ------------------
  131|  3.71k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  889|  3.71k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|  3.71k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 2.11k, False: 1.59k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|       |#else
  133|       |    *buf = *(const pb_byte_t*)stream->state;
  134|       |    stream->state = (pb_byte_t*)stream->state + 1;
  135|       |#endif
  136|       |
  137|  4.56M|    stream->bytes_left--;
  138|       |    
  139|  4.56M|    return true;    
  140|  4.56M|}
pb_decode.c:pb_skip_varint:
  266|  21.9k|{
  267|  21.9k|    pb_byte_t byte;
  268|  21.9k|    do
  269|  60.9k|    {
  270|  60.9k|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (270:13): [True: 357, False: 60.5k]
  ------------------
  271|    357|            return false;
  272|  60.9k|    } while (byte & 0x80);
  ------------------
  |  Branch (272:14): [True: 38.9k, False: 21.6k]
  ------------------
  273|  21.6k|    return true;
  274|  21.9k|}
pb_decode.c:pb_skip_string:
  277|  31.3k|{
  278|  31.3k|    uint32_t length;
  279|  31.3k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (279:9): [True: 339, False: 31.0k]
  ------------------
  280|    339|        return false;
  281|       |    
  282|  31.0k|    if ((size_t)length != length)
  ------------------
  |  Branch (282:9): [True: 0, False: 31.0k]
  ------------------
  283|      0|    {
  284|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  285|      0|    }
  286|       |
  287|  31.0k|    return pb_read(stream, NULL, (size_t)length);
  288|  31.0k|}
pb_decode.c:pb_decode_inner:
  990|   164k|{
  991|   164k|    uint32_t extension_range_start = 0;
  992|   164k|    pb_extension_t *extensions = NULL;
  993|       |
  994|       |    /* 'fixed_count_field' and 'fixed_count_size' track position of a repeated fixed
  995|       |     * count field. This can only handle _one_ repeated fixed count field that
  996|       |     * is unpacked and unordered among other (non repeated fixed count) fields.
  997|       |     */
  998|   164k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  302|   164k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  999|   164k|    pb_size_t fixed_count_size = 0;
 1000|   164k|    pb_size_t fixed_count_total_size = 0;
 1001|       |
 1002|   164k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1003|   164k|    const uint32_t allbits = ~(uint32_t)0;
 1004|   164k|    pb_field_iter_t iter;
 1005|       |
 1006|   164k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1006:9): [True: 110k, False: 54.4k]
  ------------------
 1007|   110k|    {
 1008|   110k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |   99|   110k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1008:13): [True: 53.3k, False: 56.9k]
  ------------------
 1009|  53.3k|        {
 1010|  53.3k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1010:17): [True: 0, False: 53.3k]
  ------------------
 1011|      0|                PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1012|  53.3k|        }
 1013|   110k|    }
 1014|       |
 1015|  1.32M|    while (stream->bytes_left)
  ------------------
  |  Branch (1015:12): [True: 1.18M, False: 145k]
  ------------------
 1016|  1.18M|    {
 1017|  1.18M|        uint32_t tag;
 1018|  1.18M|        pb_wire_type_t wire_type;
 1019|  1.18M|        bool eof;
 1020|       |
 1021|  1.18M|        if (!pb_decode_tag(stream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1021:13): [True: 2.68k, False: 1.17M]
  ------------------
 1022|  2.68k|        {
 1023|  2.68k|            if (eof)
  ------------------
  |  Branch (1023:17): [True: 1.19k, False: 1.49k]
  ------------------
 1024|  1.19k|                break;
 1025|  1.49k|            else
 1026|  1.49k|                return false;
 1027|  2.68k|        }
 1028|       |
 1029|  1.17M|        if (tag == 0)
  ------------------
  |  Branch (1029:13): [True: 1.10k, False: 1.17M]
  ------------------
 1030|  1.10k|        {
 1031|  1.10k|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  101|  1.10k|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1031:15): [True: 179, False: 922]
  ------------------
 1032|    179|          {
 1033|    179|            break;
 1034|    179|          }
 1035|    922|          else
 1036|    922|          {
 1037|    922|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  889|    922|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    922|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 922]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1038|    922|          }
 1039|  1.10k|        }
 1040|       |
 1041|  1.17M|        if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  288|  1.10M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|  1.10M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  257|  1.10M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1041:13): [True: 71.4k, False: 1.10M]
  |  Branch (1041:48): [True: 949, False: 1.10M]
  ------------------
 1042|  72.4k|        {
 1043|       |            /* No match found, check if it matches an extension. */
 1044|  72.4k|            if (extension_range_start == 0)
  ------------------
  |  Branch (1044:17): [True: 7.46k, False: 64.9k]
  ------------------
 1045|  7.46k|            {
 1046|  7.46k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1046:21): [True: 3.63k, False: 3.83k]
  ------------------
 1047|  3.63k|                {
 1048|  3.63k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1049|  3.63k|                    extension_range_start = iter.tag;
 1050|  3.63k|                }
 1051|       |
 1052|  7.46k|                if (!extensions)
  ------------------
  |  Branch (1052:21): [True: 6.35k, False: 1.10k]
  ------------------
 1053|  6.35k|                {
 1054|  6.35k|                    extension_range_start = (uint32_t)-1;
 1055|  6.35k|                }
 1056|  7.46k|            }
 1057|       |
 1058|  72.4k|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1058:17): [True: 9.05k, False: 63.3k]
  ------------------
 1059|  9.05k|            {
 1060|  9.05k|                size_t pos = stream->bytes_left;
 1061|       |
 1062|  9.05k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1062:21): [True: 86, False: 8.97k]
  ------------------
 1063|     86|                    return false;
 1064|       |
 1065|  8.97k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1065:21): [True: 935, False: 8.03k]
  ------------------
 1066|    935|                {
 1067|       |                    /* The field was handled */
 1068|    935|                    continue;
 1069|    935|                }
 1070|  8.97k|            }
 1071|       |
 1072|       |            /* No match found, skip data */
 1073|  71.4k|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1073:17): [True: 2.20k, False: 69.2k]
  ------------------
 1074|  2.20k|                return false;
 1075|  69.2k|            continue;
 1076|  71.4k|        }
 1077|       |
 1078|       |        /* If a repeated fixed count field was found, get size from
 1079|       |         * 'fixed_count_field' as there is no counter contained in the struct.
 1080|       |         */
 1081|  1.10M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  287|  1.10M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|  1.10M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  274|  2.20M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1081:13): [True: 36.6k, False: 1.06M]
  |  Branch (1081:57): [True: 2.69k, False: 33.9k]
  ------------------
 1082|  2.69k|        {
 1083|  2.69k|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1083:17): [True: 1.00k, False: 1.68k]
  ------------------
 1084|       |                /* If the new fixed count field does not match the previous one,
 1085|       |                 * check that the previous one is NULL or that it finished
 1086|       |                 * receiving all the expected data.
 1087|       |                 */
 1088|  1.00k|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  302|  2.01k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1088:21): [True: 345, False: 661]
  ------------------
 1089|  1.00k|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1089:21): [True: 36, False: 309]
  ------------------
 1090|     36|                {
 1091|     36|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  889|     36|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|     36|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 36]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1092|     36|                }
 1093|       |
 1094|    970|                fixed_count_field = iter.index;
 1095|    970|                fixed_count_size = 0;
 1096|    970|                fixed_count_total_size = iter.array_size;
 1097|    970|            }
 1098|       |
 1099|  2.65k|            iter.pSize = &fixed_count_size;
 1100|  2.65k|        }
 1101|       |
 1102|  1.10M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  287|  1.10M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|  1.10M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  271|  2.20M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1102:13): [True: 897k, False: 206k]
  ------------------
 1103|  1.10M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  204|   897k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1103:16): [True: 897k, False: 0]
  ------------------
 1104|   897k|        {
 1105|   897k|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1106|   897k|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1107|   897k|        }
 1108|       |
 1109|  1.10M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1109:13): [True: 12.5k, False: 1.09M]
  ------------------
 1110|  12.5k|            return false;
 1111|  1.10M|    }
 1112|       |
 1113|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1114|   147k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  302|   294k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1114:9): [True: 62, False: 147k]
  ------------------
 1115|   147k|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1115:9): [True: 40, False: 22]
  ------------------
 1116|     40|    {
 1117|     40|        PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  889|     40|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|     40|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 22, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1118|     40|    }
 1119|       |
 1120|       |    /* Check that all required fields were present. */
 1121|   147k|    {
 1122|   147k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1123|       |
 1124|   147k|        if (req_field_count > 0)
  ------------------
  |  Branch (1124:13): [True: 92.3k, False: 54.9k]
  ------------------
 1125|  92.3k|        {
 1126|  92.3k|            pb_size_t i;
 1127|       |
 1128|  92.3k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  204|  92.3k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1128:17): [True: 0, False: 92.3k]
  ------------------
 1129|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  204|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1130|       |
 1131|       |            /* Check the whole words */
 1132|  92.3k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1132:25): [True: 0, False: 92.3k]
  ------------------
 1133|      0|            {
 1134|      0|                if (fields_seen.bitfield[i] != allbits)
  ------------------
  |  Branch (1134:21): [True: 0, False: 0]
  ------------------
 1135|      0|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1136|      0|            }
 1137|       |
 1138|       |            /* Check the remaining bits (if any) */
 1139|  92.3k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1139:17): [True: 92.3k, False: 0]
  ------------------
 1140|  92.3k|            {
 1141|  92.3k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1141:21): [True: 2.37k, False: 89.9k]
  ------------------
 1142|  92.3k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1143|  2.37k|                {
 1144|  2.37k|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  889|  2.37k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|  2.37k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 902, False: 1.47k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1145|  2.37k|                }
 1146|  92.3k|            }
 1147|  92.3k|        }
 1148|   147k|    }
 1149|       |
 1150|   144k|    return true;
 1151|   147k|}
pb_decode.c:pb_message_set_to_defaults:
  951|   139k|{
  952|   139k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   49|   139k|#define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
  953|   139k|    uint32_t tag = 0;
  954|   139k|    pb_wire_type_t wire_type = PB_WT_VARINT;
  955|   139k|    bool eof;
  956|       |
  957|   139k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (957:9): [True: 94.9k, False: 44.1k]
  ------------------
  958|  94.9k|    {
  959|  94.9k|        defstream = pb_istream_from_buffer(iter->descriptor->default_value, (size_t)-1);
  960|  94.9k|        if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (960:13): [True: 0, False: 94.9k]
  ------------------
  961|      0|            return false;
  962|  94.9k|    }
  963|       |
  964|   139k|    do
  965|  1.57M|    {
  966|  1.57M|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (966:13): [True: 0, False: 1.57M]
  ------------------
  967|      0|            return false;
  968|       |
  969|  1.57M|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (969:13): [True: 1.09M, False: 482k]
  |  Branch (969:25): [True: 506k, False: 584k]
  ------------------
  970|   506k|        {
  971|       |            /* We have a default value for this field in the defstream */
  972|   506k|            if (!decode_field(&defstream, wire_type, iter))
  ------------------
  |  Branch (972:17): [True: 0, False: 506k]
  ------------------
  973|      0|                return false;
  974|   506k|            if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (974:17): [True: 0, False: 506k]
  ------------------
  975|      0|                return false;
  976|       |
  977|   506k|            if (iter->pSize)
  ------------------
  |  Branch (977:17): [True: 278k, False: 228k]
  ------------------
  978|   278k|                *(bool*)iter->pSize = false;
  979|   506k|        }
  980|  1.57M|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (980:14): [True: 1.43M, False: 139k]
  ------------------
  981|       |
  982|   139k|    return true;
  983|   139k|}
pb_decode.c:pb_field_set_to_default:
  869|  1.57M|{
  870|  1.57M|    pb_type_t type;
  871|  1.57M|    type = field->type;
  872|       |
  873|  1.57M|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  288|  1.57M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|  1.57M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  257|  1.57M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (873:9): [True: 16.2k, False: 1.55M]
  ------------------
  874|  16.2k|    {
  875|  16.2k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  876|  20.3k|        while (ext != NULL)
  ------------------
  |  Branch (876:16): [True: 4.07k, False: 16.2k]
  ------------------
  877|  4.07k|        {
  878|  4.07k|            pb_field_iter_t ext_iter;
  879|  4.07k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (879:17): [True: 4.07k, False: 0]
  ------------------
  880|  4.07k|            {
  881|  4.07k|                ext->found = false;
  882|  4.07k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (882:21): [True: 0, False: 4.07k]
  ------------------
  883|      0|                    return false;
  884|  4.07k|            }
  885|  4.07k|            ext = ext->next;
  886|  4.07k|        }
  887|  16.2k|    }
  888|  1.55M|    else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  286|  1.55M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|  1.55M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  281|  1.55M|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (888:14): [True: 1.01M, False: 541k]
  ------------------
  889|  1.01M|    {
  890|  1.01M|        bool init_data = true;
  891|  1.01M|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  287|  1.01M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|  1.01M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  272|  2.03M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (891:13): [True: 302k, False: 713k]
  |  Branch (891:52): [True: 302k, False: 0]
  ------------------
  892|   302k|        {
  893|       |            /* Set has_field to false. Still initialize the optional field
  894|       |             * itself also. */
  895|   302k|            *(bool*)field->pSize = false;
  896|   302k|        }
  897|   713k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  287|   713k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|   713k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  274|  1.42M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (897:18): [True: 171k, False: 542k]
  ------------------
  898|   713k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|   542k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|   542k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  276|   542k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (898:18): [True: 40.7k, False: 501k]
  ------------------
  899|   211k|        {
  900|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
  901|       |               ONEOF: Set which_field to 0. */
  902|   211k|            *(pb_size_t*)field->pSize = 0;
  903|   211k|            init_data = false;
  904|   211k|        }
  905|       |
  906|  1.01M|        if (init_data)
  ------------------
  |  Branch (906:13): [True: 804k, False: 211k]
  ------------------
  907|   804k|        {
  908|   804k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  289|  1.60M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|   804k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|   804k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  248|  1.60M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (289:32): [True: 89.6k, False: 714k]
  |  |  ------------------
  |  |  290|  1.60M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  288|   714k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|   714k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  253|   714k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (290:32): [True: 0, False: 714k]
  |  |  ------------------
  ------------------
  909|   804k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (909:18): [True: 36.6k, False: 52.9k]
  ------------------
  910|  89.6k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (910:18): [True: 0, False: 52.9k]
  ------------------
  911|  89.6k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (911:18): [True: 0, False: 52.9k]
  ------------------
  912|  36.6k|            {
  913|       |                /* Initialize submessage to defaults.
  914|       |                 * Only needed if it has default values
  915|       |                 * or callback/submessage fields. */
  916|  36.6k|                pb_field_iter_t submsg_iter;
  917|  36.6k|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (917:21): [True: 36.6k, False: 0]
  ------------------
  918|  36.6k|                {
  919|  36.6k|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (919:25): [True: 0, False: 36.6k]
  ------------------
  920|      0|                        return false;
  921|  36.6k|                }
  922|  36.6k|            }
  923|   767k|            else
  924|   767k|            {
  925|       |                /* Initialize to zeros */
  926|   767k|                memset(field->pData, 0, (size_t)field->data_size);
  927|   767k|            }
  928|   804k|        }
  929|  1.01M|    }
  930|   541k|    else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  286|   541k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|   541k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  282|   541k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (930:14): [True: 384k, False: 156k]
  ------------------
  931|   384k|    {
  932|       |        /* Initialize the pointer to NULL. */
  933|   384k|        *(void**)field->pField = NULL;
  934|       |
  935|       |        /* Initialize array count to 0. */
  936|   384k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  287|   384k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|   384k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  274|   768k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (936:13): [True: 85.5k, False: 298k]
  ------------------
  937|   384k|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|   298k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|   298k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  276|   298k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (937:13): [True: 8.14k, False: 290k]
  ------------------
  938|  93.7k|        {
  939|  93.7k|            *(pb_size_t*)field->pSize = 0;
  940|  93.7k|        }
  941|   384k|    }
  942|   156k|    else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  286|   156k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|   156k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  283|   156k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (942:14): [True: 156k, False: 0]
  ------------------
  943|   156k|    {
  944|       |        /* Don't overwrite callback */
  945|   156k|    }
  946|       |
  947|  1.57M|    return true;
  948|  1.57M|}
pb_decode.c:decode_extension:
  847|  9.05k|{
  848|  9.05k|    size_t pos = stream->bytes_left;
  849|       |    
  850|  18.0k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (850:12): [True: 9.05k, False: 8.97k]
  |  Branch (850:33): [True: 9.05k, False: 0]
  ------------------
  851|  9.05k|    {
  852|  9.05k|        bool status;
  853|  9.05k|        if (extension->type->decode)
  ------------------
  |  Branch (853:13): [True: 0, False: 9.05k]
  ------------------
  854|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  855|  9.05k|        else
  856|  9.05k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  857|       |
  858|  9.05k|        if (!status)
  ------------------
  |  Branch (858:13): [True: 86, False: 8.97k]
  ------------------
  859|     86|            return false;
  860|       |        
  861|  8.97k|        extension = extension->next;
  862|  8.97k|    }
  863|       |    
  864|  8.97k|    return true;
  865|  9.05k|}
pb_decode.c:default_extension_decoder:
  830|  9.05k|{
  831|  9.05k|    pb_field_iter_t iter;
  832|       |
  833|  9.05k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (833:9): [True: 0, False: 9.05k]
  ------------------
  834|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  835|       |
  836|  9.05k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (836:9): [True: 8.03k, False: 1.02k]
  |  Branch (836:28): [True: 0, False: 1.02k]
  ------------------
  837|  8.03k|        return true;
  838|       |
  839|  1.02k|    extension->found = true;
  840|  1.02k|    return decode_field(stream, wire_type, &iter);
  841|  9.05k|}
pb_decode.c:decode_field:
  798|  1.61M|{
  799|  1.61M|#ifdef PB_ENABLE_MALLOC
  800|       |    /* When decoding an oneof field, check if there is old data that must be
  801|       |     * released first. */
  802|  1.61M|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|  1.61M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|  1.61M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  276|  1.61M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (802:9): [True: 163k, False: 1.44M]
  ------------------
  803|   163k|    {
  804|   163k|        if (!pb_release_union_field(stream, field))
  ------------------
  |  Branch (804:13): [True: 0, False: 163k]
  ------------------
  805|      0|            return false;
  806|   163k|    }
  807|  1.61M|#endif
  808|       |
  809|  1.61M|    switch (PB_ATYPE(field->type))
  ------------------
  |  |  286|  1.61M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|  1.61M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
  810|  1.61M|    {
  811|  1.06M|        case PB_ATYPE_STATIC:
  ------------------
  |  |  281|  1.06M|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (811:9): [True: 1.06M, False: 545k]
  ------------------
  812|  1.06M|            return decode_static_field(stream, wire_type, field);
  813|       |        
  814|   444k|        case PB_ATYPE_POINTER:
  ------------------
  |  |  282|   444k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (814:9): [True: 444k, False: 1.16M]
  ------------------
  815|   444k|            return decode_pointer_field(stream, wire_type, field);
  816|       |        
  817|   100k|        case PB_ATYPE_CALLBACK:
  ------------------
  |  |  283|   100k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (817:9): [True: 100k, False: 1.51M]
  ------------------
  818|   100k|            return decode_callback_field(stream, wire_type, field);
  819|       |        
  820|      0|        default:
  ------------------
  |  Branch (820:9): [True: 0, False: 1.61M]
  ------------------
  821|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  822|  1.61M|    }
  823|  1.61M|}
pb_decode.c:pb_release_union_field:
 1199|   163k|{
 1200|   163k|    pb_field_iter_t old_field = *field;
 1201|   163k|    pb_size_t old_tag = *(pb_size_t*)field->pSize; /* Previous which_ value */
 1202|   163k|    pb_size_t new_tag = field->tag; /* New which_ value */
 1203|       |
 1204|   163k|    if (old_tag == 0)
  ------------------
  |  Branch (1204:9): [True: 3.13k, False: 160k]
  ------------------
 1205|  3.13k|        return true; /* Ok, no old data in union */
 1206|       |
 1207|   160k|    if (old_tag == new_tag)
  ------------------
  |  Branch (1207:9): [True: 23.3k, False: 136k]
  ------------------
 1208|  23.3k|        return true; /* Ok, old data is of same type => merge */
 1209|       |
 1210|       |    /* Release old data. The find can fail if the message struct contains
 1211|       |     * invalid data. */
 1212|   136k|    if (!pb_field_iter_find(&old_field, old_tag))
  ------------------
  |  Branch (1212:9): [True: 0, False: 136k]
  ------------------
 1213|      0|        PB_RETURN_ERROR(stream, "invalid union tag");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1214|       |
 1215|   136k|    pb_release_single_field(&old_field);
 1216|       |
 1217|   136k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  286|   136k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|   136k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  282|   136k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1217:9): [True: 57.5k, False: 79.1k]
  ------------------
 1218|  57.5k|    {
 1219|       |        /* Initialize the pointer to NULL to make sure it is valid
 1220|       |         * even in case of error return. */
 1221|  57.5k|        *(void**)field->pField = NULL;
 1222|  57.5k|        field->pData = NULL;
 1223|  57.5k|    }
 1224|       |
 1225|   136k|    return true;
 1226|   136k|}
pb_decode.c:decode_static_field:
  467|  1.06M|{
  468|  1.06M|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  287|  1.06M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|  1.06M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  469|  1.06M|    {
  470|   678k|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  271|   678k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (470:9): [True: 678k, False: 388k]
  ------------------
  471|   678k|            return decode_basic_field(stream, wire_type, field);
  472|       |            
  473|   283k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  272|   283k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (473:9): [True: 283k, False: 784k]
  ------------------
  474|   283k|            if (field->pSize != NULL)
  ------------------
  |  Branch (474:17): [True: 283k, False: 0]
  ------------------
  475|   283k|                *(bool*)field->pSize = true;
  476|   283k|            return decode_basic_field(stream, wire_type, field);
  477|       |    
  478|  7.51k|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  274|  7.51k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (478:9): [True: 7.51k, False: 1.05M]
  ------------------
  479|  7.51k|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (479:17): [True: 6.73k, False: 781]
  ------------------
  480|  7.51k|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  288|  6.73k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|  6.73k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  236|  6.73k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (480:20): [True: 3.45k, False: 3.27k]
  ------------------
  481|  3.45k|            {
  482|       |                /* Packed array */
  483|  3.45k|                bool status = true;
  484|  3.45k|                pb_istream_t substream;
  485|  3.45k|                pb_size_t *size = (pb_size_t*)field->pSize;
  486|  3.45k|                field->pData = (char*)field->pField + field->data_size * (*size);
  487|       |
  488|  3.45k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (488:21): [True: 454, False: 3.00k]
  ------------------
  489|    454|                    return false;
  490|       |
  491|  12.0k|                while (substream.bytes_left > 0 && *size < field->array_size)
  ------------------
  |  Branch (491:24): [True: 9.76k, False: 2.30k]
  |  Branch (491:52): [True: 9.49k, False: 264]
  ------------------
  492|  9.49k|                {
  493|  9.49k|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (493:25): [True: 431, False: 9.06k]
  ------------------
  494|    431|                    {
  495|    431|                        status = false;
  496|    431|                        break;
  497|    431|                    }
  498|  9.06k|                    (*size)++;
  499|  9.06k|                    field->pData = (char*)field->pData + field->data_size;
  500|  9.06k|                }
  501|       |
  502|  3.00k|                if (substream.bytes_left != 0)
  ------------------
  |  Branch (502:21): [True: 375, False: 2.62k]
  ------------------
  503|    375|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  889|    375|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    375|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 375]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  504|  2.62k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (504:21): [True: 0, False: 2.62k]
  ------------------
  505|      0|                    return false;
  506|       |
  507|  2.62k|                return status;
  508|  2.62k|            }
  509|  4.05k|            else
  510|  4.05k|            {
  511|       |                /* Repeated field */
  512|  4.05k|                pb_size_t *size = (pb_size_t*)field->pSize;
  513|  4.05k|                field->pData = (char*)field->pField + field->data_size * (*size);
  514|       |
  515|  4.05k|                if ((*size)++ >= field->array_size)
  ------------------
  |  Branch (515:21): [True: 113, False: 3.94k]
  ------------------
  516|    113|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  889|    113|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    113|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 113]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  517|       |
  518|  3.94k|                return decode_basic_field(stream, wire_type, field);
  519|  4.05k|            }
  520|       |
  521|  98.2k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  276|  98.2k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (521:9): [True: 98.2k, False: 968k]
  ------------------
  522|  98.2k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  289|   196k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  98.2k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|  98.2k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  248|   196k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (289:32): [True: 27.2k, False: 71.0k]
  |  |  ------------------
  |  |  290|   196k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  288|  71.0k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|  71.0k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  253|  71.0k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (290:32): [True: 71.0k, False: 0]
  |  |  ------------------
  ------------------
  523|  98.2k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (523:17): [True: 81.6k, False: 16.6k]
  ------------------
  524|  81.6k|            {
  525|       |                /* We memset to zero so that any callbacks are set to NULL.
  526|       |                 * This is because the callbacks might otherwise have values
  527|       |                 * from some other union field.
  528|       |                 * If callbacks are needed inside oneof field, use .proto
  529|       |                 * option submsg_callback to have a separate callback function
  530|       |                 * that can set the fields before submessage is decoded.
  531|       |                 * pb_dec_submessage() will set any default values. */
  532|  81.6k|                memset(field->pData, 0, (size_t)field->data_size);
  533|       |
  534|       |                /* Set default values for the submessage fields. */
  535|  81.6k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (535:21): [True: 45.0k, False: 36.5k]
  ------------------
  536|  81.6k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (536:21): [True: 0, False: 36.5k]
  ------------------
  537|  81.6k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (537:21): [True: 0, False: 36.5k]
  ------------------
  538|  45.0k|                {
  539|  45.0k|                    pb_field_iter_t submsg_iter;
  540|  45.0k|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (540:25): [True: 45.0k, False: 0]
  ------------------
  541|  45.0k|                    {
  542|  45.0k|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (542:29): [True: 0, False: 45.0k]
  ------------------
  543|      0|                            PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  544|  45.0k|                    }
  545|  45.0k|                }
  546|  81.6k|            }
  547|  98.2k|            *(pb_size_t*)field->pSize = field->tag;
  548|       |
  549|  98.2k|            return decode_basic_field(stream, wire_type, field);
  550|       |
  551|      0|        default:
  ------------------
  |  Branch (551:9): [True: 0, False: 1.06M]
  ------------------
  552|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  553|  1.06M|    }
  554|  1.06M|}
pb_decode.c:decode_basic_field:
  396|  1.54M|{
  397|  1.54M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  288|  1.54M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|  1.54M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  398|  1.54M|    {
  399|  31.3k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  228|  31.3k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (399:9): [True: 31.3k, False: 1.51M]
  ------------------
  400|  31.3k|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (400:17): [True: 12.9k, False: 18.4k]
  |  Branch (400:46): [True: 60, False: 12.8k]
  ------------------
  401|     60|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  889|     60|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|     60|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 60]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  402|       |
  403|  31.2k|            return pb_dec_bool(stream, field);
  404|       |
  405|   582k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  229|   582k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (405:9): [True: 582k, False: 963k]
  ------------------
  406|   784k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  230|   784k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (406:9): [True: 202k, False: 1.34M]
  ------------------
  407|   893k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  231|   893k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (407:9): [True: 108k, False: 1.43M]
  ------------------
  408|   893k|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (408:17): [True: 24.5k, False: 868k]
  |  Branch (408:46): [True: 370, False: 24.2k]
  ------------------
  409|    370|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  889|    370|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    370|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 370]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  410|       |
  411|   892k|            return pb_dec_varint(stream, field);
  412|       |
  413|   178k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  232|   178k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (413:9): [True: 178k, False: 1.36M]
  ------------------
  414|   178k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (414:17): [True: 1.38k, False: 177k]
  |  Branch (414:45): [True: 111, False: 1.26k]
  ------------------
  415|    111|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  889|    111|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    111|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 111]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  416|       |
  417|   178k|            return pb_decode_fixed32(stream, field->pData);
  418|       |
  419|  91.1k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  233|  91.1k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (419:9): [True: 91.1k, False: 1.45M]
  ------------------
  420|  91.1k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (420:17): [True: 2.01k, False: 89.0k]
  |  Branch (420:45): [True: 66, False: 1.95k]
  ------------------
  421|     66|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  889|     66|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|     66|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 66]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  422|       |
  423|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  424|       |            if (field->data_size == sizeof(float))
  425|       |            {
  426|       |                return pb_decode_double_as_float(stream, (float*)field->pData);
  427|       |            }
  428|       |#endif
  429|       |
  430|       |#ifdef PB_WITHOUT_64BIT
  431|       |            PB_RETURN_ERROR(stream, "invalid data_size");
  432|       |#else
  433|  91.0k|            return pb_decode_fixed64(stream, field->pData);
  434|      0|#endif
  435|       |
  436|  56.6k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  240|  56.6k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (436:9): [True: 56.6k, False: 1.48M]
  ------------------
  437|  56.6k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (437:17): [True: 215, False: 56.4k]
  ------------------
  438|    215|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  889|    215|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    215|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 215]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  439|       |
  440|  56.4k|            return pb_dec_bytes(stream, field);
  441|       |
  442|  97.1k|        case PB_LTYPE_STRING:
  ------------------
  |  |  244|  97.1k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (442:9): [True: 97.1k, False: 1.44M]
  ------------------
  443|  97.1k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (443:17): [True: 245, False: 96.8k]
  ------------------
  444|    245|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  889|    245|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    245|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 245]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  445|       |
  446|  96.8k|            return pb_dec_string(stream, field);
  447|       |
  448|   115k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  248|   115k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (448:9): [True: 115k, False: 1.42M]
  ------------------
  449|   186k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  253|   186k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (449:9): [True: 71.0k, False: 1.47M]
  ------------------
  450|   186k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (450:17): [True: 232, False: 186k]
  ------------------
  451|    232|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  889|    232|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    232|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 232]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  452|       |
  453|   186k|            return pb_dec_submessage(stream, field);
  454|       |
  455|  10.9k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  263|  10.9k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (455:9): [True: 10.9k, False: 1.53M]
  ------------------
  456|  10.9k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (456:17): [True: 25, False: 10.9k]
  ------------------
  457|     25|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  889|     25|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|     25|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  458|       |
  459|  10.9k|            return pb_dec_fixed_length_bytes(stream, field);
  460|       |
  461|      0|        default:
  ------------------
  |  Branch (461:9): [True: 0, False: 1.54M]
  ------------------
  462|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  463|  1.54M|    }
  464|  1.54M|}
pb_decode.c:pb_dec_bool:
 1420|  31.2k|{
 1421|  31.2k|    return pb_decode_bool(stream, (bool*)field->pData);
 1422|  31.2k|}
pb_decode.c:pb_dec_varint:
 1425|   892k|{
 1426|   892k|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  288|   892k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   892k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  230|   892k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1426:9): [True: 202k, False: 690k]
  ------------------
 1427|   202k|    {
 1428|   202k|        pb_uint64_t value, clamped;
  ------------------
  |  |   57|   202k|#define pb_uint64_t uint64_t
  ------------------
 1429|   202k|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1429:13): [True: 337, False: 202k]
  ------------------
 1430|    337|            return false;
 1431|       |
 1432|       |        /* Cast to the proper field size, while checking for overflows */
 1433|   202k|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1433:13): [True: 81.9k, False: 120k]
  ------------------
 1434|  81.9k|            clamped = *(pb_uint64_t*)field->pData = value;
 1435|   120k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1435:18): [True: 117k, False: 2.85k]
  ------------------
 1436|   117k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1437|  2.85k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1437:18): [True: 1.35k, False: 1.50k]
  ------------------
 1438|  1.35k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1439|  1.50k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1439:18): [True: 1.50k, False: 0]
  ------------------
 1440|  1.50k|            clamped = *(uint_least8_t*)field->pData = (uint_least8_t)value;
 1441|      0|        else
 1442|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1443|       |
 1444|   202k|        if (clamped != value)
  ------------------
  |  Branch (1444:13): [True: 331, False: 201k]
  ------------------
 1445|    331|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  889|    331|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    331|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 331]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1446|       |
 1447|   201k|        return true;
 1448|   202k|    }
 1449|   690k|    else
 1450|   690k|    {
 1451|   690k|        pb_uint64_t value;
  ------------------
  |  |   57|   690k|#define pb_uint64_t uint64_t
  ------------------
 1452|   690k|        pb_int64_t svalue;
  ------------------
  |  |   56|   690k|#define pb_int64_t int64_t
  ------------------
 1453|   690k|        pb_int64_t clamped;
  ------------------
  |  |   56|   690k|#define pb_int64_t int64_t
  ------------------
 1454|       |
 1455|   690k|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  288|   690k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   690k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  231|   690k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1455:13): [True: 108k, False: 581k]
  ------------------
 1456|   108k|        {
 1457|   108k|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1457:17): [True: 317, False: 108k]
  ------------------
 1458|    317|                return false;
 1459|   108k|        }
 1460|   581k|        else
 1461|   581k|        {
 1462|   581k|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1462:17): [True: 484, False: 581k]
  ------------------
 1463|    484|                return false;
 1464|       |
 1465|       |            /* See issue 97: Google's C++ protobuf allows negative varint values to
 1466|       |            * be cast as int32_t, instead of the int64_t that should be used when
 1467|       |            * encoding. Nanopb versions before 0.2.5 had a bug in encoding. In order to
 1468|       |            * not break decoding of such messages, we cast <=32 bit fields to
 1469|       |            * int32_t first to get the sign correct.
 1470|       |            */
 1471|   581k|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1471:17): [True: 308k, False: 273k]
  ------------------
 1472|   308k|                svalue = (pb_int64_t)value;
 1473|   273k|            else
 1474|   273k|                svalue = (int32_t)value;
 1475|   581k|        }
 1476|       |
 1477|       |        /* Cast to the proper field size, while checking for overflows */
 1478|   689k|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1478:13): [True: 333k, False: 355k]
  ------------------
 1479|   333k|            clamped = *(pb_int64_t*)field->pData = svalue;
 1480|   355k|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1480:18): [True: 350k, False: 5.11k]
  ------------------
 1481|   350k|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1482|  5.11k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1482:18): [True: 2.51k, False: 2.59k]
  ------------------
 1483|  2.51k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1484|  2.59k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1484:18): [True: 2.59k, False: 0]
  ------------------
 1485|  2.59k|            clamped = *(int_least8_t*)field->pData = (int_least8_t)svalue;
 1486|      0|        else
 1487|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1488|       |
 1489|   689k|        if (clamped != svalue)
  ------------------
  |  Branch (1489:13): [True: 287, False: 689k]
  ------------------
 1490|    287|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  889|    287|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    287|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 287]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1491|       |
 1492|   689k|        return true;
 1493|   689k|    }
 1494|   892k|}
pb_decode.c:pb_dec_bytes:
 1497|  56.4k|{
 1498|  56.4k|    uint32_t size;
 1499|  56.4k|    size_t alloc_size;
 1500|  56.4k|    pb_bytes_array_t *dest;
 1501|       |    
 1502|  56.4k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1502:9): [True: 63, False: 56.3k]
  ------------------
 1503|     63|        return false;
 1504|       |    
 1505|  56.3k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  302|  56.3k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1505:9): [True: 108, False: 56.2k]
  ------------------
 1506|    108|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  889|    108|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    108|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 108]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1507|       |    
 1508|  56.2k|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  372|  56.2k|#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes))
  ------------------
 1509|  56.2k|    if (size > alloc_size)
  ------------------
  |  Branch (1509:9): [True: 0, False: 56.2k]
  ------------------
 1510|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1511|       |    
 1512|  56.2k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  286|  56.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|  56.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  282|  56.2k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1512:9): [True: 44.3k, False: 11.9k]
  ------------------
 1513|  44.3k|    {
 1514|       |#ifndef PB_ENABLE_MALLOC
 1515|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1516|       |#else
 1517|  44.3k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1517:13): [True: 0, False: 44.3k]
  ------------------
 1518|      0|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1519|       |
 1520|  44.3k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1520:13): [True: 34, False: 44.2k]
  ------------------
 1521|     34|            return false;
 1522|  44.2k|        dest = *(pb_bytes_array_t**)field->pData;
 1523|  44.2k|#endif
 1524|  44.2k|    }
 1525|  11.9k|    else
 1526|  11.9k|    {
 1527|  11.9k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1527:13): [True: 495, False: 11.4k]
  ------------------
 1528|    495|            PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  889|    495|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    495|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 495]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1529|  11.4k|        dest = (pb_bytes_array_t*)field->pData;
 1530|  11.4k|    }
 1531|       |
 1532|  55.7k|    dest->size = (pb_size_t)size;
 1533|  55.7k|    return pb_read(stream, dest->bytes, (size_t)size);
 1534|  56.2k|}
pb_decode.c:allocate_field:
  562|   455k|{    
  563|   455k|    void *ptr = *(void**)pData;
  564|       |    
  565|   455k|    if (data_size == 0 || array_size == 0)
  ------------------
  |  Branch (565:9): [True: 0, False: 455k]
  |  Branch (565:27): [True: 0, False: 455k]
  ------------------
  566|      0|        PB_RETURN_ERROR(stream, "invalid size");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  567|       |    
  568|       |#ifdef __AVR__
  569|       |    /* Workaround for AVR libc bug 53284: http://savannah.nongnu.org/bugs/?53284
  570|       |     * Realloc to size of 1 byte can cause corruption of the malloc structures.
  571|       |     */
  572|       |    if (data_size == 1 && array_size == 1)
  573|       |    {
  574|       |        data_size = 2;
  575|       |    }
  576|       |#endif
  577|       |
  578|       |    /* Check for multiplication overflows.
  579|       |     * This code avoids the costly division if the sizes are small enough.
  580|       |     * Multiplication is safe as long as only half of bits are set
  581|       |     * in either multiplicand.
  582|       |     */
  583|   455k|    {
  584|   455k|        const size_t check_limit = (size_t)1 << (sizeof(size_t) * 4);
  585|   455k|        if (data_size >= check_limit || array_size >= check_limit)
  ------------------
  |  Branch (585:13): [True: 0, False: 455k]
  |  Branch (585:41): [True: 0, False: 455k]
  ------------------
  586|      0|        {
  587|      0|            const size_t size_max = (size_t)-1;
  588|      0|            if (size_max / array_size < data_size)
  ------------------
  |  Branch (588:17): [True: 0, False: 0]
  ------------------
  589|      0|            {
  590|      0|                PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  591|      0|            }
  592|      0|        }
  593|   455k|    }
  594|       |    
  595|       |    /* Allocate new or expand previous allocation */
  596|       |    /* Note: on failure the old pointer will remain in the structure,
  597|       |     * the message must be freed by caller also on error return. */
  598|   455k|    ptr = pb_realloc(ptr, array_size * data_size);
  ------------------
  |  |    3|   455k|#define pb_realloc(ptr,size) realloc_with_check(ptr,size)
  ------------------
  599|   455k|    if (ptr == NULL)
  ------------------
  |  Branch (599:9): [True: 277, False: 455k]
  ------------------
  600|    277|        PB_RETURN_ERROR(stream, "realloc failed");
  ------------------
  |  |  889|    277|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    277|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 277]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  601|       |    
  602|   455k|    *(void**)pData = ptr;
  603|   455k|    return true;
  604|   455k|}
pb_decode.c:pb_dec_string:
 1537|  96.8k|{
 1538|  96.8k|    uint32_t size;
 1539|  96.8k|    size_t alloc_size;
 1540|  96.8k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1541|       |
 1542|  96.8k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1542:9): [True: 102, False: 96.7k]
  ------------------
 1543|    102|        return false;
 1544|       |
 1545|  96.7k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1545:9): [True: 10, False: 96.7k]
  ------------------
 1546|     10|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  889|     10|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|     10|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1547|       |
 1548|       |    /* Space for null terminator */
 1549|  96.7k|    alloc_size = (size_t)(size + 1);
 1550|       |
 1551|  96.7k|    if (alloc_size < size)
  ------------------
  |  Branch (1551:9): [True: 0, False: 96.7k]
  ------------------
 1552|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1553|       |
 1554|  96.7k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  286|  96.7k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|  96.7k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  282|  96.7k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1554:9): [True: 39.7k, False: 57.0k]
  ------------------
 1555|  39.7k|    {
 1556|       |#ifndef PB_ENABLE_MALLOC
 1557|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1558|       |#else
 1559|  39.7k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1559:13): [True: 9, False: 39.7k]
  ------------------
 1560|      9|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  889|      9|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      9|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1561|       |
 1562|  39.7k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1562:13): [True: 139, False: 39.5k]
  ------------------
 1563|    139|            return false;
 1564|  39.5k|        dest = *(pb_byte_t**)field->pData;
 1565|  39.5k|#endif
 1566|  39.5k|    }
 1567|  57.0k|    else
 1568|  57.0k|    {
 1569|  57.0k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1569:13): [True: 468, False: 56.5k]
  ------------------
 1570|    468|            PB_RETURN_ERROR(stream, "string overflow");
  ------------------
  |  |  889|    468|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    468|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 468]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1571|  57.0k|    }
 1572|       |    
 1573|  96.1k|    dest[size] = 0;
 1574|       |
 1575|  96.1k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1575:9): [True: 209, False: 95.9k]
  ------------------
 1576|    209|        return false;
 1577|       |
 1578|       |#ifdef PB_VALIDATE_UTF8
 1579|       |    if (!pb_validate_utf8((const char*)dest))
 1580|       |        PB_RETURN_ERROR(stream, "invalid utf8");
 1581|       |#endif
 1582|       |
 1583|  95.9k|    return true;
 1584|  96.1k|}
pb_decode.c:pb_dec_submessage:
 1587|   186k|{
 1588|   186k|    bool status = true;
 1589|   186k|    bool submsg_consumed = false;
 1590|   186k|    pb_istream_t substream;
 1591|       |
 1592|   186k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1592:9): [True: 2.26k, False: 184k]
  ------------------
 1593|  2.26k|        return false;
 1594|       |    
 1595|   184k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1595:9): [True: 0, False: 184k]
  ------------------
 1596|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1597|       |    
 1598|       |    /* Submessages can have a separate message-level callback that is called
 1599|       |     * before decoding the message. Typically it is used to set callback fields
 1600|       |     * inside oneofs. */
 1601|   184k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  288|   184k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   184k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  253|   368k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1601:9): [True: 70.7k, False: 113k]
  |  Branch (1601:58): [True: 70.7k, False: 0]
  ------------------
 1602|  70.7k|    {
 1603|       |        /* Message callback is stored right before pSize. */
 1604|  70.7k|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
 1605|  70.7k|        if (callback->funcs.decode)
  ------------------
  |  Branch (1605:13): [True: 70.7k, False: 0]
  ------------------
 1606|  70.7k|        {
 1607|  70.7k|            status = callback->funcs.decode(&substream, field, &callback->arg);
 1608|       |
 1609|  70.7k|            if (substream.bytes_left == 0)
  ------------------
  |  Branch (1609:17): [True: 36.9k, False: 33.7k]
  ------------------
 1610|  36.9k|            {
 1611|  36.9k|                submsg_consumed = true;
 1612|  36.9k|            }
 1613|  70.7k|        }
 1614|  70.7k|    }
 1615|       |
 1616|       |    /* Now decode the submessage contents */
 1617|   184k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1617:9): [True: 184k, False: 0]
  |  Branch (1617:19): [True: 147k, False: 36.9k]
  ------------------
 1618|   147k|    {
 1619|   147k|        unsigned int flags = 0;
 1620|       |
 1621|       |        /* Static required/optional fields are already initialized by top-level
 1622|       |         * pb_decode(), no need to initialize them again. */
 1623|   147k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  286|   147k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|   147k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  281|   294k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1623:13): [True: 70.7k, False: 76.3k]
  ------------------
 1624|   147k|            PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  287|  70.7k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|  70.7k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  274|  70.7k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1624:13): [True: 68.7k, False: 2.08k]
  ------------------
 1625|  68.7k|        {
 1626|  68.7k|            flags = PB_DECODE_NOINIT;
  ------------------
  |  |   99|  68.7k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1627|  68.7k|        }
 1628|       |
 1629|   147k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1630|   147k|    }
 1631|       |    
 1632|   184k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1632:9): [True: 890, False: 183k]
  ------------------
 1633|    890|        return false;
 1634|       |
 1635|   183k|    return status;
 1636|   184k|}
pb_decode.c:pb_dec_fixed_length_bytes:
 1639|  10.9k|{
 1640|  10.9k|    uint32_t size;
 1641|       |
 1642|  10.9k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1642:9): [True: 13, False: 10.9k]
  ------------------
 1643|     13|        return false;
 1644|       |
 1645|  10.9k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  302|  10.9k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1645:9): [True: 96, False: 10.8k]
  ------------------
 1646|     96|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  889|     96|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|     96|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 96]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1647|       |
 1648|  10.8k|    if (size == 0)
  ------------------
  |  Branch (1648:9): [True: 1.61k, False: 9.18k]
  ------------------
 1649|  1.61k|    {
 1650|       |        /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */
 1651|  1.61k|        memset(field->pData, 0, (size_t)field->data_size);
 1652|  1.61k|        return true;
 1653|  1.61k|    }
 1654|       |
 1655|  9.18k|    if (size != field->data_size)
  ------------------
  |  Branch (1655:9): [True: 142, False: 9.04k]
  ------------------
 1656|    142|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  889|    142|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|    142|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 142]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1657|       |
 1658|  9.04k|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1659|  9.18k|}
pb_decode.c:decode_pointer_field:
  624|   444k|{
  625|       |#ifndef PB_ENABLE_MALLOC
  626|       |    PB_UNUSED(wire_type);
  627|       |    PB_UNUSED(field);
  628|       |    PB_RETURN_ERROR(stream, "no malloc support");
  629|       |#else
  630|   444k|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  287|   444k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|   444k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  631|   444k|    {
  632|   363k|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  271|   363k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (632:9): [True: 363k, False: 81.1k]
  ------------------
  633|   365k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  272|   365k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (633:9): [True: 1.93k, False: 442k]
  ------------------
  634|   430k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  276|   430k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (634:9): [True: 64.8k, False: 379k]
  ------------------
  635|   430k|            if (PB_LTYPE_IS_SUBMSG(field->type) && *(void**)field->pField != NULL)
  ------------------
  |  |  289|   860k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|   430k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|   430k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  248|   860k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (289:32): [True: 69.4k, False: 360k]
  |  |  ------------------
  |  |  290|   860k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  288|   360k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|   360k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  253|   360k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (290:32): [True: 0, False: 360k]
  |  |  ------------------
  ------------------
  |  Branch (635:52): [True: 9.97k, False: 59.4k]
  ------------------
  636|  9.97k|            {
  637|       |                /* Duplicate field, have to release the old allocation first. */
  638|       |                /* FIXME: Does this work correctly for oneofs? */
  639|  9.97k|                pb_release_single_field(field);
  640|  9.97k|            }
  641|       |        
  642|   430k|            if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|   430k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|   430k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  276|   430k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (642:17): [True: 64.8k, False: 365k]
  ------------------
  643|  64.8k|            {
  644|  64.8k|                *(pb_size_t*)field->pSize = field->tag;
  645|  64.8k|            }
  646|       |
  647|   430k|            if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  288|   430k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   430k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  244|   860k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (647:17): [True: 39.0k, False: 391k]
  ------------------
  648|   430k|                PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  288|   391k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   391k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  240|   391k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (648:17): [True: 43.3k, False: 347k]
  ------------------
  649|  82.4k|            {
  650|       |                /* pb_dec_string and pb_dec_bytes handle allocation themselves */
  651|  82.4k|                field->pData = field->pField;
  652|  82.4k|                return decode_basic_field(stream, wire_type, field);
  653|  82.4k|            }
  654|   347k|            else
  655|   347k|            {
  656|   347k|                if (!allocate_field(stream, field->pField, field->data_size, 1))
  ------------------
  |  Branch (656:21): [True: 1, False: 347k]
  ------------------
  657|      1|                    return false;
  658|       |                
  659|   347k|                field->pData = *(void**)field->pField;
  660|   347k|                initialize_pointer_field(field->pData, field);
  661|   347k|                return decode_basic_field(stream, wire_type, field);
  662|   347k|            }
  663|       |    
  664|  14.3k|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  274|  14.3k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (664:9): [True: 14.3k, False: 430k]
  ------------------
  665|  14.3k|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (665:17): [True: 12.1k, False: 2.13k]
  ------------------
  666|  14.3k|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  288|  12.1k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|  12.1k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  236|  12.1k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (666:20): [True: 2.82k, False: 9.35k]
  ------------------
  667|  2.82k|            {
  668|       |                /* Packed array, multiple items come in at once. */
  669|  2.82k|                bool status = true;
  670|  2.82k|                pb_size_t *size = (pb_size_t*)field->pSize;
  671|  2.82k|                size_t allocated_size = *size;
  672|  2.82k|                pb_istream_t substream;
  673|       |                
  674|  2.82k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (674:21): [True: 13, False: 2.81k]
  ------------------
  675|     13|                    return false;
  676|       |                
  677|  33.2k|                while (substream.bytes_left)
  ------------------
  |  Branch (677:24): [True: 30.8k, False: 2.34k]
  ------------------
  678|  30.8k|                {
  679|  30.8k|                    if (*size == PB_SIZE_MAX)
  ------------------
  |  |  302|  30.8k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (679:25): [True: 0, False: 30.8k]
  ------------------
  680|      0|                    {
  681|      0|#ifndef PB_NO_ERRMSG
  682|      0|                        stream->errmsg = "too many array entries";
  683|      0|#endif
  684|      0|                        status = false;
  685|      0|                        break;
  686|      0|                    }
  687|       |
  688|  30.8k|                    if ((size_t)*size + 1 > allocated_size)
  ------------------
  |  Branch (688:25): [True: 12.1k, False: 18.7k]
  ------------------
  689|  12.1k|                    {
  690|       |                        /* Allocate more storage. This tries to guess the
  691|       |                         * number of remaining entries. Round the division
  692|       |                         * upwards. */
  693|  12.1k|                        size_t remain = (substream.bytes_left - 1) / field->data_size + 1;
  694|  12.1k|                        if (remain < PB_SIZE_MAX - allocated_size)
  ------------------
  |  |  302|  12.1k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (694:29): [True: 7.32k, False: 4.85k]
  ------------------
  695|  7.32k|                            allocated_size += remain;
  696|  4.85k|                        else
  697|  4.85k|                            allocated_size += 1;
  698|       |                        
  699|  12.1k|                        if (!allocate_field(&substream, field->pField, field->data_size, allocated_size))
  ------------------
  |  Branch (699:29): [True: 102, False: 12.0k]
  ------------------
  700|    102|                        {
  701|    102|                            status = false;
  702|    102|                            break;
  703|    102|                        }
  704|  12.1k|                    }
  705|       |
  706|       |                    /* Decode the array entry */
  707|  30.7k|                    field->pData = *(char**)field->pField + field->data_size * (*size);
  708|  30.7k|                    if (field->pData == NULL)
  ------------------
  |  Branch (708:25): [True: 0, False: 30.7k]
  ------------------
  709|      0|                    {
  710|       |                        /* Shouldn't happen, but satisfies static analyzers */
  711|      0|                        status = false;
  712|      0|                        break;
  713|      0|                    }
  714|  30.7k|                    initialize_pointer_field(field->pData, field);
  715|  30.7k|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (715:25): [True: 366, False: 30.4k]
  ------------------
  716|    366|                    {
  717|    366|                        status = false;
  718|    366|                        break;
  719|    366|                    }
  720|       |                    
  721|  30.4k|                    (*size)++;
  722|  30.4k|                }
  723|  2.81k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (723:21): [True: 215, False: 2.59k]
  ------------------
  724|    215|                    return false;
  725|       |                
  726|  2.59k|                return status;
  727|  2.81k|            }
  728|  11.4k|            else
  729|  11.4k|            {
  730|       |                /* Normal repeated field, i.e. only one item at a time. */
  731|  11.4k|                pb_size_t *size = (pb_size_t*)field->pSize;
  732|       |
  733|  11.4k|                if (*size == PB_SIZE_MAX)
  ------------------
  |  |  302|  11.4k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (733:21): [True: 0, False: 11.4k]
  ------------------
  734|      0|                    PB_RETURN_ERROR(stream, "too many array entries");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  735|       |                
  736|  11.4k|                if (!allocate_field(stream, field->pField, field->data_size, (size_t)(*size + 1)))
  ------------------
  |  Branch (736:21): [True: 1, False: 11.4k]
  ------------------
  737|      1|                    return false;
  738|       |            
  739|  11.4k|                field->pData = *(char**)field->pField + field->data_size * (*size);
  740|  11.4k|                (*size)++;
  741|  11.4k|                initialize_pointer_field(field->pData, field);
  742|  11.4k|                return decode_basic_field(stream, wire_type, field);
  743|  11.4k|            }
  744|       |
  745|      0|        default:
  ------------------
  |  Branch (745:9): [True: 0, False: 444k]
  ------------------
  746|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  889|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  747|   444k|    }
  748|   444k|#endif
  749|   444k|}
pb_decode.c:initialize_pointer_field:
  608|   390k|{
  609|   390k|    if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  288|   390k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   390k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  244|   780k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (609:9): [True: 762, False: 389k]
  ------------------
  610|   390k|        PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  288|   389k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   389k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  240|   389k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (610:9): [True: 1.12k, False: 388k]
  ------------------
  611|  1.88k|    {
  612|  1.88k|        *(void**)pItem = NULL;
  613|  1.88k|    }
  614|   388k|    else if (PB_LTYPE_IS_SUBMSG(field->type))
  ------------------
  |  |  289|   388k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|   388k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|   388k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  248|   776k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (289:32): [True: 76.5k, False: 311k]
  |  |  ------------------
  |  |  290|   388k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  288|   311k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|   311k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  253|   311k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (290:32): [True: 0, False: 311k]
  |  |  ------------------
  ------------------
  615|  76.5k|    {
  616|       |        /* We memset to zero so that any callbacks are set to NULL.
  617|       |         * Default values will be set by pb_dec_submessage(). */
  618|  76.5k|        memset(pItem, 0, field->data_size);
  619|  76.5k|    }
  620|   390k|}
pb_decode.c:decode_callback_field:
  752|   100k|{
  753|   100k|    if (!field->descriptor->field_callback)
  ------------------
  |  Branch (753:9): [True: 0, False: 100k]
  ------------------
  754|      0|        return pb_skip_field(stream, wire_type);
  755|       |
  756|   100k|    if (wire_type == PB_WT_STRING)
  ------------------
  |  Branch (756:9): [True: 96.6k, False: 4.04k]
  ------------------
  757|  96.6k|    {
  758|  96.6k|        pb_istream_t substream;
  759|  96.6k|        size_t prev_bytes_left;
  760|       |        
  761|  96.6k|        if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (761:13): [True: 1.02k, False: 95.6k]
  ------------------
  762|  1.02k|            return false;
  763|       |        
  764|  95.6k|        do
  765|  95.6k|        {
  766|  95.6k|            prev_bytes_left = substream.bytes_left;
  767|  95.6k|            if (!field->descriptor->field_callback(&substream, NULL, field))
  ------------------
  |  Branch (767:17): [True: 0, False: 95.6k]
  ------------------
  768|      0|            {
  769|      0|                PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "callback failed");
  ------------------
  |  |  885|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (885:53): [True: 0, False: 0]
  |  |  |  Branch (885:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  770|      0|                return false;
  771|      0|            }
  772|  95.6k|        } while (substream.bytes_left > 0 && substream.bytes_left < prev_bytes_left);
  ------------------
  |  Branch (772:18): [True: 46.3k, False: 49.2k]
  |  Branch (772:46): [True: 0, False: 46.3k]
  ------------------
  773|       |        
  774|  95.6k|        if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (774:13): [True: 0, False: 95.6k]
  ------------------
  775|      0|            return false;
  776|       |
  777|  95.6k|        return true;
  778|  95.6k|    }
  779|  4.04k|    else
  780|  4.04k|    {
  781|       |        /* Copy the single scalar value to stack.
  782|       |         * This is required so that we can limit the stream length,
  783|       |         * which in turn allows to use same callback for packed and
  784|       |         * not-packed fields. */
  785|  4.04k|        pb_istream_t substream;
  786|  4.04k|        pb_byte_t buffer[10];
  787|  4.04k|        size_t size = sizeof(buffer);
  788|       |        
  789|  4.04k|        if (!read_raw_value(stream, wire_type, buffer, &size))
  ------------------
  |  Branch (789:13): [True: 125, False: 3.92k]
  ------------------
  790|    125|            return false;
  791|  3.92k|        substream = pb_istream_from_buffer(buffer, size);
  792|       |        
  793|  3.92k|        return field->descriptor->field_callback(&substream, NULL, field);
  794|  4.04k|    }
  795|   100k|}
pb_decode.c:read_raw_value:
  323|  4.04k|{
  324|  4.04k|    size_t max_size = *size;
  325|  4.04k|    switch (wire_type)
  326|  4.04k|    {
  327|  1.88k|        case PB_WT_VARINT:
  ------------------
  |  Branch (327:9): [True: 1.88k, False: 2.15k]
  ------------------
  328|  1.88k|            *size = 0;
  329|  1.88k|            do
  330|  3.05k|            {
  331|  3.05k|                (*size)++;
  332|  3.05k|                if (*size > max_size)
  ------------------
  |  Branch (332:21): [True: 6, False: 3.05k]
  ------------------
  333|      6|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  889|      6|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|      6|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  334|       |
  335|  3.05k|                if (!pb_read(stream, buf, 1))
  ------------------
  |  Branch (335:21): [True: 37, False: 3.01k]
  ------------------
  336|     37|                    return false;
  337|  3.05k|            } while (*buf++ & 0x80);
  ------------------
  |  Branch (337:22): [True: 1.17k, False: 1.84k]
  ------------------
  338|  1.84k|            return true;
  339|       |            
  340|    294|        case PB_WT_64BIT:
  ------------------
  |  Branch (340:9): [True: 294, False: 3.75k]
  ------------------
  341|    294|            *size = 8;
  342|    294|            return pb_read(stream, buf, 8);
  343|       |        
  344|  1.80k|        case PB_WT_32BIT:
  ------------------
  |  Branch (344:9): [True: 1.80k, False: 2.23k]
  ------------------
  345|  1.80k|            *size = 4;
  346|  1.80k|            return pb_read(stream, buf, 4);
  347|       |        
  348|      0|        case PB_WT_STRING:
  ------------------
  |  Branch (348:9): [True: 0, False: 4.04k]
  ------------------
  349|       |            /* Calling read_raw_value with a PB_WT_STRING is an error.
  350|       |             * Explicitly handle this case and fallthrough to default to avoid
  351|       |             * compiler warnings.
  352|       |             */
  353|       |
  354|     56|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  889|     56|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  885|     56|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (885:53): [True: 0, False: 56]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (354:9): [True: 56, False: 3.99k]
  ------------------
  355|  4.04k|    }
  356|  4.04k|}
pb_decode.c:pb_release_single_field:
 1229|  3.74M|{
 1230|  3.74M|    pb_type_t type;
 1231|  3.74M|    type = field->type;
 1232|       |
 1233|  3.74M|    if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|  3.74M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|  3.74M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  276|  3.74M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (1233:9): [True: 256k, False: 3.48M]
  ------------------
 1234|   256k|    {
 1235|   256k|        if (*(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (1235:13): [True: 106k, False: 149k]
  ------------------
 1236|   106k|            return; /* This is not the current field in the union */
 1237|   256k|    }
 1238|       |
 1239|       |    /* Release anything contained inside an extension or submsg.
 1240|       |     * This has to be done even if the submsg itself is statically
 1241|       |     * allocated. */
 1242|  3.63M|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  288|  3.63M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|  3.63M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  257|  3.63M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1242:9): [True: 37.7k, False: 3.60M]
  ------------------
 1243|  37.7k|    {
 1244|       |        /* Release fields from all extensions in the linked list */
 1245|  37.7k|        pb_extension_t *ext = *(pb_extension_t**)field->pData;
 1246|  51.0k|        while (ext != NULL)
  ------------------
  |  Branch (1246:16): [True: 13.3k, False: 37.7k]
  ------------------
 1247|  13.3k|        {
 1248|  13.3k|            pb_field_iter_t ext_iter;
 1249|  13.3k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (1249:17): [True: 13.3k, False: 0]
  ------------------
 1250|  13.3k|            {
 1251|  13.3k|                pb_release_single_field(&ext_iter);
 1252|  13.3k|            }
 1253|  13.3k|            ext = ext->next;
 1254|  13.3k|        }
 1255|  37.7k|    }
 1256|  3.60M|    else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  289|  7.20M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  3.60M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|  3.60M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  248|  7.20M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (289:32): [True: 441k, False: 3.15M]
  |  |  ------------------
  |  |  290|  7.20M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  288|  3.15M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|  3.15M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  253|  3.15M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (290:32): [True: 64.6k, False: 3.09M]
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  286|   505k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|   505k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  283|   505k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1256:42): [True: 489k, False: 16.1k]
  ------------------
 1257|   489k|    {
 1258|       |        /* Release fields in submessage or submsg array */
 1259|   489k|        pb_size_t count = 1;
 1260|       |        
 1261|   489k|        if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  286|   489k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|   489k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  282|   489k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1261:13): [True: 142k, False: 347k]
  ------------------
 1262|   142k|        {
 1263|   142k|            field->pData = *(void**)field->pField;
 1264|   142k|        }
 1265|   347k|        else
 1266|   347k|        {
 1267|   347k|            field->pData = field->pField;
 1268|   347k|        }
 1269|       |        
 1270|   489k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  287|   489k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|   489k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  274|   489k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1270:13): [True: 59.2k, False: 430k]
  ------------------
 1271|  59.2k|        {
 1272|  59.2k|            count = *(pb_size_t*)field->pSize;
 1273|       |
 1274|  59.2k|            if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  286|  59.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|  59.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  281|   118k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1274:17): [True: 42.9k, False: 16.2k]
  |  Branch (1274:54): [True: 106, False: 42.8k]
  ------------------
 1275|    106|            {
 1276|       |                /* Protect against corrupted _count fields */
 1277|    106|                count = field->array_size;
 1278|    106|            }
 1279|  59.2k|        }
 1280|       |        
 1281|   489k|        if (field->pData)
  ------------------
  |  Branch (1281:13): [True: 417k, False: 72.3k]
  ------------------
 1282|   417k|        {
 1283|   802k|            for (; count > 0; count--)
  ------------------
  |  Branch (1283:20): [True: 385k, False: 417k]
  ------------------
 1284|   385k|            {
 1285|   385k|                pb_release(field->submsg_desc, field->pData);
 1286|   385k|                field->pData = (char*)field->pData + field->data_size;
 1287|   385k|            }
 1288|   417k|        }
 1289|   489k|    }
 1290|       |    
 1291|  3.63M|    if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  286|  3.63M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|  3.63M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  282|  3.63M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1291:9): [True: 712k, False: 2.92M]
  ------------------
 1292|   712k|    {
 1293|   712k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  287|   712k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|   712k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  274|  1.42M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1293:13): [True: 171k, False: 541k]
  ------------------
 1294|   712k|            (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  288|   171k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   171k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  244|   342k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (1294:14): [True: 8.14k, False: 162k]
  ------------------
 1295|   171k|             PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  288|   162k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|   162k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                           PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  240|   162k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (1295:14): [True: 8.14k, False: 154k]
  ------------------
 1296|  16.2k|        {
 1297|       |            /* Release entries in repeated string or bytes array */
 1298|  16.2k|            void **pItem = *(void***)field->pField;
 1299|  16.2k|            pb_size_t count = *(pb_size_t*)field->pSize;
 1300|  18.1k|            for (; count > 0; count--)
  ------------------
  |  Branch (1300:20): [True: 1.88k, False: 16.2k]
  ------------------
 1301|  1.88k|            {
 1302|  1.88k|                pb_free(*pItem);
  ------------------
  |  |    4|  1.88k|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1303|  1.88k|                *pItem++ = NULL;
 1304|  1.88k|            }
 1305|  16.2k|        }
 1306|       |        
 1307|   712k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  287|   712k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|   712k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  274|   712k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1307:13): [True: 171k, False: 541k]
  ------------------
 1308|   171k|        {
 1309|       |            /* We are going to release the array, so set the size to 0 */
 1310|   171k|            *(pb_size_t*)field->pSize = 0;
 1311|   171k|        }
 1312|       |        
 1313|       |        /* Release main pointer */
 1314|   712k|        pb_free(*(void**)field->pField);
  ------------------
  |  |    4|   712k|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1315|   712k|        *(void**)field->pField = NULL;
 1316|   712k|    }
 1317|  3.63M|}

malloc_with_check:
   55|   189k|{
   56|   189k|    char *buf = NULL;
   57|       |
   58|   189k|    if (size <= g_max_alloc_bytes - g_alloc_bytes)
  ------------------
  |  Branch (58:9): [True: 189k, False: 235]
  ------------------
   59|   189k|    {
   60|   189k|        buf = malloc(round_blocksize(size + GUARD_SIZE));
  ------------------
  |  |   12|   189k|#define GUARD_SIZE (sizeof(size_t)*3)
  ------------------
   61|   189k|    }
   62|       |
   63|   189k|    if (buf)
  ------------------
  |  Branch (63:9): [True: 189k, False: 235]
  ------------------
   64|   189k|    {
   65|   189k|        ((size_t*)buf)[0] = size;
   66|   189k|        ((size_t*)buf)[1] = CHECK1;
  ------------------
  |  |   14|   189k|#define CHECK1 ((size_t)0xDEADBEEF)
  ------------------
   67|   189k|        ((size_t*)(buf + size))[2] = CHECK2;
  ------------------
  |  |   15|   189k|#define CHECK2 ((size_t)0x600DCAFE)
  ------------------
   68|   189k|        g_alloc_count++;
   69|   189k|        g_alloc_bytes += size;
   70|   189k|        if (DEBUG_MALLOC) fprintf(stderr, "Alloc 0x%04x/%u\n", (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   22|   189k|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (22:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
                      if (DEBUG_MALLOC) fprintf(stderr, "Alloc 0x%04x/%u\n", (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   13|      0|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   71|   189k|        return buf + PREFIX_SIZE;
  ------------------
  |  |   13|   189k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   72|   189k|    }
   73|    235|    else
   74|    235|    {
   75|    235|        if (DEBUG_MALLOC) fprintf(stderr, "malloc(%u) failed\n", (unsigned)size);
  ------------------
  |  |   22|    235|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (22:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
   76|    235|        return NULL;
   77|    235|    }
   78|   189k|}
free_with_check:
   82|   742k|{
   83|   742k|    if (mem)
  ------------------
  |  Branch (83:9): [True: 189k, False: 553k]
  ------------------
   84|   189k|    {
   85|   189k|        char *buf = (char*)mem - PREFIX_SIZE;
  ------------------
  |  |   13|   189k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   86|   189k|        size_t size = ((size_t*)buf)[0];
   87|   189k|        if (DEBUG_MALLOC) fprintf(stderr, "Release 0x%04x/%u\n", (unsigned)(uintptr_t)mem, (unsigned)size);
  ------------------
  |  |   22|   189k|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (22:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
   88|   189k|        assert(((size_t*)buf)[1] == CHECK1);
   89|   189k|        assert(((size_t*)(buf + size))[2] == CHECK2);
   90|   189k|        assert(g_alloc_count > 0);
   91|   189k|        assert(g_alloc_bytes >= size);
   92|   189k|        ((size_t*)buf)[1] = 0;
   93|   189k|        ((size_t*)(buf + size))[2] = 0;
   94|   189k|        g_alloc_count--;
   95|   189k|        g_alloc_bytes -= size;
   96|   189k|        free(buf);
   97|   189k|    }
   98|   742k|}
realloc_with_check:
  102|   455k|{
  103|   455k|    if (!ptr && size)
  ------------------
  |  Branch (103:9): [True: 160k, False: 294k]
  |  Branch (103:17): [True: 160k, False: 0]
  ------------------
  104|   160k|    {
  105|       |        /* Allocate new block and write guard values */
  106|   160k|        return malloc_with_check(size);
  107|   160k|    }
  108|   294k|    else if (ptr && size)
  ------------------
  |  Branch (108:14): [True: 294k, False: 0]
  |  Branch (108:21): [True: 294k, False: 0]
  ------------------
  109|   294k|    {
  110|       |        /* Change block size */
  111|   294k|        char *buf = (char*)ptr - PREFIX_SIZE;
  ------------------
  |  |   13|   294k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  112|   294k|        size_t oldsize = ((size_t*)buf)[0];
  113|   294k|        assert(((size_t*)buf)[1] == CHECK1);
  114|   294k|        assert(((size_t*)(buf + oldsize))[2] == CHECK2);
  115|   294k|        assert(g_alloc_count > 0);
  116|   294k|        assert(g_alloc_bytes >= oldsize);
  117|       |
  118|   294k|        if (size <= g_max_alloc_bytes - (g_alloc_bytes - oldsize))
  ------------------
  |  Branch (118:13): [True: 294k, False: 42]
  ------------------
  119|   294k|        {
  120|   294k|            size_t new_rounded = round_blocksize(size + GUARD_SIZE);
  ------------------
  |  |   12|   294k|#define GUARD_SIZE (sizeof(size_t)*3)
  ------------------
  121|   294k|            size_t old_rounded = round_blocksize(oldsize + GUARD_SIZE);
  ------------------
  |  |   12|   294k|#define GUARD_SIZE (sizeof(size_t)*3)
  ------------------
  122|       |
  123|   294k|            if (new_rounded != old_rounded)
  ------------------
  |  Branch (123:17): [True: 14.7k, False: 279k]
  ------------------
  124|  14.7k|            {
  125|  14.7k|                buf = realloc(buf, new_rounded);
  126|  14.7k|            }
  127|   294k|        }
  128|     42|        else
  129|     42|        {
  130|     42|            buf = NULL;
  131|     42|        }
  132|       |
  133|   294k|        if (!buf)
  ------------------
  |  Branch (133:13): [True: 42, False: 294k]
  ------------------
  134|     42|        {
  135|     42|            if (DEBUG_MALLOC) fprintf(stderr, "Realloc 0x%04x/%u to %u failed\n", (unsigned)(uintptr_t)ptr, (unsigned)oldsize, (unsigned)size);
  ------------------
  |  |   22|     42|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (22:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  136|     42|            return NULL;
  137|     42|        }
  138|       |
  139|   294k|        ((size_t*)buf)[0] = size;
  140|   294k|        ((size_t*)buf)[1] = CHECK1;
  ------------------
  |  |   14|   294k|#define CHECK1 ((size_t)0xDEADBEEF)
  ------------------
  141|   294k|        ((size_t*)(buf + size))[2] = CHECK2;
  ------------------
  |  |   15|   294k|#define CHECK2 ((size_t)0x600DCAFE)
  ------------------
  142|   294k|        g_alloc_bytes -= oldsize;
  143|   294k|        g_alloc_bytes += size;
  144|       |
  145|   294k|        if (DEBUG_MALLOC) fprintf(stderr, "Realloc 0x%04x/%u to 0x%04x/%u\n", (unsigned)(uintptr_t)ptr, (unsigned)oldsize, (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   22|   294k|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (22:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
                      if (DEBUG_MALLOC) fprintf(stderr, "Realloc 0x%04x/%u to 0x%04x/%u\n", (unsigned)(uintptr_t)ptr, (unsigned)oldsize, (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   13|      0|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  146|   294k|        return buf + PREFIX_SIZE;
  ------------------
  |  |   13|   294k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  147|   294k|    }
  148|      0|    else if (ptr && !size)
  ------------------
  |  Branch (148:14): [True: 0, False: 0]
  |  Branch (148:21): [True: 0, False: 0]
  ------------------
  149|      0|    {
  150|       |        /* Deallocate */
  151|      0|        free_with_check(ptr);
  152|      0|        return NULL;
  153|      0|    }
  154|      0|    else
  155|      0|    {
  156|       |        /* No action */
  157|      0|        return NULL;
  158|      0|    }
  159|   455k|}
get_alloc_count:
  163|  48.8k|{
  164|  48.8k|    return g_alloc_count;
  165|  48.8k|}
get_alloc_bytes:
  176|  4.07k|{
  177|  4.07k|    return g_alloc_bytes;
  178|  4.07k|}
set_max_alloc_bytes:
  182|  8.14k|{
  183|  8.14k|    g_max_alloc_bytes = max_bytes;
  184|  8.14k|}
get_max_alloc_bytes:
  187|  4.07k|{
  188|  4.07k|    return g_max_alloc_bytes;
  189|  4.07k|}
malloc_wrappers.c:round_blocksize:
   36|   778k|{
   37|   778k|    if (size < 256)
  ------------------
  |  Branch (37:9): [True: 728k, False: 49.6k]
  ------------------
   38|   728k|    {
   39|   728k|        return size;
   40|   728k|    }
   41|  49.6k|    else
   42|  49.6k|    {
   43|  49.6k|        return (size + 1023) / 1024 * 1024;
   44|  49.6k|    }
   45|   778k|}

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

do_callback_decode:
  161|  4.07k|{
  162|  4.07k|    bool status;
  163|  4.07k|    pb_istream_t stream;
  164|  4.07k|    size_t initial_alloc_count = get_alloc_count();
  165|  4.07k|    alltypes_callback_AllTypes *msg = malloc_with_check(sizeof(alltypes_callback_AllTypes));
  166|  4.07k|    assert(msg);
  167|       |
  168|  4.07k|    memset(msg, 0, sizeof(alltypes_callback_AllTypes));
  169|  4.07k|    stream = pb_istream_from_buffer(buffer, msglen);
  170|       |
  171|  4.07k|    msg->rep_int32.funcs.decode = &field_callback;
  172|  4.07k|    msg->rep_int32.arg = &g_sentinel;
  173|  4.07k|    msg->rep_string.funcs.decode = &field_callback;
  174|  4.07k|    msg->rep_string.arg = &g_sentinel;
  175|  4.07k|    msg->rep_farray.funcs.decode = &field_callback;
  176|  4.07k|    msg->rep_farray.arg = &g_sentinel;
  177|  4.07k|    msg->req_limits.int64_min.funcs.decode = &field_callback;
  178|  4.07k|    msg->req_limits.int64_min.arg = &g_sentinel;
  179|  4.07k|    msg->cb_oneof.funcs.decode = &submsg_callback;
  180|  4.07k|    msg->cb_oneof.arg = &g_sentinel;
  181|       |
  182|  4.07k|    status = pb_decode(&stream, alltypes_callback_AllTypes_fields, msg);
  ------------------
  |  |  465|  4.07k|#define alltypes_callback_AllTypes_fields &alltypes_callback_AllTypes_msg
  ------------------
  183|       |
  184|  4.07k|    if (assert_success)
  ------------------
  |  Branch (184:9): [True: 0, False: 4.07k]
  ------------------
  185|      0|    {
  186|      0|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  886|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (886:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (186:13): [True: 0, False: 0]
  ------------------
  187|      0|        assert(status);
  188|      0|    }
  189|       |
  190|  4.07k|    pb_release(alltypes_callback_AllTypes_fields, msg);
  ------------------
  |  |  465|  4.07k|#define alltypes_callback_AllTypes_fields &alltypes_callback_AllTypes_msg
  ------------------
  191|  4.07k|    free_with_check(msg);
  192|  4.07k|    assert(get_alloc_count() == initial_alloc_count);
  193|       |
  194|  4.07k|    return status;
  195|  4.07k|}
do_roundtrips:
  290|  4.07k|{
  291|  4.07k|    size_t initial_alloc_count = get_alloc_count();
  292|  4.07k|    PB_UNUSED(expect_valid); /* Potentially unused depending on configuration */
  ------------------
  |  |  143|  4.07k|#define PB_UNUSED(x) (void)(x)
  ------------------
  293|       |
  294|       |#ifdef FUZZTEST_PROTO2_STATIC
  295|       |    if (do_decode(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, 0, expect_valid))
  296|       |    {
  297|       |        do_roundtrip(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields);
  298|       |        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, true);
  299|       |        do_callback_decode(data, size, true);
  300|       |    }
  301|       |#endif
  302|       |
  303|       |#ifdef FUZZTEST_PROTO3_STATIC
  304|       |    if (do_decode(data, size, sizeof(alltypes_proto3_static_AllTypes), alltypes_proto3_static_AllTypes_fields, 0, expect_valid))
  305|       |    {
  306|       |        do_roundtrip(data, size, sizeof(alltypes_proto3_static_AllTypes), alltypes_proto3_static_AllTypes_fields);
  307|       |        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_proto3_static_AllTypes), alltypes_proto3_static_AllTypes_fields, true);
  308|       |    }
  309|       |#endif
  310|       |
  311|       |#ifdef FUZZTEST_PROTO2_POINTER
  312|       |    if (do_decode(data, size, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, 0, expect_valid))
  313|       |    {
  314|       |        do_roundtrip(data, size, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields);
  315|       |        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, true);
  316|       |    }
  317|       |#endif
  318|       |
  319|       |#ifdef FUZZTEST_PROTO3_POINTER
  320|       |    if (do_decode(data, size, sizeof(alltypes_proto3_pointer_AllTypes), alltypes_proto3_pointer_AllTypes_fields, 0, expect_valid))
  321|       |    {
  322|       |        do_roundtrip(data, size, sizeof(alltypes_proto3_pointer_AllTypes), alltypes_proto3_pointer_AllTypes_fields);
  323|       |        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_proto3_pointer_AllTypes), alltypes_proto3_pointer_AllTypes_fields, true);
  324|       |    }
  325|       |#endif
  326|       |
  327|  4.07k|#ifdef FUZZTEST_IO_ERRORS
  328|  4.07k|    {
  329|  4.07k|        size_t orig_max_alloc_bytes = get_max_alloc_bytes();
  330|       |        /* Test decoding when error conditions occur.
  331|       |         * The decoding will end either when running out of memory or when stream returns IO error.
  332|       |         * Testing proto2 is enough for good coverage here, as it has a superset of the field types of proto3.
  333|       |         */
  334|  4.07k|        set_max_alloc_bytes(get_alloc_bytes() + 4096);
  335|  4.07k|        do_stream_decode(data, size, size - 16, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, false);
  ------------------
  |  |  490|  4.07k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  336|  4.07k|        do_stream_decode(data, size, size - 16, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, false);
  ------------------
  |  |  465|  4.07k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  337|  4.07k|        set_max_alloc_bytes(orig_max_alloc_bytes);
  338|  4.07k|    }
  339|       |
  340|       |    /* Test pb_decode_ex() modes */
  341|  4.07k|    do_decode(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, PB_DECODE_NOINIT | PB_DECODE_DELIMITED, false);
  ------------------
  |  |  490|  4.07k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
                  do_decode(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, PB_DECODE_NOINIT | PB_DECODE_DELIMITED, false);
  ------------------
  |  |   99|  4.07k|#define PB_DECODE_NOINIT          0x01U
  ------------------
                  do_decode(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, PB_DECODE_NOINIT | PB_DECODE_DELIMITED, false);
  ------------------
  |  |  100|  4.07k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  342|  4.07k|    do_decode(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, PB_DECODE_NULLTERMINATED, false);
  ------------------
  |  |  490|  4.07k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
                  do_decode(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, PB_DECODE_NULLTERMINATED, false);
  ------------------
  |  |  101|  4.07k|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  343|       |
  344|       |    /* Test callbacks also when message is not valid */
  345|  4.07k|    do_callback_decode(data, size, false);
  346|  4.07k|#endif
  347|       |
  348|  4.07k|    assert(get_alloc_count() == initial_alloc_count);
  349|  4.07k|}
LLVMFuzzerTestOneInput:
  353|  4.07k|{
  354|  4.07k|    if (size > g_bufsize)
  ------------------
  |  Branch (354:9): [True: 4, False: 4.07k]
  ------------------
  355|      4|        return 0;
  356|       |
  357|  4.07k|    do_roundtrips(data, size, false);
  358|       |
  359|  4.07k|    return 0;
  360|  4.07k|}
fuzztest.c:field_callback:
  145|  2.03k|{
  146|  2.03k|    assert(stream);
  147|  2.03k|    assert(field);
  148|  2.03k|    assert(*arg == &g_sentinel);
  149|  2.03k|    return pb_read(stream, NULL, stream->bytes_left);
  150|  2.03k|}
fuzztest.c:submsg_callback:
  153|  70.7k|{
  154|  70.7k|    assert(stream);
  155|  70.7k|    assert(field);
  156|  70.7k|    assert(*arg == &g_sentinel);
  157|  70.7k|    return true;
  158|  70.7k|}
fuzztest.c:do_stream_decode:
  113|  8.14k|{
  114|  8.14k|    bool status;
  115|  8.14k|    flakystream_t stream;
  116|  8.14k|    size_t initial_alloc_count = get_alloc_count();
  117|  8.14k|    void *msg = malloc_with_check(structsize);
  118|  8.14k|    assert(msg);
  119|       |
  120|  8.14k|    memset(msg, 0, structsize);
  121|  8.14k|    flakystream_init(&stream, buffer, msglen, fail_after);
  122|  8.14k|    status = pb_decode(&stream.stream, msgtype, msg);
  123|       |
  124|  8.14k|    if (status)
  ------------------
  |  Branch (124:9): [True: 0, False: 8.14k]
  ------------------
  125|      0|    {
  126|      0|        validate_message(msg, structsize, msgtype);
  127|      0|    }
  128|       |
  129|  8.14k|    if (assert_success)
  ------------------
  |  Branch (129:9): [True: 0, False: 8.14k]
  ------------------
  130|      0|    {
  131|      0|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream.stream));
  ------------------
  |  |  886|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (886:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (131:13): [True: 0, False: 0]
  ------------------
  132|      0|        assert(status);
  133|      0|    }
  134|       |
  135|  8.14k|    pb_release(msgtype, msg);
  136|  8.14k|    free_with_check(msg);
  137|  8.14k|    assert(get_alloc_count() == initial_alloc_count);
  138|       |
  139|  8.14k|    return status;
  140|  8.14k|}
fuzztest.c:do_decode:
   66|  8.14k|{
   67|  8.14k|    bool status;
   68|  8.14k|    pb_istream_t stream;
   69|  8.14k|    size_t initial_alloc_count = get_alloc_count();
   70|  8.14k|    uint8_t *buf2 = malloc_with_check(g_bufsize); /* This is just to match the amount of memory allocations in do_roundtrips(). */
   71|  8.14k|    void *msg = malloc_with_check(structsize);
   72|  8.14k|    alltypes_static_TestExtension extmsg = alltypes_static_TestExtension_init_zero;
  ------------------
  |  |  248|  8.14k|#define alltypes_static_TestExtension_init_zero  {false, ""}
  ------------------
   73|  8.14k|    pb_extension_t ext = pb_extension_init_zero;
  ------------------
  |  |  472|  8.14k|#define pb_extension_init_zero {NULL,NULL,NULL,false}
  ------------------
   74|  8.14k|    assert(msg);
   75|       |
   76|  8.14k|    memset(msg, 0, structsize);
   77|  8.14k|    ext.type = &alltypes_static_TestExtension_testextension;
   78|  8.14k|    ext.dest = &extmsg;
   79|  8.14k|    ext.next = NULL;
   80|       |
   81|  8.14k|    if (msgtype == alltypes_static_AllTypes_fields)
  ------------------
  |  |  490|  8.14k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (81:9): [True: 8.14k, False: 0]
  ------------------
   82|  8.14k|    {
   83|  8.14k|        ((alltypes_static_AllTypes*)msg)->extensions = &ext;
   84|  8.14k|    }
   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|  8.14k|    stream = pb_istream_from_buffer(buffer, msglen);
   91|  8.14k|    status = pb_decode_ex(&stream, msgtype, msg, flags);
   92|       |
   93|  8.14k|    if (status)
  ------------------
  |  Branch (93:9): [True: 84, False: 8.06k]
  ------------------
   94|     84|    {
   95|     84|        validate_message(msg, structsize, msgtype);
   96|     84|    }
   97|       |
   98|  8.14k|    if (assert_success)
  ------------------
  |  Branch (98:9): [True: 0, False: 8.14k]
  ------------------
   99|      0|    {
  100|      0|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  886|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (886:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (100:13): [True: 0, False: 0]
  ------------------
  101|      0|        assert(status);
  102|      0|    }
  103|       |
  104|  8.14k|    pb_release(msgtype, msg);
  105|  8.14k|    free_with_check(msg);
  106|  8.14k|    free_with_check(buf2);
  107|  8.14k|    assert(get_alloc_count() == initial_alloc_count);
  108|       |    
  109|  8.14k|    return status;
  110|  8.14k|}

validate_static:
    7|  8.14k|{
    8|  8.14k|    pb_size_t count = 1;
    9|  8.14k|    pb_size_t i;
   10|  8.14k|    bool truebool = true;
   11|  8.14k|    bool falsebool = false;
   12|       |
   13|  8.14k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  287|  8.14k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|  8.14k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  274|  16.2k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 1.76k, False: 6.38k]
  |  Branch (13:54): [True: 1.76k, False: 0]
  ------------------
   14|  1.76k|    {
   15|       |        /* Array count must be between 0 and statically allocated size */
   16|  1.76k|        count = *(pb_size_t*)iter->pSize;
   17|  1.76k|        assert(count <= iter->array_size);
   18|  1.76k|    }
   19|  6.38k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  287|  6.38k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|  6.38k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  272|  12.7k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 1.98k, False: 4.39k]
  |  Branch (19:59): [True: 1.98k, False: 0]
  ------------------
   20|  1.98k|    {
   21|       |        /* Boolean has_ field must have a valid value */
   22|  1.98k|        assert(memcmp(iter->pSize, &truebool, sizeof(bool)) == 0 ||
   23|  1.98k|               memcmp(iter->pSize, &falsebool, sizeof(bool)) == 0);
   24|  1.98k|    }
   25|  4.39k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|  4.39k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  277|  4.39k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  276|  4.39k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 252, False: 4.14k]
  ------------------
   26|    252|    {
   27|    252|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 214, False: 38]
  ------------------
   28|    214|        {
   29|       |            /* Some different field in oneof */
   30|    214|            return;
   31|    214|        }
   32|    252|    }
   33|       |
   34|  16.1k|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 8.24k, False: 7.93k]
  ------------------
   35|  8.24k|    {
   36|  8.24k|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|  8.24k|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  288|  8.24k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|  8.24k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  244|  8.24k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 520, False: 7.72k]
  ------------------
   39|    520|        {
   40|       |            /* String length must be at most statically allocated size */
   41|    520|            assert(strlen(pData) + 1 <= iter->data_size);
   42|    520|        }
   43|  7.72k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  288|  7.72k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|  7.72k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  240|  7.72k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 203, False: 7.52k]
  ------------------
   44|    203|        {
   45|       |            /* Bytes length must be at most statically allocated size */
   46|    203|            pb_bytes_array_t *bytes = pData;
   47|    203|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= iter->data_size);
   48|    203|        }
   49|  7.52k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  288|  7.52k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  267|  7.52k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  228|  7.52k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 328, False: 7.19k]
  ------------------
   50|    328|        {
   51|       |            /* Bool fields must have valid value */
   52|    328|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
   53|    328|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
   54|    328|        }
   55|  7.19k|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  289|  7.19k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  288|  7.19k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|  7.19k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  248|  14.3k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (289:32): [True: 857, False: 6.34k]
  |  |  ------------------
  |  |  290|  7.19k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  288|  6.34k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  267|  6.34k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  253|  6.34k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (290:32): [True: 0, False: 6.34k]
  |  |  ------------------
  ------------------
   56|    857|        {
   57|    857|            validate_message(pData, 0, iter->submsg_desc);
   58|    857|        }
   59|  8.24k|    }
   60|  7.93k|}
validate_message:
  145|    941|{
  146|    941|    pb_field_iter_t iter;
  147|       |
  148|    941|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 644, False: 297]
  ------------------
  149|    644|    {
  150|    644|        do
  151|  8.23k|        {
  152|  8.23k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  286|  8.23k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|  8.23k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  281|  8.23k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 8.14k, False: 84]
  ------------------
  153|  8.14k|            {
  154|  8.14k|                validate_static(&iter);
  155|  8.14k|            }
  156|     84|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  286|     84|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  284|     84|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  282|     84|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 0, False: 84]
  ------------------
  157|      0|            {
  158|      0|                validate_pointer(&iter);
  159|      0|            }
  160|  8.23k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 7.58k, False: 644]
  ------------------
  161|    644|    }
  162|    941|}

