pb_field_iter_begin:
  157|   508k|{
  158|   508k|    memset(iter, 0, sizeof(*iter));
  159|       |
  160|   508k|    iter->descriptor = desc;
  161|   508k|    iter->message = message;
  162|       |
  163|   508k|    return load_descriptor_values(iter);
  164|   508k|}
pb_field_iter_begin_extension:
  167|  24.6k|{
  168|  24.6k|    const pb_msgdesc_t *msg = (const pb_msgdesc_t*)extension->type->arg;
  169|  24.6k|    bool status;
  170|       |
  171|  24.6k|    uint32_t word0 = PB_PROGMEM_READU32(msg->field_info[0]);
  ------------------
  |  |  155|  24.6k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  172|  24.6k|    if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  297|  24.6k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  24.6k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  293|  24.6k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (172:9): [True: 0, False: 24.6k]
  ------------------
  173|      0|    {
  174|       |        /* For pointer extensions, the pointer is stored directly
  175|       |         * in the extension structure. This avoids having an extra
  176|       |         * indirection. */
  177|      0|        status = pb_field_iter_begin(iter, msg, &extension->dest);
  178|      0|    }
  179|  24.6k|    else
  180|  24.6k|    {
  181|  24.6k|        status = pb_field_iter_begin(iter, msg, extension->dest);
  182|  24.6k|    }
  183|       |
  184|  24.6k|    iter->pSize = &extension->found;
  185|  24.6k|    return status;
  186|  24.6k|}
pb_field_iter_next:
  189|  4.79M|{
  190|  4.79M|    advance_iterator(iter);
  191|  4.79M|    (void)load_descriptor_values(iter);
  192|  4.79M|    return iter->index != 0;
  193|  4.79M|}
