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

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

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

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

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

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

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