pb_field_iter_find:
  196|  1.11M|{
  197|  1.11M|    if (iter->tag == tag)
  ------------------
  |  Branch (197:9): [True: 725k, False: 384k]
  ------------------
  198|   725k|    {
  199|   725k|        return true; /* Nothing to do, correct field already. */
  200|   725k|    }
  201|   384k|    else if (tag > iter->descriptor->largest_tag)
  ------------------
  |  Branch (201:14): [True: 38.3k, False: 346k]
  ------------------
  202|  38.3k|    {
  203|  38.3k|        return false;
  204|  38.3k|    }
  205|   346k|    else
  206|   346k|    {
  207|   346k|        pb_size_t start = iter->index;
  208|   346k|        uint32_t fieldinfo;
  209|       |
  210|   346k|        if (tag < iter->tag)
  ------------------
  |  Branch (210:13): [True: 97.1k, False: 249k]
  ------------------
  211|  97.1k|        {
  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|  97.1k|            iter->index = iter->descriptor->field_count;
  216|  97.1k|        }
  217|       |
  218|   346k|        do
  219|  7.38M|        {
  220|       |            /* Advance iterator but don't load values yet */
  221|  7.38M|            advance_iterator(iter);
  222|       |
  223|       |            /* Do fast check for tag number match */
  224|  7.38M|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  155|  7.38M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  225|       |
  226|  7.38M|            if (((fieldinfo >> 2) & 0x3F) == (tag & 0x3F))
  ------------------
  |  Branch (226:17): [True: 354k, False: 7.02M]
  ------------------
  227|   354k|            {
  228|       |                /* Good candidate, check further */
  229|   354k|                (void)load_descriptor_values(iter);
  230|       |
  231|   354k|                if (iter->tag == tag &&
  ------------------
  |  Branch (231:21): [True: 304k, False: 49.4k]
  ------------------
  232|   354k|                    PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  299|   304k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   304k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                                  PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  268|   304k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (232:21): [True: 304k, False: 267]
  ------------------
  233|   304k|                {
  234|       |                    /* Found it */
  235|   304k|                    return true;
  236|   304k|                }
  237|   354k|            }
  238|  7.38M|        } while (iter->index != start);
  ------------------
  |  Branch (238:18): [True: 7.03M, False: 42.1k]
  ------------------
  239|       |
  240|       |        /* Searched all the way back to start, and found nothing. */
  241|  42.1k|        (void)load_descriptor_values(iter);
  242|  42.1k|        return false;
  243|   346k|    }
  244|  1.11M|}
pb_field_iter_find_extension:
  247|  6.59k|{
  248|  6.59k|    if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  299|  6.59k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  6.59k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  268|  6.59k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (248:9): [True: 0, False: 6.59k]
  ------------------
  249|      0|    {
  250|      0|        return true;
  251|      0|    }
  252|  6.59k|    else
  253|  6.59k|    {
  254|  6.59k|        pb_size_t start = iter->index;
  255|  6.59k|        uint32_t fieldinfo;
  256|       |
  257|  6.59k|        do
  258|   210k|        {
  259|       |            /* Advance iterator but don't load values yet */
  260|   210k|            advance_iterator(iter);
  261|       |
  262|       |            /* Do fast check for field type */
  263|   210k|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  155|   210k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  264|       |
  265|   210k|            if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  299|   210k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   210k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  268|   210k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (265:17): [True: 3.50k, False: 206k]
  ------------------
  266|  3.50k|            {
  267|  3.50k|                return load_descriptor_values(iter);
  268|  3.50k|            }
  269|   210k|        } while (iter->index != start);
  ------------------
  |  Branch (269:18): [True: 203k, False: 3.08k]
  ------------------
  270|       |
  271|       |        /* Searched all the way back to start, and found nothing. */
  272|  3.08k|        (void)load_descriptor_values(iter);
  273|  3.08k|        return false;
  274|  6.59k|    }
  275|  6.59k|}
pb_field_iter_begin_const:
  291|    912|{
  292|    912|    return pb_field_iter_begin(iter, desc, pb_const_cast(message));
  293|    912|}
pb_default_field_callback:
  301|  70.9k|{
  302|  70.9k|    if (field->data_size == sizeof(pb_callback_t))
  ------------------
  |  Branch (302:9): [True: 70.9k, False: 0]
  ------------------
  303|  70.9k|    {
  304|  70.9k|        pb_callback_t *pCallback = (pb_callback_t*)field->pData;
  305|       |
  306|  70.9k|        if (pCallback != NULL)
  ------------------
  |  Branch (306:13): [True: 70.9k, False: 0]
  ------------------
  307|  70.9k|        {
  308|  70.9k|            if (istream != NULL && pCallback->funcs.decode != NULL)
  ------------------
  |  Branch (308:17): [True: 70.9k, False: 0]
  |  Branch (308:36): [True: 1.70k, False: 69.2k]
  ------------------
  309|  1.70k|            {
  310|  1.70k|                return pCallback->funcs.decode(istream, field, &pCallback->arg);
  311|  1.70k|            }
  312|       |
  313|  69.2k|            if (ostream != NULL && pCallback->funcs.encode != NULL)
  ------------------
  |  Branch (313:17): [True: 0, False: 69.2k]
  |  Branch (313:36): [True: 0, False: 0]
  ------------------
  314|      0|            {
  315|      0|                return pCallback->funcs.encode(ostream, field, &pCallback->arg);
  316|      0|            }
  317|  69.2k|        }
  318|  70.9k|    }
  319|       |
  320|  69.2k|    return true; /* Success, but didn't do anything */
  321|       |
  322|  70.9k|}
pb_common.c:load_descriptor_values:
    9|  5.71M|{
   10|  5.71M|    uint32_t word0;
   11|  5.71M|    uint32_t data_offset;
   12|  5.71M|    int_least8_t size_offset;
   13|       |
   14|  5.71M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (14:9): [True: 124k, False: 5.58M]
  ------------------
   15|   124k|        return false;
   16|       |
   17|  5.58M|    word0 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  155|  5.58M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   18|  5.58M|    iter->type = (pb_type_t)((word0 >> 8) & 0xFF);
   19|       |
   20|  5.58M|    switch(word0 & 3)
   21|  5.58M|    {
   22|   586k|        case 0: {
  ------------------
  |  Branch (22:9): [True: 586k, False: 4.99M]
  ------------------
   23|       |            /* 1-word format */
   24|   586k|            iter->array_size = 1;
   25|   586k|            iter->tag = (pb_size_t)((word0 >> 2) & 0x3F);
   26|   586k|            size_offset = (int_least8_t)((word0 >> 24) & 0x0F);
   27|   586k|            data_offset = (word0 >> 16) & 0xFF;
   28|   586k|            iter->data_size = (pb_size_t)((word0 >> 28) & 0x0F);
   29|   586k|            break;
   30|      0|        }
   31|       |
   32|  4.38M|        case 1: {
  ------------------
  |  Branch (32:9): [True: 4.38M, False: 1.20M]
  ------------------
   33|       |            /* 2-word format */
   34|  4.38M|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  155|  4.38M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   35|       |
   36|  4.38M|            iter->array_size = (pb_size_t)((word0 >> 16) & 0x0FFF);
   37|  4.38M|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 28) << 6));
   38|  4.38M|            size_offset = (int_least8_t)((word0 >> 28) & 0x0F);
   39|  4.38M|            data_offset = word1 & 0xFFFF;
   40|  4.38M|            iter->data_size = (pb_size_t)((word1 >> 16) & 0x0FFF);
   41|  4.38M|            break;
   42|      0|        }
   43|       |
   44|   520k|        case 2: {
  ------------------
  |  Branch (44:9): [True: 520k, False: 5.06M]
  ------------------
   45|       |            /* 4-word format */
   46|   520k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  155|   520k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   47|   520k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  155|   520k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   48|   520k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  155|   520k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   49|       |
   50|   520k|            iter->array_size = (pb_size_t)(word0 >> 16);
   51|   520k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   52|   520k|            size_offset = (int_least8_t)(word1 & 0xFF);
   53|   520k|            data_offset = word2;
   54|   520k|            iter->data_size = (pb_size_t)word3;
   55|   520k|            break;
   56|      0|        }
   57|       |
   58|  95.0k|        default: {
  ------------------
  |  Branch (58:9): [True: 95.0k, False: 5.49M]
  ------------------
   59|       |            /* 8-word format */
   60|  95.0k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  155|  95.0k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   61|  95.0k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  155|  95.0k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   62|  95.0k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  155|  95.0k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   63|  95.0k|            uint32_t word4 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 4]);
  ------------------
  |  |  155|  95.0k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   64|       |
   65|  95.0k|            iter->array_size = (pb_size_t)word4;
   66|  95.0k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   67|  95.0k|            size_offset = (int_least8_t)(word1 & 0xFF);
   68|  95.0k|            data_offset = word2;
   69|  95.0k|            iter->data_size = (pb_size_t)word3;
   70|  95.0k|            break;
   71|      0|        }
   72|  5.58M|    }
   73|       |
   74|  5.58M|    if (!iter->message)
  ------------------
  |  Branch (74:9): [True: 0, False: 5.58M]
  ------------------
   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|  5.58M|    else
   81|  5.58M|    {
   82|  5.58M|        iter->pField = (char*)iter->message + data_offset;
   83|       |
   84|  5.58M|        if (size_offset)
  ------------------
  |  Branch (84:13): [True: 2.01M, False: 3.57M]
  ------------------
   85|  2.01M|        {
   86|  2.01M|            iter->pSize = (char*)iter->pField - size_offset;
   87|  2.01M|        }
   88|  3.57M|        else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  298|  3.57M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  3.57M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  285|  7.14M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (88:18): [True: 358k, False: 3.21M]
  ------------------
   89|  3.57M|                 (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  297|   358k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|   358k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                               (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  292|   716k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (89:19): [True: 64.7k, False: 293k]
  ------------------
   90|   358k|                  PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  297|   293k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|   293k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                                PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  293|   293k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (90:19): [True: 28.5k, False: 264k]
  ------------------
   91|  93.3k|        {
   92|       |            /* Fixed count array */
   93|  93.3k|            iter->pSize = &iter->array_size;
   94|  93.3k|        }
   95|  3.47M|        else
   96|  3.47M|        {
   97|  3.47M|            iter->pSize = NULL;
   98|  3.47M|        }
   99|       |
  100|  5.58M|        if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  297|  5.58M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  5.58M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  293|  11.1M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (100:13): [True: 1.08M, False: 4.50M]
  |  Branch (100:57): [True: 1.08M, False: 0]
  ------------------
  101|  1.08M|        {
  102|  1.08M|            iter->pData = *(void**)iter->pField;
  103|  1.08M|        }
  104|  4.50M|        else
  105|  4.50M|        {
  106|  4.50M|            iter->pData = iter->pField;
  107|  4.50M|        }
  108|  5.58M|    }
  109|       |
  110|  5.58M|    if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  300|  5.58M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|  5.58M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  5.58M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|  11.1M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 721k, False: 4.86M]
  |  |  ------------------
  |  |  301|  5.58M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|  4.86M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  4.86M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|  4.86M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 66.9k, False: 4.79M]
  |  |  ------------------
  ------------------
  111|   788k|    {
  112|   788k|        iter->submsg_desc = iter->descriptor->submsg_info[iter->submessage_index];
  113|   788k|    }
  114|  4.79M|    else
  115|  4.79M|    {
  116|  4.79M|        iter->submsg_desc = NULL;
  117|  4.79M|    }
  118|       |
  119|  5.58M|    return true;
  120|  5.58M|}
pb_common.c:advance_iterator:
  123|  12.3M|{
  124|  12.3M|    iter->index++;
  125|       |
  126|  12.3M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (126:9): [True: 474k, False: 11.9M]
  ------------------
  127|   474k|    {
  128|       |        /* Restart */
  129|   474k|        iter->index = 0;
  130|   474k|        iter->field_info_index = 0;
  131|   474k|        iter->submessage_index = 0;
  132|   474k|        iter->required_field_index = 0;
  133|   474k|    }
  134|  11.9M|    else
  135|  11.9M|    {
  136|       |        /* Increment indexes based on previous field type.
  137|       |         * All field info formats have the following fields:
  138|       |         * - lowest 2 bits tell the amount of words in the descriptor (2^n words)
  139|       |         * - bits 2..7 give the lowest bits of tag number.
  140|       |         * - bits 8..15 give the field type.
  141|       |         */
  142|  11.9M|        uint32_t prev_descriptor = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  155|  11.9M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  143|  11.9M|        pb_type_t prev_type = (prev_descriptor >> 8) & 0xFF;
  144|  11.9M|        pb_size_t descriptor_len = (pb_size_t)(1 << (prev_descriptor & 3));
  145|       |
  146|       |        /* Add to fields.
  147|       |         * The cast to pb_size_t is needed to avoid -Wconversion warning.
  148|       |         * Because the data is is constants from generator, there is no danger of overflow.
  149|       |         */
  150|  11.9M|        iter->field_info_index = (pb_size_t)(iter->field_info_index + descriptor_len);
  151|  11.9M|        iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  298|  11.9M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  11.9M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  282|  11.9M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  152|  11.9M|        iter->submessage_index = (pb_size_t)(iter->submessage_index + PB_LTYPE_IS_SUBMSG(prev_type));
  ------------------
  |  |  300|  11.9M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|  11.9M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  11.9M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|  23.8M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 1.57M, False: 10.3M]
  |  |  ------------------
  |  |  301|  11.9M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|  10.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  10.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|  10.3M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 89.0k, False: 10.2M]
  |  |  ------------------
  ------------------
  153|  11.9M|    }
  154|  12.3M|}
pb_common.c:pb_const_cast:
  278|    912|{
  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|    912|    union {
  283|    912|        void *p1;
  284|    912|        const void *p2;
  285|    912|    } t;
  286|    912|    t.p2 = p;
  287|    912|    return t.p1;
  288|    912|}

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

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

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

do_callback_decode:
  161|  3.98k|{
  162|  3.98k|    bool status;
  163|  3.98k|    pb_istream_t stream;
  164|  3.98k|    size_t initial_alloc_count = get_alloc_count();
  165|  3.98k|    alltypes_callback_AllTypes *msg = malloc_with_check(sizeof(alltypes_callback_AllTypes));
  166|  3.98k|    assert(msg);
  167|       |
  168|  3.98k|    memset(msg, 0, sizeof(alltypes_callback_AllTypes));
  169|  3.98k|    stream = pb_istream_from_buffer(buffer, msglen);
  170|       |
  171|  3.98k|    msg->rep_int32.funcs.decode = &field_callback;
  172|  3.98k|    msg->rep_int32.arg = &g_sentinel;
  173|  3.98k|    msg->rep_string.funcs.decode = &field_callback;
  174|  3.98k|    msg->rep_string.arg = &g_sentinel;
  175|  3.98k|    msg->rep_farray.funcs.decode = &field_callback;
  176|  3.98k|    msg->rep_farray.arg = &g_sentinel;
  177|  3.98k|    msg->req_limits.int64_min.funcs.decode = &field_callback;
  178|  3.98k|    msg->req_limits.int64_min.arg = &g_sentinel;
  179|  3.98k|    msg->cb_oneof.funcs.decode = &submsg_callback;
  180|  3.98k|    msg->cb_oneof.arg = &g_sentinel;
  181|       |
  182|  3.98k|    status = pb_decode(&stream, alltypes_callback_AllTypes_fields, msg);
  ------------------
  |  |  465|  3.98k|#define alltypes_callback_AllTypes_fields &alltypes_callback_AllTypes_msg
  ------------------
  183|       |
  184|  3.98k|    if (assert_success)
  ------------------
  |  Branch (184:9): [True: 0, False: 3.98k]
  ------------------
  185|      0|    {
  186|      0|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  891|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (891:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (186:13): [True: 0, False: 0]
  ------------------
  187|      0|        assert(status);
  188|      0|    }
  189|       |
  190|  3.98k|    pb_release(alltypes_callback_AllTypes_fields, msg);
  ------------------
  |  |  465|  3.98k|#define alltypes_callback_AllTypes_fields &alltypes_callback_AllTypes_msg
  ------------------
  191|  3.98k|    free_with_check(msg);
  192|  3.98k|    assert(get_alloc_count() == initial_alloc_count);
  193|       |
  194|  3.98k|    return status;
  195|  3.98k|}
do_roundtrips:
  290|  3.98k|{
  291|  3.98k|    size_t initial_alloc_count = get_alloc_count();
  292|  3.98k|    PB_UNUSED(expect_valid); /* Potentially unused depending on configuration */
  ------------------
  |  |  143|  3.98k|#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|  3.98k|#ifdef FUZZTEST_IO_ERRORS
  328|  3.98k|    {
  329|  3.98k|        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|  3.98k|        set_max_alloc_bytes(get_alloc_bytes() + 4096);
  335|  3.98k|        do_stream_decode(data, size, size - 16, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, false);
  ------------------
  |  |  490|  3.98k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  336|  3.98k|        do_stream_decode(data, size, size - 16, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, false);
  ------------------
  |  |  465|  3.98k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  337|  3.98k|        set_max_alloc_bytes(orig_max_alloc_bytes);
  338|  3.98k|    }
  339|       |
  340|       |    /* Test pb_decode_ex() modes */
  341|  3.98k|    do_decode(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, PB_DECODE_NOINIT | PB_DECODE_DELIMITED, false);
  ------------------
  |  |  490|  3.98k|#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|  3.98k|#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|  3.98k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  342|  3.98k|    do_decode(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, PB_DECODE_NULLTERMINATED, false);
  ------------------
  |  |  490|  3.98k|#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|  3.98k|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  343|       |
  344|       |    /* Test callbacks also when message is not valid */
  345|  3.98k|    do_callback_decode(data, size, false);
  346|  3.98k|#endif
  347|       |
  348|  3.98k|    assert(get_alloc_count() == initial_alloc_count);
  349|  3.98k|}
LLVMFuzzerTestOneInput:
  353|  3.98k|{
  354|  3.98k|    if (size > g_bufsize)
  ------------------
  |  Branch (354:9): [True: 4, False: 3.98k]
  ------------------
  355|      4|        return 0;
  356|       |
  357|  3.98k|    do_roundtrips(data, size, false);
  358|       |
  359|  3.98k|    return 0;
  360|  3.98k|}
fuzztest.c:field_callback:
  145|  1.70k|{
  146|  1.70k|    assert(stream);
  147|  1.70k|    assert(field);
  148|  1.70k|    assert(*arg == &g_sentinel);
  149|  1.70k|    return pb_read(stream, NULL, stream->bytes_left);
  150|  1.70k|}
fuzztest.c:submsg_callback:
  153|  26.6k|{
  154|  26.6k|    assert(stream);
  155|  26.6k|    assert(field);
  156|  26.6k|    assert(*arg == &g_sentinel);
  157|  26.6k|    return true;
  158|  26.6k|}
fuzztest.c:do_stream_decode:
  113|  7.96k|{
  114|  7.96k|    bool status;
  115|  7.96k|    flakystream_t stream;
  116|  7.96k|    size_t initial_alloc_count = get_alloc_count();
  117|  7.96k|    void *msg = malloc_with_check(structsize);
  118|  7.96k|    assert(msg);
  119|       |
  120|  7.96k|    memset(msg, 0, structsize);
  121|  7.96k|    flakystream_init(&stream, buffer, msglen, fail_after);
  122|  7.96k|    status = pb_decode(&stream.stream, msgtype, msg);
  123|       |
  124|  7.96k|    if (status)
  ------------------
  |  Branch (124:9): [True: 0, False: 7.96k]
  ------------------
  125|      0|    {
  126|      0|        validate_message(msg, structsize, msgtype);
  127|      0|    }
  128|       |
  129|  7.96k|    if (assert_success)
  ------------------
  |  Branch (129:9): [True: 0, False: 7.96k]
  ------------------
  130|      0|    {
  131|      0|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream.stream));
  ------------------
  |  |  891|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (891:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (131:13): [True: 0, False: 0]
  ------------------
  132|      0|        assert(status);
  133|      0|    }
  134|       |
  135|  7.96k|    pb_release(msgtype, msg);
  136|  7.96k|    free_with_check(msg);
  137|  7.96k|    assert(get_alloc_count() == initial_alloc_count);
  138|       |
  139|  7.96k|    return status;
  140|  7.96k|}
fuzztest.c:do_decode:
   66|  7.96k|{
   67|  7.96k|    bool status;
   68|  7.96k|    pb_istream_t stream;
   69|  7.96k|    size_t initial_alloc_count = get_alloc_count();
   70|  7.96k|    uint8_t *buf2 = malloc_with_check(g_bufsize); /* This is just to match the amount of memory allocations in do_roundtrips(). */
   71|  7.96k|    void *msg = malloc_with_check(structsize);
   72|  7.96k|    alltypes_static_TestExtension extmsg = alltypes_static_TestExtension_init_zero;
  ------------------
  |  |  248|  7.96k|#define alltypes_static_TestExtension_init_zero  {false, ""}
  ------------------
   73|  7.96k|    pb_extension_t ext = pb_extension_init_zero;
  ------------------
  |  |  477|  7.96k|#define pb_extension_init_zero {NULL,NULL,NULL,false}
  ------------------
   74|  7.96k|    assert(msg);
   75|       |
   76|  7.96k|    memset(msg, 0, structsize);
   77|  7.96k|    ext.type = &alltypes_static_TestExtension_testextension;
   78|  7.96k|    ext.dest = &extmsg;
   79|  7.96k|    ext.next = NULL;
   80|       |
   81|  7.96k|    if (msgtype == alltypes_static_AllTypes_fields)
  ------------------
  |  |  490|  7.96k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (81:9): [True: 7.96k, False: 0]
  ------------------
   82|  7.96k|    {
   83|  7.96k|        ((alltypes_static_AllTypes*)msg)->extensions = &ext;
   84|  7.96k|    }
   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|  7.96k|    stream = pb_istream_from_buffer(buffer, msglen);
   91|  7.96k|    status = pb_decode_ex(&stream, msgtype, msg, flags);
   92|       |
   93|  7.96k|    if (status)
  ------------------
  |  Branch (93:9): [True: 85, False: 7.87k]
  ------------------
   94|     85|    {
   95|     85|        validate_message(msg, structsize, msgtype);
   96|     85|    }
   97|       |
   98|  7.96k|    if (assert_success)
  ------------------
  |  Branch (98:9): [True: 0, False: 7.96k]
  ------------------
   99|      0|    {
  100|      0|        if (!status) fprintf(stderr, "pb_decode: %s\n", PB_GET_ERROR(&stream));
  ------------------
  |  |  891|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (891:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (100:13): [True: 0, False: 0]
  ------------------
  101|      0|        assert(status);
  102|      0|    }
  103|       |
  104|  7.96k|    pb_release(msgtype, msg);
  105|  7.96k|    free_with_check(msg);
  106|  7.96k|    free_with_check(buf2);
  107|  7.96k|    assert(get_alloc_count() == initial_alloc_count);
  108|       |    
  109|  7.96k|    return status;
  110|  7.96k|}

validate_static:
    7|  8.24k|{
    8|  8.24k|    pb_size_t count = 1;
    9|  8.24k|    pb_size_t i;
   10|  8.24k|    bool truebool = true;
   11|  8.24k|    bool falsebool = false;
   12|       |
   13|  8.24k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  298|  8.24k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  8.24k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  285|  16.4k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 1.78k, False: 6.46k]
  |  Branch (13:54): [True: 1.78k, False: 0]
  ------------------
   14|  1.78k|    {
   15|       |        /* Array count must be between 0 and statically allocated size */
   16|  1.78k|        count = *(pb_size_t*)iter->pSize;
   17|  1.78k|        assert(count <= iter->array_size);
   18|  1.78k|    }
   19|  6.46k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  298|  6.46k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  6.46k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  283|  12.9k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 2.01k, False: 4.44k]
  |  Branch (19:59): [True: 2.01k, False: 0]
  ------------------
   20|  2.01k|    {
   21|       |        /* Boolean has_ field must have a valid value */
   22|  2.01k|        assert(memcmp(iter->pSize, &truebool, sizeof(bool)) == 0 ||
   23|  2.01k|               memcmp(iter->pSize, &falsebool, sizeof(bool)) == 0);
   24|  2.01k|    }
   25|  4.44k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  298|  4.44k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  4.44k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|  4.44k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 255, False: 4.19k]
  ------------------
   26|    255|    {
   27|    255|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 222, False: 33]
  ------------------
   28|    222|        {
   29|       |            /* Some different field in oneof */
   30|    222|            return;
   31|    222|        }
   32|    255|    }
   33|       |
   34|  16.2k|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 8.18k, False: 8.02k]
  ------------------
   35|  8.18k|    {
   36|  8.18k|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|  8.18k|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  299|  8.18k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  8.18k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  255|  8.18k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 526, False: 7.66k]
  ------------------
   39|    526|        {
   40|       |            /* String length must be at most statically allocated size */
   41|    526|            assert(strlen(pData) + 1 <= iter->data_size);
   42|    526|        }
   43|  7.66k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  299|  7.66k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  7.66k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  251|  7.66k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 202, False: 7.46k]
  ------------------
   44|    202|        {
   45|       |            /* Bytes length must be at most statically allocated size */
   46|    202|            pb_bytes_array_t *bytes = pData;
   47|    202|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= iter->data_size);
   48|    202|        }
   49|  7.46k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  299|  7.46k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  7.46k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  239|  7.46k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 291, False: 7.17k]
  ------------------
   50|    291|        {
   51|       |            /* Bool fields must have valid value */
   52|    291|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
   53|    291|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
   54|    291|        }
   55|  7.17k|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  300|  7.17k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|  7.17k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  7.17k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|  14.3k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 827, False: 6.34k]
  |  |  ------------------
  |  |  301|  7.17k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|  6.34k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  6.34k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|  6.34k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 0, False: 6.34k]
  |  |  ------------------
  ------------------
   56|    827|        {
   57|    827|            validate_message(pData, 0, iter->submsg_desc);
   58|    827|        }
   59|  8.18k|    }
   60|  8.02k|}
validate_message:
  145|    912|{
  146|    912|    pb_field_iter_t iter;
  147|       |
  148|    912|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 652, False: 260]
  ------------------
  149|    652|    {
  150|    652|        do
  151|  8.33k|        {
  152|  8.33k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  297|  8.33k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  8.33k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  292|  8.33k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 8.24k, False: 85]
  ------------------
  153|  8.24k|            {
  154|  8.24k|                validate_static(&iter);
  155|  8.24k|            }
  156|     85|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  297|     85|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|     85|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  293|     85|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 0, False: 85]
  ------------------
  157|      0|            {
  158|      0|                validate_pointer(&iter);
  159|      0|            }
  160|  8.33k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 7.67k, False: 652]
  ------------------
  161|    652|    }
  162|    912|}

