pb_field_iter_begin:
  157|   673k|{
  158|   673k|    memset(iter, 0, sizeof(*iter));
  159|       |
  160|   673k|    iter->descriptor = desc;
  161|   673k|    iter->message = message;
  162|       |
  163|   673k|    return load_descriptor_values(iter);
  164|   673k|}
pb_field_iter_begin_extension:
  167|  92.0k|{
  168|  92.0k|    const pb_msgdesc_t *msg = (const pb_msgdesc_t*)extension->type->arg;
  169|  92.0k|    bool status;
  170|       |
  171|  92.0k|    uint32_t word0 = PB_PROGMEM_READU32(msg->field_info[0]);
  ------------------
  |  |  181|  92.0k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  172|  92.0k|    if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|  92.0k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  92.0k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|  92.0k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (172:9): [True: 0, False: 92.0k]
  ------------------
  173|      0|    {
  174|       |        /* For pointer extensions, the pointer is stored directly
  175|       |         * in the extension structure. This avoids having an extra
  176|       |         * indirection. */
  177|      0|        status = pb_field_iter_begin(iter, msg, &extension->dest);
  178|      0|    }
  179|  92.0k|    else
  180|  92.0k|    {
  181|  92.0k|        status = pb_field_iter_begin(iter, msg, extension->dest);
  182|  92.0k|    }
  183|       |
  184|  92.0k|    iter->pSize = &extension->found;
  185|  92.0k|    return status;
  186|  92.0k|}
pb_field_iter_next:
  189|  2.98M|{
  190|  2.98M|    advance_iterator(iter);
  191|  2.98M|    (void)load_descriptor_values(iter);
  192|  2.98M|    return iter->index != 0;
  193|  2.98M|}
pb_field_iter_find:
  196|  29.9M|{
  197|  29.9M|    if (iter->tag == tag)
  ------------------
  |  Branch (197:9): [True: 28.6M, False: 1.26M]
  ------------------
  198|  28.6M|    {
  199|  28.6M|        return true; /* Nothing to do, correct field already. */
  200|  28.6M|    }
  201|  1.26M|    else if (tag > iter->descriptor->largest_tag)
  ------------------
  |  Branch (201:14): [True: 328k, False: 932k]
  ------------------
  202|   328k|    {
  203|   328k|        return false;
  204|   328k|    }
  205|   932k|    else
  206|   932k|    {
  207|   932k|        pb_size_t start = iter->index;
  208|   932k|        uint32_t fieldinfo;
  209|       |
  210|   932k|        if (tag < iter->tag)
  ------------------
  |  Branch (210:13): [True: 225k, False: 706k]
  ------------------
  211|   225k|        {
  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|   225k|            iter->index = iter->descriptor->field_count;
  216|   225k|        }
  217|       |
  218|   932k|        do
  219|  10.7M|        {
  220|       |            /* Advance iterator but don't load values yet */
  221|  10.7M|            advance_iterator(iter);
  222|       |
  223|       |            /* Do fast check for tag number match */
  224|  10.7M|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  181|  10.7M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  225|       |
  226|  10.7M|            if (((fieldinfo >> 2) & 0x3F) == (tag & 0x3F))
  ------------------
  |  Branch (226:17): [True: 959k, False: 9.80M]
  ------------------
  227|   959k|            {
  228|       |                /* Good candidate, check further */
  229|   959k|                (void)load_descriptor_values(iter);
  230|       |
  231|   959k|                if (iter->tag == tag &&
  ------------------
  |  Branch (231:21): [True: 858k, False: 100k]
  ------------------
  232|   858k|                    PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|   858k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   858k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                                  PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|   858k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (232:21): [True: 854k, False: 3.76k]
  ------------------
  233|   854k|                {
  234|       |                    /* Found it */
  235|   854k|                    return true;
  236|   854k|                }
  237|   959k|            }
  238|  10.7M|        } while (iter->index != start);
  ------------------
  |  Branch (238:18): [True: 9.83M, False: 77.3k]
  ------------------
  239|       |
  240|       |        /* Searched all the way back to start, and found nothing. */
  241|  77.3k|        (void)load_descriptor_values(iter);
  242|       |        return false;
  243|   932k|    }
  244|  29.9M|}
pb_field_iter_find_extension:
  247|  9.19k|{
  248|  9.19k|    if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|  9.19k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  9.19k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|  9.19k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (248:9): [True: 0, False: 9.19k]
  ------------------
  249|      0|    {
  250|      0|        return true;
  251|      0|    }
  252|  9.19k|    else
  253|  9.19k|    {
  254|  9.19k|        pb_size_t start = iter->index;
  255|  9.19k|        uint32_t fieldinfo;
  256|       |
  257|  9.19k|        do
  258|   126k|        {
  259|       |            /* Advance iterator but don't load values yet */
  260|   126k|            advance_iterator(iter);
  261|       |
  262|       |            /* Do fast check for field type */
  263|   126k|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  181|   126k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  264|       |
  265|   126k|            if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|   126k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   126k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|   126k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (265:17): [True: 3.84k, False: 122k]
  ------------------
  266|  3.84k|            {
  267|  3.84k|                return load_descriptor_values(iter);
  268|  3.84k|            }
  269|   126k|        } while (iter->index != start);
  ------------------
  |  Branch (269:18): [True: 117k, False: 5.34k]
  ------------------
  270|       |
  271|       |        /* Searched all the way back to start, and found nothing. */
  272|  5.34k|        (void)load_descriptor_values(iter);
  273|       |        return false;
  274|  9.19k|    }
  275|  9.19k|}
pb_field_iter_begin_const:
  291|   221k|{
  292|   221k|    return pb_field_iter_begin(iter, desc, pb_const_cast(message));
  293|   221k|}
pb_field_iter_begin_extension_const:
  296|  2.71k|{
  297|  2.71k|    return pb_field_iter_begin_extension(iter, (pb_extension_t*)pb_const_cast(extension));
  298|  2.71k|}
pb_common.c:load_descriptor_values:
    9|  4.70M|{
   10|  4.70M|    uint32_t word0;
   11|  4.70M|    uint32_t data_offset;
   12|  4.70M|    int_least8_t size_offset;
   13|       |
   14|  4.70M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (14:9): [True: 220k, False: 4.48M]
  ------------------
   15|   220k|        return false;
   16|       |
   17|  4.48M|    word0 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  181|  4.48M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   18|  4.48M|    iter->type = (pb_type_t)((word0 >> 8) & 0xFF);
   19|       |
   20|  4.48M|    switch(word0 & 3)
   21|  4.48M|    {
   22|   778k|        case 0: {
  ------------------
  |  Branch (22:9): [True: 778k, False: 3.70M]
  ------------------
   23|       |            /* 1-word format */
   24|   778k|            iter->array_size = 1;
   25|   778k|            iter->tag = (pb_size_t)((word0 >> 2) & 0x3F);
   26|   778k|            size_offset = (int_least8_t)((word0 >> 24) & 0x0F);
   27|   778k|            data_offset = (word0 >> 16) & 0xFF;
   28|   778k|            iter->data_size = (pb_size_t)((word0 >> 28) & 0x0F);
   29|   778k|            break;
   30|      0|        }
   31|       |
   32|  3.04M|        case 1: {
  ------------------
  |  Branch (32:9): [True: 3.04M, False: 1.43M]
  ------------------
   33|       |            /* 2-word format */
   34|  3.04M|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  181|  3.04M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   35|       |
   36|  3.04M|            iter->array_size = (pb_size_t)((word0 >> 16) & 0x0FFF);
   37|  3.04M|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 28) << 6));
   38|  3.04M|            size_offset = (int_least8_t)((word0 >> 28) & 0x0F);
   39|  3.04M|            data_offset = word1 & 0xFFFF;
   40|  3.04M|            iter->data_size = (pb_size_t)((word1 >> 16) & 0x0FFF);
   41|  3.04M|            break;
   42|      0|        }
   43|       |
   44|   489k|        case 2: {
  ------------------
  |  Branch (44:9): [True: 489k, False: 3.99M]
  ------------------
   45|       |            /* 4-word format */
   46|   489k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  181|   489k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   47|   489k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  181|   489k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   48|   489k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  181|   489k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   49|       |
   50|   489k|            iter->array_size = (pb_size_t)(word0 >> 16);
   51|   489k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   52|   489k|            size_offset = (int_least8_t)(word1 & 0xFF);
   53|   489k|            data_offset = word2;
   54|   489k|            iter->data_size = (pb_size_t)word3;
   55|   489k|            break;
   56|      0|        }
   57|       |
   58|   168k|        default: {
  ------------------
  |  Branch (58:9): [True: 168k, False: 4.31M]
  ------------------
   59|       |            /* 8-word format */
   60|   168k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  181|   168k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   61|   168k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  181|   168k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   62|   168k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  181|   168k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   63|   168k|            uint32_t word4 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 4]);
  ------------------
  |  |  181|   168k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   64|       |
   65|   168k|            iter->array_size = (pb_size_t)word4;
   66|   168k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   67|   168k|            size_offset = (int_least8_t)(word1 & 0xFF);
   68|   168k|            data_offset = word2;
   69|   168k|            iter->data_size = (pb_size_t)word3;
   70|   168k|            break;
   71|      0|        }
   72|  4.48M|    }
   73|       |
   74|  4.48M|    if (!iter->message)
  ------------------
  |  Branch (74:9): [True: 0, False: 4.48M]
  ------------------
   75|      0|    {
   76|       |        /* Avoid doing arithmetic on null pointers, it is undefined */
   77|      0|        iter->pField = NULL;
   78|      0|        iter->pSize = NULL;
   79|      0|    }
   80|  4.48M|    else
   81|  4.48M|    {
   82|  4.48M|        iter->pField = (char*)iter->message + data_offset;
   83|       |
   84|  4.48M|        if (size_offset)
  ------------------
  |  Branch (84:13): [True: 773k, False: 3.70M]
  ------------------
   85|   773k|        {
   86|   773k|            iter->pSize = (char*)iter->pField - size_offset;
   87|   773k|        }
   88|  3.70M|        else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  324|  3.70M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  3.70M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  311|  7.41M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (88:18): [True: 59.2k, False: 3.64M]
  ------------------
   89|  59.2k|                 (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  323|  59.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  59.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                               (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  318|   118k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (89:19): [True: 0, False: 59.2k]
  ------------------
   90|  59.2k|                  PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  323|  59.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  59.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                                PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  319|  59.2k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (90:19): [True: 59.2k, False: 0]
  ------------------
   91|  59.2k|        {
   92|       |            /* Fixed count array */
   93|  59.2k|            iter->pSize = &iter->array_size;
   94|  59.2k|        }
   95|  3.64M|        else
   96|  3.64M|        {
   97|  3.64M|            iter->pSize = NULL;
   98|  3.64M|        }
   99|       |
  100|  4.48M|        if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  323|  4.48M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  4.48M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  319|  8.96M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (100:13): [True: 4.27M, False: 206k]
  |  Branch (100:57): [True: 4.27M, False: 0]
  ------------------
  101|  4.27M|        {
  102|  4.27M|            iter->pData = *(void**)iter->pField;
  103|  4.27M|        }
  104|   206k|        else
  105|   206k|        {
  106|   206k|            iter->pData = iter->pField;
  107|   206k|        }
  108|  4.48M|    }
  109|       |
  110|  4.48M|    if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  326|  4.48M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|  4.48M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  4.48M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  8.96M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 532k, False: 3.94M]
  |  |  ------------------
  |  |  327|  4.48M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|  3.94M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  3.94M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|  3.94M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 3.94M]
  |  |  ------------------
  ------------------
  111|   532k|    {
  112|   532k|        iter->submsg_desc = iter->descriptor->submsg_info[iter->submessage_index];
  113|   532k|    }
  114|  3.94M|    else
  115|  3.94M|    {
  116|  3.94M|        iter->submsg_desc = NULL;
  117|  3.94M|    }
  118|       |
  119|       |    return true;
  120|  4.48M|}
pb_common.c:advance_iterator:
  123|  13.8M|{
  124|  13.8M|    iter->index++;
  125|       |
  126|  13.8M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (126:9): [True: 663k, False: 13.2M]
  ------------------
  127|   663k|    {
  128|       |        /* Restart */
  129|   663k|        iter->index = 0;
  130|   663k|        iter->field_info_index = 0;
  131|   663k|        iter->submessage_index = 0;
  132|   663k|        iter->required_field_index = 0;
  133|   663k|    }
  134|  13.2M|    else
  135|  13.2M|    {
  136|       |        /* Increment indexes based on previous field type.
  137|       |         * All field info formats have the following fields:
  138|       |         * - lowest 2 bits tell the amount of words in the descriptor (2^n words)
  139|       |         * - bits 2..7 give the lowest bits of tag number.
  140|       |         * - bits 8..15 give the field type.
  141|       |         */
  142|  13.2M|        uint32_t prev_descriptor = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  181|  13.2M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  143|  13.2M|        pb_type_t prev_type = (prev_descriptor >> 8) & 0xFF;
  144|  13.2M|        pb_size_t descriptor_len = (pb_size_t)(1 << (prev_descriptor & 3));
  145|       |
  146|       |        /* Add to fields.
  147|       |         * The cast to pb_size_t is needed to avoid -Wconversion warning.
  148|       |         * Because the data is is constants from generator, there is no danger of overflow.
  149|       |         */
  150|  13.2M|        iter->field_info_index = (pb_size_t)(iter->field_info_index + descriptor_len);
  151|  13.2M|        iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  324|  13.2M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  13.2M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  308|  13.2M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  152|  13.2M|        iter->submessage_index = (pb_size_t)(iter->submessage_index + PB_LTYPE_IS_SUBMSG(prev_type));
  ------------------
  |  |  326|  13.2M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|  13.2M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  13.2M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  26.4M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 1.75M, False: 11.4M]
  |  |  ------------------
  |  |  327|  13.2M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|  11.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  11.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|  11.4M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 11.4M]
  |  |  ------------------
  ------------------
  153|  13.2M|    }
  154|  13.8M|}
pb_common.c:pb_const_cast:
  278|   224k|{
  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|   224k|    union {
  283|   224k|        void *p1;
  284|   224k|        const void *p2;
  285|   224k|    } t;
  286|   224k|    t.p2 = p;
  287|   224k|    return t.p1;
  288|   224k|}

pb_read:
   82|  3.12M|{
   83|  3.12M|    if (count == 0)
  ------------------
  |  Branch (83:9): [True: 1.34M, False: 1.77M]
  ------------------
   84|  1.34M|        return true;
   85|       |
   86|  1.77M|#ifndef PB_BUFFER_ONLY
   87|  1.77M|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (87:6): [True: 101k, False: 1.66M]
  |  Branch (87:21): [True: 33.7k, False: 68.2k]
  ------------------
   88|  33.7k|	{
   89|       |		/* Skip input bytes */
   90|  33.7k|		pb_byte_t tmp[16];
   91|   199k|		while (count > 16)
  ------------------
  |  Branch (91:10): [True: 165k, False: 33.7k]
  ------------------
   92|   165k|		{
   93|   165k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (93:8): [True: 0, False: 165k]
  ------------------
   94|      0|				return false;
   95|       |			
   96|   165k|			count -= 16;
   97|   165k|		}
   98|       |		
   99|  33.7k|		return pb_read(stream, tmp, count);
  100|  33.7k|	}
  101|  1.73M|#endif
  102|       |
  103|  1.73M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (103:9): [True: 210, False: 1.73M]
  ------------------
  104|    210|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  920|    210|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|    210|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 210]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  105|       |    
  106|  1.73M|#ifndef PB_BUFFER_ONLY
  107|  1.73M|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:9): [True: 0, False: 1.73M]
  ------------------
  108|      0|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|       |#else
  110|       |    if (!buf_read(stream, buf, count))
  111|       |        return false;
  112|       |#endif
  113|       |    
  114|  1.73M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (114:9): [True: 0, False: 1.73M]
  ------------------
  115|      0|        stream->bytes_left = 0;
  116|  1.73M|    else
  117|  1.73M|        stream->bytes_left -= count;
  118|       |
  119|       |    return true;
  120|  1.73M|}
pb_istream_from_buffer:
  143|  6.48k|{
  144|  6.48k|    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|  6.48k|    union {
  149|  6.48k|        void *state;
  150|  6.48k|        const void *c_state;
  151|  6.48k|    } state;
  152|       |#ifdef PB_BUFFER_ONLY
  153|       |    stream.callback = NULL;
  154|       |#else
  155|  6.48k|    stream.callback = &buf_read;
  156|  6.48k|#endif
  157|  6.48k|    state.c_state = buf;
  158|  6.48k|    stream.state = state.state;
  159|  6.48k|    stream.bytes_left = msglen;
  160|  6.48k|#ifndef PB_NO_ERRMSG
  161|       |    stream.errmsg = NULL;
  162|  6.48k|#endif
  163|  6.48k|    return stream;
  164|  6.48k|}
pb_decode_varint32:
  172|  62.2M|{
  173|  62.2M|    pb_byte_t byte;
  174|  62.2M|    uint32_t result;
  175|       |    
  176|  62.2M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (176:9): [True: 1.74k, False: 62.2M]
  ------------------
  177|  1.74k|    {
  178|  1.74k|        return false;
  179|  1.74k|    }
  180|       |    
  181|  62.2M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (181:9): [True: 33.9M, False: 28.3M]
  ------------------
  182|  33.9M|    {
  183|       |        /* Quick case, 1 byte value */
  184|  33.9M|        result = byte;
  185|  33.9M|    }
  186|  28.3M|    else
  187|  28.3M|    {
  188|       |        /* Multibyte case */
  189|  28.3M|        uint_fast8_t bitpos = 7;
  190|  28.3M|        result = byte & 0x7F;
  191|       |        
  192|  28.3M|        do
  193|  28.4M|        {
  194|  28.4M|            if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (194:17): [True: 56, False: 28.4M]
  ------------------
  195|     56|                return false;
  196|       |            
  197|  28.4M|            if (bitpos >= 32)
  ------------------
  |  Branch (197:17): [True: 6.31k, False: 28.4M]
  ------------------
  198|  6.31k|            {
  199|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  200|  6.31k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (200:44): [True: 6.20k, False: 113]
  ------------------
  201|  6.31k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (201:41): [True: 3.06k, False: 3.25k]
  ------------------
  202|  3.25k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (202:27): [True: 3.23k, False: 15]
  |  Branch (202:50): [True: 3.17k, False: 64]
  ------------------
  203|       |
  204|  6.31k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (204:21): [True: 2, False: 6.31k]
  |  Branch (204:37): [True: 78, False: 6.23k]
  ------------------
  205|     80|                {
  206|     80|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  920|     80|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     80|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 80]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  207|     80|                }
  208|  6.31k|            }
  209|  28.4M|            else if (bitpos == 28)
  ------------------
  |  Branch (209:22): [True: 6.93k, False: 28.4M]
  ------------------
  210|  6.93k|            {
  211|  6.93k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (211:21): [True: 4.34k, False: 2.58k]
  |  Branch (211:43): [True: 23, False: 4.32k]
  ------------------
  212|     23|                {
  213|     23|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  920|     23|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     23|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 23]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  214|     23|                }
  215|  6.91k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  216|  6.91k|            }
  217|  28.4M|            else
  218|  28.4M|            {
  219|  28.4M|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  220|  28.4M|            }
  221|  28.4M|            bitpos = (uint_fast8_t)(bitpos + 7);
  222|  28.4M|        } while (byte & 0x80);
  ------------------
  |  Branch (222:18): [True: 96.3k, False: 28.3M]
  ------------------
  223|  28.3M|   }
  224|       |   
  225|  62.2M|   *dest = result;
  226|       |   return true;
  227|  62.2M|}
pb_decode_varint:
  231|  10.9M|{
  232|  10.9M|    pb_byte_t byte;
  233|  10.9M|    uint_fast8_t bitpos = 0;
  234|  10.9M|    uint64_t result = 0;
  235|       |    
  236|  10.9M|    do
  237|  18.0M|    {
  238|  18.0M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (238:13): [True: 96, False: 18.0M]
  ------------------
  239|     96|            return false;
  240|       |
  241|  18.0M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (241:13): [True: 68.6k, False: 17.9M]
  |  Branch (241:29): [True: 32, False: 68.6k]
  ------------------
  242|     32|            PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  920|     32|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     32|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  243|       |
  244|  18.0M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  245|  18.0M|        bitpos = (uint_fast8_t)(bitpos + 7);
  246|  18.0M|    } while (byte & 0x80);
  ------------------
  |  Branch (246:14): [True: 7.01M, False: 10.9M]
  ------------------
  247|       |    
  248|  10.9M|    *dest = result;
  249|       |    return true;
  250|  10.9M|}
pb_decode_tag:
  279|  30.0M|{
  280|  30.0M|    uint32_t temp;
  281|  30.0M|    *eof = false;
  282|  30.0M|    *wire_type = (pb_wire_type_t) 0;
  283|  30.0M|    *tag = 0;
  284|       |
  285|  30.0M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (285:9): [True: 175k, False: 29.9M]
  ------------------
  286|   175k|    {
  287|   175k|        *eof = true;
  288|   175k|        return false;
  289|   175k|    }
  290|       |
  291|  29.9M|    if (!pb_decode_varint32(stream, &temp))
  ------------------
  |  Branch (291:9): [True: 1.63k, False: 29.9M]
  ------------------
  292|  1.63k|    {
  293|  1.63k|#ifndef PB_BUFFER_ONLY
  294|       |        /* Workaround for issue #1017
  295|       |         *
  296|       |         * Callback streams don't set bytes_left to 0 on eof until after being called by pb_decode_varint32,
  297|       |         * which results in "io error" being raised. This contrasts the behavior of buffer streams who raise
  298|       |         * no error on eof as bytes_left is already 0 on entry. This causes legitimate errors (e.g. missing
  299|       |         * required fields) to be incorrectly reported by callback streams.
  300|       |         */
  301|  1.63k|        if (stream->callback != buf_read && stream->bytes_left == 0)
  ------------------
  |  Branch (301:13): [True: 1.52k, False: 105]
  |  Branch (301:45): [True: 1.52k, False: 0]
  ------------------
  302|  1.52k|        {
  303|  1.52k|#ifndef PB_NO_ERRMSG
  304|  1.52k|            if (strcmp(stream->errmsg, "io error") == 0)
  ------------------
  |  Branch (304:17): [True: 1.52k, False: 0]
  ------------------
  305|  1.52k|                stream->errmsg = NULL;
  306|  1.52k|#endif
  307|  1.52k|            *eof = true;
  308|  1.52k|        }
  309|  1.63k|#endif
  310|  1.63k|        return false;
  311|  1.63k|    }
  312|       |    
  313|  29.9M|    *tag = temp >> 3;
  314|  29.9M|    *wire_type = (pb_wire_type_t)(temp & 7);
  315|       |    return true;
  316|  29.9M|}
pb_skip_field:
  319|   402k|{
  320|   402k|    switch (wire_type)
  321|   402k|    {
  322|   195k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (322:9): [True: 195k, False: 206k]
  ------------------
  323|  15.7k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (323:9): [True: 15.7k, False: 387k]
  ------------------
  324|   139k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (324:9): [True: 139k, False: 263k]
  ------------------
  325|  51.4k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (325:9): [True: 51.4k, False: 351k]
  ------------------
  326|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (326:2): [True: 0, False: 402k]
  ------------------
  327|       |            /* Calling pb_skip_field with a PB_WT_PACKED is an error.
  328|       |             * Explicitly handle this case and fallthrough to default to avoid
  329|       |             * compiler warnings.
  330|       |             */
  331|     80|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  920|     80|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     80|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 80]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (331:9): [True: 80, False: 402k]
  ------------------
  332|   402k|    }
  333|   402k|}
pb_make_string_substream:
  384|   248k|{
  385|   248k|    uint32_t size;
  386|   248k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (386:9): [True: 104, False: 248k]
  ------------------
  387|    104|        return false;
  388|       |    
  389|   248k|    *substream = *stream;
  390|   248k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (390:9): [True: 74, False: 248k]
  ------------------
  391|     74|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  920|     74|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     74|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 74]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  392|       |    
  393|   248k|    substream->bytes_left = (size_t)size;
  394|   248k|    stream->bytes_left -= (size_t)size;
  395|       |    return true;
  396|   248k|}
pb_close_string_substream:
  399|   248k|{
  400|   248k|    if (substream->bytes_left) {
  ------------------
  |  Branch (400:9): [True: 120, False: 248k]
  ------------------
  401|    120|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (401:13): [True: 0, False: 120]
  ------------------
  402|      0|            return false;
  403|    120|    }
  404|       |
  405|   248k|    stream->state = substream->state;
  406|       |
  407|   248k|#ifndef PB_NO_ERRMSG
  408|   248k|    stream->errmsg = substream->errmsg;
  409|   248k|#endif
  410|       |    return true;
  411|   248k|}
pb_decode_ex:
 1199|  8.00k|{
 1200|  8.00k|    bool status;
 1201|       |
 1202|  8.00k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  111|  8.00k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1202:9): [True: 8.00k, False: 0]
  ------------------
 1203|  8.00k|    {
 1204|  8.00k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1205|  8.00k|    }
 1206|      0|    else
 1207|      0|    {
 1208|      0|      pb_istream_t substream;
 1209|      0|      if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1209:11): [True: 0, False: 0]
  ------------------
 1210|      0|        return false;
 1211|       |
 1212|      0|      status = pb_decode_inner(&substream, fields, dest_struct, flags);
 1213|       |
 1214|      0|      if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1214:11): [True: 0, False: 0]
  ------------------
 1215|      0|        status = false;
 1216|      0|    }
 1217|       |    
 1218|  8.00k|#ifdef PB_ENABLE_MALLOC
 1219|  8.00k|    if (!status)
  ------------------
  |  Branch (1219:9): [True: 2.10k, False: 5.90k]
  ------------------
 1220|  2.10k|        pb_release(fields, dest_struct);
 1221|  8.00k|#endif
 1222|       |    
 1223|  8.00k|    return status;
 1224|  8.00k|}
pb_decode:
 1227|  2.84k|{
 1228|  2.84k|    return pb_decode_ex(stream, fields, dest_struct, 0);
 1229|  2.84k|}
pb_release:
 1356|   181k|{
 1357|   181k|    pb_field_iter_t iter;
 1358|       |    
 1359|   181k|    if (!dest_struct)
  ------------------
  |  Branch (1359:9): [True: 0, False: 181k]
  ------------------
 1360|      0|        return; /* Ignore NULL pointers, similar to free() */
 1361|       |
 1362|   181k|    if (!pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1362:9): [True: 66.7k, False: 114k]
  ------------------
 1363|  66.7k|        return; /* Empty message type */
 1364|       |    
 1365|   114k|    do
 1366|   964k|    {
 1367|   964k|        pb_release_single_field(&iter);
 1368|   964k|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (1368:14): [True: 850k, False: 114k]
  ------------------
 1369|   114k|}
pb_decode_bool:
 1382|  4.25M|{
 1383|  4.25M|    uint32_t value;
 1384|  4.25M|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1384:9): [True: 68, False: 4.25M]
  ------------------
 1385|     68|        return false;
 1386|       |
 1387|  4.25M|    *(bool*)dest = (value != 0);
 1388|       |    return true;
 1389|  4.25M|}
pb_decode_svarint:
 1392|  5.10M|{
 1393|  5.10M|    pb_uint64_t value;
  ------------------
  |  |   57|  5.10M|#define pb_uint64_t uint64_t
  ------------------
 1394|  5.10M|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1394:9): [True: 42, False: 5.10M]
  ------------------
 1395|     42|        return false;
 1396|       |    
 1397|  5.10M|    if (value & 1)
  ------------------
  |  Branch (1397:9): [True: 719k, False: 4.38M]
  ------------------
 1398|   719k|        *dest = (pb_int64_t)(~(value >> 1));
 1399|  4.38M|    else
 1400|  4.38M|        *dest = (pb_int64_t)(value >> 1);
 1401|       |    
 1402|       |    return true;
 1403|  5.10M|}
pb_decode_fixed32:
 1406|  78.1k|{
 1407|  78.1k|    union {
 1408|  78.1k|        uint32_t fixed32;
 1409|  78.1k|        pb_byte_t bytes[4];
 1410|  78.1k|    } u;
 1411|       |
 1412|  78.1k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1412:9): [True: 21, False: 78.1k]
  ------------------
 1413|     21|        return false;
 1414|       |
 1415|  78.1k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1416|       |    /* fast path - if we know that we're on little endian, assign directly */
 1417|  78.1k|    *(uint32_t*)dest = u.fixed32;
 1418|       |#else
 1419|       |    *(uint32_t*)dest = ((uint32_t)u.bytes[0] << 0) |
 1420|       |                       ((uint32_t)u.bytes[1] << 8) |
 1421|       |                       ((uint32_t)u.bytes[2] << 16) |
 1422|       |                       ((uint32_t)u.bytes[3] << 24);
 1423|       |#endif
 1424|       |    return true;
 1425|  78.1k|}
pb_decode_fixed64:
 1429|  58.1k|{
 1430|  58.1k|    union {
 1431|  58.1k|        uint64_t fixed64;
 1432|  58.1k|        pb_byte_t bytes[8];
 1433|  58.1k|    } u;
 1434|       |
 1435|  58.1k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1435:9): [True: 17, False: 58.1k]
  ------------------
 1436|     17|        return false;
 1437|       |
 1438|  58.1k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1439|       |    /* fast path - if we know that we're on little endian, assign directly */
 1440|  58.1k|    *(uint64_t*)dest = u.fixed64;
 1441|       |#else
 1442|       |    *(uint64_t*)dest = ((uint64_t)u.bytes[0] << 0) |
 1443|       |                       ((uint64_t)u.bytes[1] << 8) |
 1444|       |                       ((uint64_t)u.bytes[2] << 16) |
 1445|       |                       ((uint64_t)u.bytes[3] << 24) |
 1446|       |                       ((uint64_t)u.bytes[4] << 32) |
 1447|       |                       ((uint64_t)u.bytes[5] << 40) |
 1448|       |                       ((uint64_t)u.bytes[6] << 48) |
 1449|       |                       ((uint64_t)u.bytes[7] << 56);
 1450|       |#endif
 1451|       |    return true;
 1452|  58.1k|}
pb_decode.c:buf_read:
   69|  77.4M|{
   70|  77.4M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   71|  77.4M|    stream->state = (pb_byte_t*)stream->state + count;
   72|       |    
   73|  77.4M|    if (buf != NULL)
  ------------------
  |  Branch (73:9): [True: 77.3M, False: 68.1k]
  ------------------
   74|  77.3M|    {
   75|  77.3M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   76|  77.3M|    }
   77|       |    
   78|       |    return true;
   79|  77.4M|}
pb_decode.c:pb_readbyte:
  125|   108M|{
  126|   108M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (126:9): [True: 364, False: 108M]
  ------------------
  127|    364|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  920|    364|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|    364|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 364]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|       |
  129|   108M|#ifndef PB_BUFFER_ONLY
  130|   108M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (130:9): [True: 1.52k, False: 108M]
  ------------------
  131|  1.52k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  920|  1.52k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|  1.52k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 1.52k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|       |#else
  133|       |    *buf = *(const pb_byte_t*)stream->state;
  134|       |    stream->state = (pb_byte_t*)stream->state + 1;
  135|       |#endif
  136|       |
  137|   108M|    stream->bytes_left--;
  138|       |    
  139|       |    return true;    
  140|   108M|}
pb_decode.c:pb_skip_varint:
  254|   195k|{
  255|   195k|    pb_byte_t byte;
  256|   195k|    do
  257|   291k|    {
  258|   291k|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (258:13): [True: 70, False: 290k]
  ------------------
  259|     70|            return false;
  260|   291k|    } while (byte & 0x80);
  ------------------
  |  Branch (260:14): [True: 95.2k, False: 195k]
  ------------------
  261|   195k|    return true;
  262|   195k|}
pb_decode.c:pb_skip_string:
  265|   139k|{
  266|   139k|    uint32_t length;
  267|   139k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (267:9): [True: 53, False: 139k]
  ------------------
  268|     53|        return false;
  269|       |    
  270|   139k|    if ((size_t)length != length)
  ------------------
  |  Branch (270:9): [True: 0, False: 139k]
  ------------------
  271|      0|    {
  272|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  273|      0|    }
  274|       |
  275|   139k|    return pb_read(stream, NULL, (size_t)length);
  276|   139k|}
pb_decode.c:pb_decode_inner:
 1028|   179k|{
 1029|       |    /* If the message contains extension fields, the extension handlers
 1030|       |     * are called when tag number is >= extension_range_start. This precheck
 1031|       |     * is just for speed, and the handlers will check for precise match.
 1032|       |     */
 1033|   179k|    uint32_t extension_range_start = 0;
 1034|   179k|    pb_extension_t *extensions = NULL;
 1035|       |
 1036|       |    /* 'fixed_count_field' and 'fixed_count_size' track position of a repeated fixed
 1037|       |     * count field. This can only handle _one_ repeated fixed count field that
 1038|       |     * is unpacked and unordered among other (non repeated fixed count) fields.
 1039|       |     */
 1040|   179k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  339|   179k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
 1041|   179k|    pb_size_t fixed_count_size = 0;
 1042|   179k|    pb_size_t fixed_count_total_size = 0;
 1043|       |
 1044|       |    /* Tag and wire type of next field from the input stream */
 1045|   179k|    uint32_t tag;
 1046|   179k|    pb_wire_type_t wire_type;
 1047|   179k|    bool eof;
 1048|       |
 1049|       |    /* Track presence of required fields */
 1050|   179k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1051|   179k|    const uint32_t allbits = ~(uint32_t)0;
 1052|       |
 1053|       |    /* Descriptor for the structure field matching the tag decoded from stream */
 1054|   179k|    pb_field_iter_t iter;
 1055|       |
 1056|   179k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1056:9): [True: 112k, False: 66.7k]
  ------------------
 1057|   112k|    {
 1058|   112k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |  110|   112k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1058:13): [True: 101k, False: 10.7k]
  ------------------
 1059|   101k|        {
 1060|   101k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1060:17): [True: 0, False: 101k]
  ------------------
 1061|      0|                PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1062|   101k|        }
 1063|   112k|    }
 1064|       |
 1065|  30.0M|    while (pb_decode_tag(stream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1065:12): [True: 29.9M, False: 177k]
  ------------------
 1066|  29.9M|    {
 1067|  29.9M|        if (tag == 0)
  ------------------
  |  Branch (1067:13): [True: 74, False: 29.9M]
  ------------------
 1068|     74|        {
 1069|     74|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  112|     74|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1069:15): [True: 0, False: 74]
  ------------------
 1070|      0|          {
 1071|      0|            eof = true;
 1072|      0|            break;
 1073|      0|          }
 1074|     74|          else
 1075|     74|          {
 1076|     74|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  920|     74|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     74|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 74]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1077|     74|          }
 1078|     74|        }
 1079|       |
 1080|  29.9M|        if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|  29.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  29.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|  29.4M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1080:13): [True: 406k, False: 29.4M]
  |  Branch (1080:48): [True: 929, False: 29.4M]
  ------------------
 1081|   406k|        {
 1082|       |            /* No match found, check if it matches an extension. */
 1083|   406k|            if (extension_range_start == 0)
  ------------------
  |  Branch (1083:17): [True: 9.19k, False: 397k]
  ------------------
 1084|  9.19k|            {
 1085|  9.19k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1085:21): [True: 3.84k, False: 5.34k]
  ------------------
 1086|  3.84k|                {
 1087|  3.84k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1088|  3.84k|                    extension_range_start = iter.tag;
 1089|  3.84k|                }
 1090|       |
 1091|  9.19k|                if (!extensions)
  ------------------
  |  Branch (1091:21): [True: 6.01k, False: 3.17k]
  ------------------
 1092|  6.01k|                {
 1093|  6.01k|                    extension_range_start = (uint32_t)-1;
 1094|  6.01k|                }
 1095|  9.19k|            }
 1096|       |
 1097|   406k|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1097:17): [True: 76.1k, False: 330k]
  ------------------
 1098|  76.1k|            {
 1099|  76.1k|                size_t pos = stream->bytes_left;
 1100|       |
 1101|  76.1k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1101:21): [True: 111, False: 76.0k]
  ------------------
 1102|    111|                    return false;
 1103|       |
 1104|  76.0k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1104:21): [True: 4.09k, False: 71.9k]
  ------------------
 1105|  4.09k|                {
 1106|       |                    /* The field was handled */
 1107|  4.09k|                    continue;
 1108|  4.09k|                }
 1109|  76.0k|            }
 1110|       |
 1111|       |            /* No match found, skip data */
 1112|   402k|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1112:17): [True: 297, False: 402k]
  ------------------
 1113|    297|                return false;
 1114|   402k|            continue;
 1115|   402k|        }
 1116|       |
 1117|       |        /* If a repeated fixed count field was found, get size from
 1118|       |         * 'fixed_count_field' as there is no counter contained in the struct.
 1119|       |         */
 1120|  29.4M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  324|  29.4M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  29.4M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  311|  58.9M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1120:13): [True: 27.8M, False: 1.68M]
  |  Branch (1120:57): [True: 1.63k, False: 27.8M]
  ------------------
 1121|  1.63k|        {
 1122|  1.63k|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1122:17): [True: 1.01k, False: 621]
  ------------------
 1123|       |                /* If the new fixed count field does not match the previous one,
 1124|       |                 * check that the previous one is NULL or that it finished
 1125|       |                 * receiving all the expected data.
 1126|       |                 */
 1127|  1.01k|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  339|  2.02k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1127:21): [True: 438, False: 575]
  ------------------
 1128|    438|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1128:21): [True: 33, False: 405]
  ------------------
 1129|     33|                {
 1130|     33|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  920|     33|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     33|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 33]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1131|     33|                }
 1132|       |
 1133|    980|                fixed_count_field = iter.index;
 1134|    980|                fixed_count_size = 0;
 1135|    980|                fixed_count_total_size = iter.array_size;
 1136|    980|            }
 1137|       |
 1138|  1.60k|            iter.pSize = &fixed_count_size;
 1139|  1.60k|        }
 1140|       |
 1141|  29.4M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  324|  29.4M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  29.4M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  308|  58.9M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1141:13): [True: 1.64M, False: 27.8M]
  ------------------
 1142|  1.64M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  230|  1.64M|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1142:16): [True: 1.64M, False: 0]
  ------------------
 1143|  1.64M|        {
 1144|  1.64M|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1145|  1.64M|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1146|  1.64M|        }
 1147|       |
 1148|  29.4M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1148:13): [True: 1.35k, False: 29.4M]
  ------------------
 1149|  1.35k|            return false;
 1150|  29.4M|    }
 1151|       |
 1152|   177k|    if (!eof)
  ------------------
  |  Branch (1152:9): [True: 105, False: 177k]
  ------------------
 1153|    105|    {
 1154|       |        /* pb_decode_tag() returned error before end of stream */
 1155|    105|        return false;
 1156|    105|    }
 1157|       |
 1158|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1159|   177k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  339|   354k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1159:9): [True: 490, False: 176k]
  ------------------
 1160|    490|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1160:9): [True: 38, False: 452]
  ------------------
 1161|     38|    {
 1162|     38|        PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  920|     38|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     38|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 38]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1163|     38|    }
 1164|       |
 1165|       |    /* Check that all required fields were present. */
 1166|   177k|    {
 1167|   177k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1168|       |
 1169|   177k|        if (req_field_count > 0)
  ------------------
  |  Branch (1169:13): [True: 106k, False: 70.8k]
  ------------------
 1170|   106k|        {
 1171|   106k|            pb_size_t i;
 1172|       |
 1173|   106k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  230|   106k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1173:17): [True: 0, False: 106k]
  ------------------
 1174|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  230|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1175|       |
 1176|       |            /* Check the whole words */
 1177|   106k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1177:25): [True: 0, False: 106k]
  ------------------
 1178|      0|            {
 1179|      0|                if (fields_seen.bitfield[i] != allbits)
  ------------------
  |  Branch (1179:21): [True: 0, False: 0]
  ------------------
 1180|      0|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1181|      0|            }
 1182|       |
 1183|       |            /* Check the remaining bits (if any) */
 1184|   106k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1184:17): [True: 106k, False: 0]
  ------------------
 1185|   106k|            {
 1186|   106k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1186:21): [True: 443, False: 105k]
  ------------------
 1187|   106k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1188|    443|                {
 1189|    443|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  920|    443|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|    443|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 443]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1190|    443|                }
 1191|   106k|            }
 1192|   106k|        }
 1193|   177k|    }
 1194|       |
 1195|   176k|    return true;
 1196|   177k|}
pb_decode.c:pb_message_set_to_defaults:
  989|   108k|{
  990|   108k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   60|   108k|#define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
  991|   108k|    uint32_t tag = 0;
  992|   108k|    pb_wire_type_t wire_type = PB_WT_VARINT;
  993|   108k|    bool eof;
  994|       |
  995|   108k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (995:9): [True: 0, False: 108k]
  ------------------
  996|      0|    {
  997|      0|        defstream = pb_istream_from_buffer(iter->descriptor->default_value, (size_t)-1);
  998|      0|        if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (998:13): [True: 0, False: 0]
  ------------------
  999|      0|            return false;
 1000|      0|    }
 1001|       |
 1002|   108k|    do
 1003|   932k|    {
 1004|   932k|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (1004:13): [True: 0, False: 932k]
  ------------------
 1005|      0|            return false;
 1006|       |
 1007|   932k|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (1007:13): [True: 0, False: 932k]
  |  Branch (1007:25): [True: 0, False: 0]
  ------------------
 1008|      0|        {
 1009|       |            /* We have a default value for this field in the defstream */
 1010|      0|            if (!decode_field(&defstream, wire_type, iter))
  ------------------
  |  Branch (1010:17): [True: 0, False: 0]
  ------------------
 1011|      0|                return false;
 1012|      0|            if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1012:17): [True: 0, False: 0]
  ------------------
 1013|      0|                return false;
 1014|       |
 1015|      0|            if (iter->pSize)
  ------------------
  |  Branch (1015:17): [True: 0, False: 0]
  ------------------
 1016|      0|                *(bool*)iter->pSize = false;
 1017|      0|        }
 1018|   932k|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (1018:14): [True: 824k, False: 108k]
  ------------------
 1019|       |
 1020|   108k|    return true;
 1021|   108k|}
pb_decode.c:pb_field_set_to_default:
  907|   932k|{
  908|   932k|    pb_type_t type;
  909|   932k|    type = field->type;
  910|       |
  911|   932k|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|   932k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   932k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|   932k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (911:9): [True: 8.00k, False: 924k]
  ------------------
  912|  8.00k|    {
  913|  8.00k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  914|  14.4k|        while (ext != NULL)
  ------------------
  |  Branch (914:16): [True: 6.48k, False: 8.00k]
  ------------------
  915|  6.48k|        {
  916|  6.48k|            pb_field_iter_t ext_iter;
  917|  6.48k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (917:17): [True: 6.48k, False: 0]
  ------------------
  918|  6.48k|            {
  919|  6.48k|                ext->found = false;
  920|  6.48k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (920:21): [True: 0, False: 6.48k]
  ------------------
  921|      0|                    return false;
  922|  6.48k|            }
  923|  6.48k|            ext = ext->next;
  924|  6.48k|        }
  925|  8.00k|    }
  926|   924k|    else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  323|   924k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   924k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  318|   924k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (926:14): [True: 14.4k, False: 909k]
  ------------------
  927|  14.4k|    {
  928|  14.4k|        bool init_data = true;
  929|  14.4k|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  324|  14.4k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  14.4k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  309|  28.9k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (929:13): [True: 0, False: 14.4k]
  |  Branch (929:52): [True: 0, False: 0]
  ------------------
  930|      0|        {
  931|       |            /* Set has_field to false. Still initialize the optional field
  932|       |             * itself also. */
  933|      0|            *(bool*)field->pSize = false;
  934|      0|        }
  935|  14.4k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  324|  14.4k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  14.4k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  311|  28.9k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (935:18): [True: 0, False: 14.4k]
  ------------------
  936|  14.4k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|  14.4k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  14.4k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|  14.4k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (936:18): [True: 8.00k, False: 6.48k]
  ------------------
  937|  8.00k|        {
  938|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
  939|       |               ONEOF: Set which_field to 0. */
  940|  8.00k|            *(pb_size_t*)field->pSize = 0;
  941|  8.00k|            init_data = false;
  942|  8.00k|        }
  943|       |
  944|  14.4k|        if (init_data)
  ------------------
  |  Branch (944:13): [True: 6.48k, False: 8.00k]
  ------------------
  945|  6.48k|        {
  946|  6.48k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  326|  12.9k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|  6.48k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  6.48k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  12.9k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 6.48k, False: 0]
  |  |  ------------------
  |  |  327|  12.9k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|      0|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  947|  6.48k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (947:18): [True: 0, False: 6.48k]
  ------------------
  948|  6.48k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (948:18): [True: 0, False: 6.48k]
  ------------------
  949|  6.48k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (949:18): [True: 0, False: 6.48k]
  ------------------
  950|      0|            {
  951|       |                /* Initialize submessage to defaults.
  952|       |                 * Only needed if it has default values
  953|       |                 * or callback/submessage fields. */
  954|      0|                pb_field_iter_t submsg_iter;
  955|      0|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (955:21): [True: 0, False: 0]
  ------------------
  956|      0|                {
  957|      0|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (957:25): [True: 0, False: 0]
  ------------------
  958|      0|                        return false;
  959|      0|                }
  960|      0|            }
  961|  6.48k|            else
  962|  6.48k|            {
  963|       |                /* Initialize to zeros */
  964|  6.48k|                memset(field->pData, 0, (size_t)field->data_size);
  965|  6.48k|            }
  966|  6.48k|        }
  967|  14.4k|    }
  968|   909k|    else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|   909k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   909k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|   909k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (968:14): [True: 909k, False: 0]
  ------------------
  969|   909k|    {
  970|       |        /* Initialize the pointer to NULL. */
  971|   909k|        *(void**)field->pField = NULL;
  972|       |
  973|       |        /* Initialize array count to 0. */
  974|   909k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  324|   909k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   909k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  311|  1.81M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (974:13): [True: 168k, False: 741k]
  ------------------
  975|   741k|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|   741k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   741k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|   741k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (975:13): [True: 16.0k, False: 725k]
  ------------------
  976|   184k|        {
  977|   184k|            *(pb_size_t*)field->pSize = 0;
  978|   184k|        }
  979|   909k|    }
  980|      0|    else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|      0|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|      0|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  320|      0|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (980:14): [True: 0, False: 0]
  ------------------
  981|      0|    {
  982|       |        /* Don't overwrite callback */
  983|      0|    }
  984|       |
  985|   932k|    return true;
  986|   932k|}
pb_decode.c:decode_extension:
  885|  76.1k|{
  886|  76.1k|    size_t pos = stream->bytes_left;
  887|       |    
  888|   152k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (888:12): [True: 76.1k, False: 76.0k]
  |  Branch (888:33): [True: 76.1k, False: 0]
  ------------------
  889|  76.1k|    {
  890|  76.1k|        bool status;
  891|  76.1k|        if (extension->type->decode)
  ------------------
  |  Branch (891:13): [True: 0, False: 76.1k]
  ------------------
  892|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  893|  76.1k|        else
  894|  76.1k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  895|       |
  896|  76.1k|        if (!status)
  ------------------
  |  Branch (896:13): [True: 111, False: 76.0k]
  ------------------
  897|    111|            return false;
  898|       |        
  899|  76.0k|        extension = extension->next;
  900|  76.0k|    }
  901|       |    
  902|  76.0k|    return true;
  903|  76.1k|}
pb_decode.c:default_extension_decoder:
  868|  76.1k|{
  869|  76.1k|    pb_field_iter_t iter;
  870|       |
  871|  76.1k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (871:9): [True: 0, False: 76.1k]
  ------------------
  872|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  873|       |
  874|  76.1k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (874:9): [True: 71.9k, False: 4.20k]
  |  Branch (874:28): [True: 0, False: 4.20k]
  ------------------
  875|  71.9k|        return true;
  876|       |
  877|  4.20k|    extension->found = true;
  878|  4.20k|    return decode_field(stream, wire_type, &iter);
  879|  76.1k|}
pb_decode.c:decode_field:
  836|  29.4M|{
  837|  29.4M|#ifdef PB_ENABLE_MALLOC
  838|       |    /* When decoding an oneof field, check if there is old data that must be
  839|       |     * released first. */
  840|  29.4M|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|  29.4M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  29.4M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|  29.4M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (840:9): [True: 25.6k, False: 29.4M]
  ------------------
  841|  25.6k|    {
  842|  25.6k|        if (!pb_release_union_field(stream, field))
  ------------------
  |  Branch (842:13): [True: 0, False: 25.6k]
  ------------------
  843|      0|            return false;
  844|  25.6k|    }
  845|  29.4M|#endif
  846|       |
  847|  29.4M|    switch (PB_ATYPE(field->type))
  ------------------
  |  |  323|  29.4M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  29.4M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
  848|  29.4M|    {
  849|  12.5k|        case PB_ATYPE_STATIC:
  ------------------
  |  |  318|  12.5k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (849:9): [True: 12.5k, False: 29.4M]
  ------------------
  850|  12.5k|            return decode_static_field(stream, wire_type, field);
  851|       |        
  852|  29.4M|        case PB_ATYPE_POINTER:
  ------------------
  |  |  319|  29.4M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (852:9): [True: 29.4M, False: 12.5k]
  ------------------
  853|  29.4M|            return decode_pointer_field(stream, wire_type, field);
  854|       |        
  855|      0|        case PB_ATYPE_CALLBACK:
  ------------------
  |  |  320|      0|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (855:9): [True: 0, False: 29.4M]
  ------------------
  856|      0|            return decode_callback_field(stream, wire_type, field);
  857|       |        
  858|      0|        default:
  ------------------
  |  Branch (858:9): [True: 0, False: 29.4M]
  ------------------
  859|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  860|  29.4M|    }
  861|  29.4M|}
pb_decode.c:pb_release_union_field:
 1235|  25.6k|{
 1236|  25.6k|    pb_field_iter_t old_field = *field;
 1237|  25.6k|    pb_size_t old_tag = *(pb_size_t*)field->pSize; /* Previous which_ value */
 1238|  25.6k|    pb_size_t new_tag = field->tag; /* New which_ value */
 1239|       |
 1240|  25.6k|    if (old_tag == 0)
  ------------------
  |  Branch (1240:9): [True: 1.02k, False: 24.6k]
  ------------------
 1241|  1.02k|        return true; /* Ok, no old data in union */
 1242|       |
 1243|  24.6k|    if (old_tag == new_tag)
  ------------------
  |  Branch (1243:9): [True: 10.3k, False: 14.2k]
  ------------------
 1244|  10.3k|        return true; /* Ok, old data is of same type => merge */
 1245|       |
 1246|       |    /* Release old data. The find can fail if the message struct contains
 1247|       |     * invalid data. */
 1248|  14.2k|    if (!pb_field_iter_find(&old_field, old_tag))
  ------------------
  |  Branch (1248:9): [True: 0, False: 14.2k]
  ------------------
 1249|      0|        PB_RETURN_ERROR(stream, "invalid union tag");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1250|       |
 1251|  14.2k|    pb_release_single_field(&old_field);
 1252|       |
 1253|  14.2k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|  14.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  14.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|  14.2k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1253:9): [True: 8.87k, False: 5.41k]
  ------------------
 1254|  8.87k|    {
 1255|       |        /* Initialize the pointer to NULL to make sure it is valid
 1256|       |         * even in case of error return. */
 1257|  8.87k|        *(void**)field->pField = NULL;
 1258|  8.87k|        field->pData = NULL;
 1259|  8.87k|    }
 1260|       |
 1261|       |    return true;
 1262|  14.2k|}
pb_decode.c:decode_static_field:
  489|  12.5k|{
  490|  12.5k|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  324|  12.5k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  12.5k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  491|  12.5k|    {
  492|  4.20k|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  308|  4.20k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (492:9): [True: 4.20k, False: 8.32k]
  ------------------
  493|  4.20k|            return decode_basic_field(stream, wire_type, field);
  494|       |            
  495|  1.71k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  309|  1.71k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (495:9): [True: 1.71k, False: 10.8k]
  ------------------
  496|  1.71k|            if (field->pSize != NULL)
  ------------------
  |  Branch (496:17): [True: 1.71k, False: 0]
  ------------------
  497|  1.71k|                *(bool*)field->pSize = true;
  498|  1.71k|            return decode_basic_field(stream, wire_type, field);
  499|       |    
  500|      0|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  311|      0|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (500:9): [True: 0, False: 12.5k]
  ------------------
  501|      0|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (501:17): [True: 0, False: 0]
  ------------------
  502|      0|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  325|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  273|      0|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (502:20): [True: 0, False: 0]
  ------------------
  503|      0|            {
  504|       |                /* Packed array */
  505|      0|                bool status = true;
  506|      0|                pb_istream_t substream;
  507|      0|                pb_size_t *size = (pb_size_t*)field->pSize;
  508|      0|                field->pData = (char*)field->pField + field->data_size * (*size);
  509|       |
  510|      0|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (510:21): [True: 0, False: 0]
  ------------------
  511|      0|                    return false;
  512|       |
  513|      0|                while (substream.bytes_left > 0 && *size < field->array_size)
  ------------------
  |  Branch (513:24): [True: 0, False: 0]
  |  Branch (513:52): [True: 0, False: 0]
  ------------------
  514|      0|                {
  515|      0|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (515:25): [True: 0, False: 0]
  ------------------
  516|      0|                    {
  517|      0|                        status = false;
  518|      0|                        break;
  519|      0|                    }
  520|      0|                    (*size)++;
  521|      0|                    field->pData = (char*)field->pData + field->data_size;
  522|      0|                }
  523|       |
  524|      0|                if (substream.bytes_left != 0)
  ------------------
  |  Branch (524:21): [True: 0, False: 0]
  ------------------
  525|      0|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  526|      0|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (526:21): [True: 0, False: 0]
  ------------------
  527|      0|                    return false;
  528|       |
  529|      0|                return status;
  530|      0|            }
  531|      0|            else
  532|      0|            {
  533|       |                /* Repeated field */
  534|      0|                pb_size_t *size = (pb_size_t*)field->pSize;
  535|      0|                field->pData = (char*)field->pField + field->data_size * (*size);
  536|       |
  537|      0|                if ((*size)++ >= field->array_size)
  ------------------
  |  Branch (537:21): [True: 0, False: 0]
  ------------------
  538|      0|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  539|       |
  540|      0|                return decode_basic_field(stream, wire_type, field);
  541|      0|            }
  542|       |
  543|  6.60k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  313|  6.60k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (543:9): [True: 6.60k, False: 5.92k]
  ------------------
  544|  6.60k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  326|  13.2k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|  6.60k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  6.60k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  13.2k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 6.60k, False: 0]
  |  |  ------------------
  |  |  327|  13.2k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|      0|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  545|  6.60k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (545:17): [True: 5.73k, False: 872]
  ------------------
  546|  5.73k|            {
  547|       |                /* We memset to zero so that any callbacks are set to NULL.
  548|       |                 * This is because the callbacks might otherwise have values
  549|       |                 * from some other union field.
  550|       |                 * If callbacks are needed inside oneof field, use .proto
  551|       |                 * option submsg_callback to have a separate callback function
  552|       |                 * that can set the fields before submessage is decoded.
  553|       |                 * pb_dec_submessage() will set any default values. */
  554|  5.73k|                memset(field->pData, 0, (size_t)field->data_size);
  555|       |
  556|       |                /* Set default values for the submessage fields. */
  557|  5.73k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (557:21): [True: 0, False: 5.73k]
  ------------------
  558|  5.73k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (558:21): [True: 0, False: 5.73k]
  ------------------
  559|  5.73k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (559:21): [True: 0, False: 5.73k]
  ------------------
  560|      0|                {
  561|      0|                    pb_field_iter_t submsg_iter;
  562|      0|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (562:25): [True: 0, False: 0]
  ------------------
  563|      0|                    {
  564|      0|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (564:29): [True: 0, False: 0]
  ------------------
  565|      0|                            PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  566|      0|                    }
  567|      0|                }
  568|  5.73k|            }
  569|  6.60k|            *(pb_size_t*)field->pSize = field->tag;
  570|       |
  571|  6.60k|            return decode_basic_field(stream, wire_type, field);
  572|       |
  573|      0|        default:
  ------------------
  |  Branch (573:9): [True: 0, False: 12.5k]
  ------------------
  574|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  575|  12.5k|    }
  576|  12.5k|}
pb_decode.c:decode_basic_field:
  418|  43.3M|{
  419|  43.3M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  325|  43.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  43.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  420|  43.3M|    {
  421|  4.25M|        case PB_LTYPE_BOOL:
  ------------------
  |  |  265|  4.25M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (421:9): [True: 4.25M, False: 39.0M]
  ------------------
  422|  4.25M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (422:17): [True: 3.88M, False: 370k]
  |  Branch (422:46): [True: 13, False: 3.88M]
  ------------------
  423|     13|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     13|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     13|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  424|       |
  425|  4.25M|            return pb_dec_bool(stream, field);
  426|       |
  427|  4.81M|        case PB_LTYPE_VARINT:
  ------------------
  |  |  266|  4.81M|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (427:9): [True: 4.81M, False: 38.4M]
  ------------------
  428|  5.89M|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  267|  5.89M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (428:9): [True: 1.07M, False: 42.2M]
  ------------------
  429|  10.9M|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  268|  10.9M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (429:9): [True: 5.10M, False: 38.2M]
  ------------------
  430|  10.9M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (430:17): [True: 9.98M, False: 1.01M]
  |  Branch (430:46): [True: 71, False: 9.98M]
  ------------------
  431|     71|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     71|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     71|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 71]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  432|       |
  433|  10.9M|            return pb_dec_varint(stream, field);
  434|       |
  435|  78.1k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  269|  78.1k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (435:9): [True: 78.1k, False: 43.2M]
  ------------------
  436|  78.1k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (436:17): [True: 8.93k, False: 69.2k]
  |  Branch (436:45): [True: 15, False: 8.92k]
  ------------------
  437|     15|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     15|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     15|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  438|       |
  439|  78.1k|            return pb_decode_fixed32(stream, field->pData);
  440|       |
  441|  58.1k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  270|  58.1k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (441:9): [True: 58.1k, False: 43.2M]
  ------------------
  442|  58.1k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (442:17): [True: 13.0k, False: 45.0k]
  |  Branch (442:45): [True: 10, False: 13.0k]
  ------------------
  443|     10|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     10|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     10|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  444|       |
  445|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  446|       |            if (field->data_size == sizeof(float))
  447|       |            {
  448|       |                return pb_decode_double_as_float(stream, (float*)field->pData);
  449|       |            }
  450|       |#endif
  451|       |
  452|       |#ifdef PB_WITHOUT_64BIT
  453|       |            PB_RETURN_ERROR(stream, "invalid data_size");
  454|       |#else
  455|  58.1k|            return pb_decode_fixed64(stream, field->pData);
  456|      0|#endif
  457|       |
  458|  1.16M|        case PB_LTYPE_BYTES:
  ------------------
  |  |  277|  1.16M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (458:9): [True: 1.16M, False: 42.1M]
  ------------------
  459|  1.16M|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (459:17): [True: 18, False: 1.16M]
  ------------------
  460|     18|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     18|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     18|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  461|       |
  462|  1.16M|            return pb_dec_bytes(stream, field);
  463|       |
  464|   104k|        case PB_LTYPE_STRING:
  ------------------
  |  |  281|   104k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (464:9): [True: 104k, False: 43.2M]
  ------------------
  465|   104k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (465:17): [True: 16, False: 104k]
  ------------------
  466|     16|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     16|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     16|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  467|       |
  468|   104k|            return pb_dec_string(stream, field);
  469|       |
  470|   171k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  285|   171k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (470:9): [True: 171k, False: 43.1M]
  ------------------
  471|   171k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  290|   171k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (471:9): [True: 0, False: 43.3M]
  ------------------
  472|   171k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (472:17): [True: 25, False: 171k]
  ------------------
  473|     25|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     25|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     25|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  474|       |
  475|   171k|            return pb_dec_submessage(stream, field);
  476|       |
  477|  26.4M|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  300|  26.4M|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (477:9): [True: 26.4M, False: 16.8M]
  ------------------
  478|  26.4M|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (478:17): [True: 4, False: 26.4M]
  ------------------
  479|      4|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|      4|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      4|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  480|       |
  481|  26.4M|            return pb_dec_fixed_length_bytes(stream, field);
  482|       |
  483|      0|        default:
  ------------------
  |  Branch (483:9): [True: 0, False: 43.3M]
  ------------------
  484|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  485|  43.3M|    }
  486|  43.3M|}
pb_decode.c:pb_dec_bool:
 1456|  4.25M|{
 1457|  4.25M|    return pb_decode_bool(stream, (bool*)field->pData);
 1458|  4.25M|}
pb_decode.c:pb_dec_varint:
 1461|  10.9M|{
 1462|  10.9M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  325|  10.9M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  10.9M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  267|  10.9M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1462:9): [True: 1.07M, False: 9.92M]
  ------------------
 1463|  1.07M|    {
 1464|  1.07M|        pb_uint64_t value, clamped;
  ------------------
  |  |   57|  1.07M|#define pb_uint64_t uint64_t
  ------------------
 1465|  1.07M|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1465:13): [True: 32, False: 1.07M]
  ------------------
 1466|     32|            return false;
 1467|       |
 1468|       |        /* Cast to the proper field size, while checking for overflows */
 1469|  1.07M|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1469:13): [True: 522k, False: 555k]
  ------------------
 1470|   522k|            clamped = *(pb_uint64_t*)field->pData = value;
 1471|   555k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1471:18): [True: 532k, False: 22.9k]
  ------------------
 1472|   532k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1473|  22.9k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1473:18): [True: 11.3k, False: 11.6k]
  ------------------
 1474|  11.3k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1475|  11.6k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1475:18): [True: 11.6k, False: 0]
  ------------------
 1476|  11.6k|            clamped = *(uint_least8_t*)field->pData = (uint_least8_t)value;
 1477|      0|        else
 1478|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1479|       |
 1480|  1.07M|        if (clamped != value)
  ------------------
  |  Branch (1480:13): [True: 111, False: 1.07M]
  ------------------
 1481|    111|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  920|    111|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|    111|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 111]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1482|       |
 1483|  1.07M|        return true;
 1484|  1.07M|    }
 1485|  9.92M|    else
 1486|  9.92M|    {
 1487|  9.92M|        pb_uint64_t value;
  ------------------
  |  |   57|  9.92M|#define pb_uint64_t uint64_t
  ------------------
 1488|  9.92M|        pb_int64_t svalue;
  ------------------
  |  |   56|  9.92M|#define pb_int64_t int64_t
  ------------------
 1489|  9.92M|        pb_int64_t clamped;
  ------------------
  |  |   56|  9.92M|#define pb_int64_t int64_t
  ------------------
 1490|       |
 1491|  9.92M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  325|  9.92M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  9.92M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  268|  9.92M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1491:13): [True: 5.10M, False: 4.81M]
  ------------------
 1492|  5.10M|        {
 1493|  5.10M|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1493:17): [True: 42, False: 5.10M]
  ------------------
 1494|     42|                return false;
 1495|  5.10M|        }
 1496|  4.81M|        else
 1497|  4.81M|        {
 1498|  4.81M|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1498:17): [True: 54, False: 4.81M]
  ------------------
 1499|     54|                return false;
 1500|       |
 1501|       |            /* See issue 97: Google's C++ protobuf allows negative varint values to
 1502|       |            * be cast as int32_t, instead of the int64_t that should be used when
 1503|       |            * encoding. Nanopb versions before 0.2.5 had a bug in encoding. In order to
 1504|       |            * not break decoding of such messages, we cast <=32 bit fields to
 1505|       |            * int32_t first to get the sign correct.
 1506|       |            */
 1507|  4.81M|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1507:17): [True: 1.05M, False: 3.76M]
  ------------------
 1508|  1.05M|                svalue = (pb_int64_t)value;
 1509|  3.76M|            else
 1510|  3.76M|                svalue = (int32_t)value;
 1511|  4.81M|        }
 1512|       |
 1513|       |        /* Cast to the proper field size, while checking for overflows */
 1514|  9.92M|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1514:13): [True: 6.09M, False: 3.82M]
  ------------------
 1515|  6.09M|            clamped = *(pb_int64_t*)field->pData = svalue;
 1516|  3.82M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1516:18): [True: 3.78M, False: 45.6k]
  ------------------
 1517|  3.78M|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1518|  45.6k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1518:18): [True: 22.8k, False: 22.8k]
  ------------------
 1519|  22.8k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1520|  22.8k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1520:18): [True: 22.8k, False: 0]
  ------------------
 1521|  22.8k|            clamped = *(int_least8_t*)field->pData = (int_least8_t)svalue;
 1522|      0|        else
 1523|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1524|       |
 1525|  9.92M|        if (clamped != svalue)
  ------------------
  |  Branch (1525:13): [True: 94, False: 9.92M]
  ------------------
 1526|     94|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  920|     94|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     94|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 94]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1527|       |
 1528|  9.92M|        return true;
 1529|  9.92M|    }
 1530|  10.9M|}
pb_decode.c:pb_dec_bytes:
 1533|  1.16M|{
 1534|  1.16M|    uint32_t size;
 1535|  1.16M|    size_t alloc_size;
 1536|  1.16M|    pb_bytes_array_t *dest;
 1537|       |    
 1538|  1.16M|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1538:9): [True: 18, False: 1.16M]
  ------------------
 1539|     18|        return false;
 1540|       |    
 1541|  1.16M|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  339|  1.16M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1541:9): [True: 32, False: 1.16M]
  ------------------
 1542|     32|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  920|     32|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     32|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1543|       |    
 1544|  1.16M|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  403|  1.16M|#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes))
  ------------------
 1545|  1.16M|    if (size > alloc_size)
  ------------------
  |  Branch (1545:9): [True: 0, False: 1.16M]
  ------------------
 1546|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1547|       |    
 1548|  1.16M|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|  1.16M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  1.16M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|  1.16M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1548:9): [True: 1.16M, False: 0]
  ------------------
 1549|  1.16M|    {
 1550|       |#ifndef PB_ENABLE_MALLOC
 1551|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1552|       |#else
 1553|  1.16M|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1553:13): [True: 34, False: 1.16M]
  ------------------
 1554|     34|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  920|     34|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     34|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 34]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1555|       |
 1556|  1.16M|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1556:13): [True: 0, False: 1.16M]
  ------------------
 1557|      0|            return false;
 1558|  1.16M|        dest = *(pb_bytes_array_t**)field->pData;
 1559|  1.16M|#endif
 1560|  1.16M|    }
 1561|      0|    else
 1562|      0|    {
 1563|      0|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1563:13): [True: 0, False: 0]
  ------------------
 1564|      0|            PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1565|      0|        dest = (pb_bytes_array_t*)field->pData;
 1566|      0|    }
 1567|       |
 1568|  1.16M|    dest->size = (pb_size_t)size;
 1569|  1.16M|    return pb_read(stream, dest->bytes, (size_t)size);
 1570|  1.16M|}
pb_decode.c:allocate_field:
  584|  31.7M|{    
  585|  31.7M|    void *ptr = *(void**)pData;
  586|       |    
  587|  31.7M|    if (data_size == 0 || array_size == 0)
  ------------------
  |  Branch (587:9): [True: 0, False: 31.7M]
  |  Branch (587:27): [True: 0, False: 31.7M]
  ------------------
  588|      0|        PB_RETURN_ERROR(stream, "invalid size");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  589|       |    
  590|       |#ifdef __AVR__
  591|       |    /* Workaround for AVR libc bug 53284: http://savannah.nongnu.org/bugs/?53284
  592|       |     * Realloc to size of 1 byte can cause corruption of the malloc structures.
  593|       |     */
  594|       |    if (data_size == 1 && array_size == 1)
  595|       |    {
  596|       |        data_size = 2;
  597|       |    }
  598|       |#endif
  599|       |
  600|       |    /* Check for multiplication overflows.
  601|       |     * This code avoids the costly division if the sizes are small enough.
  602|       |     * Multiplication is safe as long as only half of bits are set
  603|       |     * in either multiplicand.
  604|       |     */
  605|  31.7M|    {
  606|  31.7M|        const size_t check_limit = (size_t)1 << (sizeof(size_t) * 4);
  607|  31.7M|        if (data_size >= check_limit || array_size >= check_limit)
  ------------------
  |  Branch (607:13): [True: 0, False: 31.7M]
  |  Branch (607:41): [True: 0, False: 31.7M]
  ------------------
  608|      0|        {
  609|      0|            const size_t size_max = (size_t)-1;
  610|      0|            if (size_max / array_size < data_size)
  ------------------
  |  Branch (610:17): [True: 0, False: 0]
  ------------------
  611|      0|            {
  612|      0|                PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  613|      0|            }
  614|      0|        }
  615|  31.7M|    }
  616|       |    
  617|       |    /* Allocate new or expand previous allocation */
  618|       |    /* Note: on failure the old pointer will remain in the structure,
  619|       |     * the message must be freed by caller also on error return. */
  620|  31.7M|    ptr = pb_realloc(ptr, array_size * data_size);
  ------------------
  |  |    3|  31.7M|#define pb_realloc(ptr,size) realloc_with_check(ptr,size)
  ------------------
  621|  31.7M|    if (ptr == NULL)
  ------------------
  |  Branch (621:9): [True: 0, False: 31.7M]
  ------------------
  622|      0|        PB_RETURN_ERROR(stream, "realloc failed");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  623|       |    
  624|  31.7M|    *(void**)pData = ptr;
  625|       |    return true;
  626|  31.7M|}
pb_decode.c:pb_dec_string:
 1573|   104k|{
 1574|   104k|    uint32_t size;
 1575|   104k|    size_t alloc_size;
 1576|   104k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1577|       |
 1578|   104k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1578:9): [True: 21, False: 104k]
  ------------------
 1579|     21|        return false;
 1580|       |
 1581|   104k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1581:9): [True: 3, False: 104k]
  ------------------
 1582|      3|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  920|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1583|       |
 1584|       |    /* Space for null terminator */
 1585|   104k|    alloc_size = (size_t)(size + 1);
 1586|       |
 1587|   104k|    if (alloc_size < size)
  ------------------
  |  Branch (1587:9): [True: 0, False: 104k]
  ------------------
 1588|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1589|       |
 1590|   104k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|   104k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   104k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|   104k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1590:9): [True: 102k, False: 1.70k]
  ------------------
 1591|   102k|    {
 1592|       |#ifndef PB_ENABLE_MALLOC
 1593|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1594|       |#else
 1595|   102k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1595:13): [True: 70, False: 102k]
  ------------------
 1596|     70|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  920|     70|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     70|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 70]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1597|       |
 1598|   102k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1598:13): [True: 0, False: 102k]
  ------------------
 1599|      0|            return false;
 1600|   102k|        dest = *(pb_byte_t**)field->pData;
 1601|   102k|#endif
 1602|   102k|    }
 1603|  1.70k|    else
 1604|  1.70k|    {
 1605|  1.70k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1605:13): [True: 53, False: 1.65k]
  ------------------
 1606|     53|            PB_RETURN_ERROR(stream, "string overflow");
  ------------------
  |  |  920|     53|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     53|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 53]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1607|  1.70k|    }
 1608|       |    
 1609|   104k|    dest[size] = 0;
 1610|       |
 1611|   104k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1611:9): [True: 4, False: 104k]
  ------------------
 1612|      4|        return false;
 1613|       |
 1614|       |#ifdef PB_VALIDATE_UTF8
 1615|       |    if (!pb_validate_utf8((const char*)dest))
 1616|       |        PB_RETURN_ERROR(stream, "invalid utf8");
 1617|       |#endif
 1618|       |
 1619|   104k|    return true;
 1620|   104k|}
pb_decode.c:pb_dec_submessage:
 1623|   171k|{
 1624|   171k|    bool status = true;
 1625|   171k|    bool submsg_consumed = false;
 1626|   171k|    pb_istream_t substream;
 1627|       |
 1628|   171k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1628:9): [True: 132, False: 171k]
  ------------------
 1629|    132|        return false;
 1630|       |    
 1631|   171k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1631:9): [True: 0, False: 171k]
  ------------------
 1632|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1633|       |    
 1634|       |    /* Submessages can have a separate message-level callback that is called
 1635|       |     * before decoding the message. Typically it is used to set callback fields
 1636|       |     * inside oneofs. */
 1637|   171k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  325|   171k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   171k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  290|   342k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1637:9): [True: 0, False: 171k]
  |  Branch (1637:58): [True: 0, False: 0]
  ------------------
 1638|      0|    {
 1639|       |        /* Message callback is stored right before pSize. */
 1640|      0|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
 1641|      0|        if (callback->funcs.decode)
  ------------------
  |  Branch (1641:13): [True: 0, False: 0]
  ------------------
 1642|      0|        {
 1643|      0|            status = callback->funcs.decode(&substream, field, &callback->arg);
 1644|       |
 1645|      0|            if (substream.bytes_left == 0)
  ------------------
  |  Branch (1645:17): [True: 0, False: 0]
  ------------------
 1646|      0|            {
 1647|      0|                submsg_consumed = true;
 1648|      0|            }
 1649|      0|        }
 1650|      0|    }
 1651|       |
 1652|       |    /* Now decode the submessage contents */
 1653|   171k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1653:9): [True: 171k, False: 0]
  |  Branch (1653:19): [True: 171k, False: 0]
  ------------------
 1654|   171k|    {
 1655|   171k|        unsigned int flags = 0;
 1656|       |
 1657|       |        /* Static required/optional fields are already initialized by top-level
 1658|       |         * pb_decode(), no need to initialize them again. */
 1659|   171k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  323|   171k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   171k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  318|   342k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1659:13): [True: 10.7k, False: 160k]
  ------------------
 1660|  10.7k|            PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  324|  10.7k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  10.7k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  311|  10.7k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1660:13): [True: 10.7k, False: 0]
  ------------------
 1661|  10.7k|        {
 1662|  10.7k|            flags = PB_DECODE_NOINIT;
  ------------------
  |  |  110|  10.7k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1663|  10.7k|        }
 1664|       |
 1665|   171k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1666|   171k|    }
 1667|       |    
 1668|   171k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1668:9): [True: 0, False: 171k]
  ------------------
 1669|      0|        return false;
 1670|       |
 1671|   171k|    return status;
 1672|   171k|}
pb_decode.c:pb_dec_fixed_length_bytes:
 1675|  26.4M|{
 1676|  26.4M|    uint32_t size;
 1677|       |
 1678|  26.4M|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1678:9): [True: 2, False: 26.4M]
  ------------------
 1679|      2|        return false;
 1680|       |
 1681|  26.4M|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  339|  26.4M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1681:9): [True: 32, False: 26.4M]
  ------------------
 1682|     32|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  920|     32|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     32|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1683|       |
 1684|  26.4M|    if (size == 0)
  ------------------
  |  Branch (1684:9): [True: 25.4M, False: 1.01M]
  ------------------
 1685|  25.4M|    {
 1686|       |        /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */
 1687|  25.4M|        memset(field->pData, 0, (size_t)field->data_size);
 1688|  25.4M|        return true;
 1689|  25.4M|    }
 1690|       |
 1691|  1.01M|    if (size != field->data_size)
  ------------------
  |  Branch (1691:9): [True: 47, False: 1.01M]
  ------------------
 1692|     47|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  920|     47|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     47|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1693|       |
 1694|  1.01M|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1695|  1.01M|}
pb_decode.c:decode_pointer_field:
  646|  29.4M|{
  647|       |#ifndef PB_ENABLE_MALLOC
  648|       |    PB_UNUSED(wire_type);
  649|       |    PB_UNUSED(field);
  650|       |    PB_RETURN_ERROR(stream, "no malloc support");
  651|       |#else
  652|  29.4M|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  324|  29.4M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  29.4M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  653|  29.4M|    {
  654|  1.64M|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  308|  1.64M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (654:9): [True: 1.64M, False: 27.8M]
  ------------------
  655|  1.65M|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  309|  1.65M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (655:9): [True: 17.2k, False: 29.4M]
  ------------------
  656|  1.67M|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  313|  1.67M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (656:9): [True: 19.0k, False: 29.4M]
  ------------------
  657|  1.67M|            if (PB_LTYPE_IS_SUBMSG(field->type) && *(void**)field->pField != NULL)
  ------------------
  |  |  326|  3.35M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|  1.67M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  1.67M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  3.35M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 81.7k, False: 1.59M]
  |  |  ------------------
  |  |  327|  3.35M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|  1.59M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  1.59M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|  1.59M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 1.59M]
  |  |  ------------------
  ------------------
  |  Branch (657:52): [True: 41.7k, False: 40.0k]
  ------------------
  658|  41.7k|            {
  659|       |                /* Duplicate field, have to release the old allocation first. */
  660|       |                /* FIXME: Does this work correctly for oneofs? */
  661|  41.7k|                pb_release_single_field(field);
  662|  41.7k|            }
  663|       |        
  664|  1.67M|            if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|  1.67M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  1.67M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|  1.67M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (664:17): [True: 19.0k, False: 1.65M]
  ------------------
  665|  19.0k|            {
  666|  19.0k|                *(pb_size_t*)field->pSize = field->tag;
  667|  19.0k|            }
  668|       |
  669|  1.67M|            if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  325|  1.67M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  1.67M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  281|  3.35M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (669:17): [True: 79.9k, False: 1.59M]
  ------------------
  670|  1.59M|                PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  325|  1.59M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  1.59M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  277|  1.59M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (670:17): [True: 17.7k, False: 1.58M]
  ------------------
  671|  97.6k|            {
  672|       |                /* pb_dec_string and pb_dec_bytes handle allocation themselves */
  673|  97.6k|                field->pData = field->pField;
  674|  97.6k|                return decode_basic_field(stream, wire_type, field);
  675|  97.6k|            }
  676|  1.58M|            else
  677|  1.58M|            {
  678|  1.58M|                if (!allocate_field(stream, field->pField, field->data_size, 1))
  ------------------
  |  Branch (678:21): [True: 0, False: 1.58M]
  ------------------
  679|      0|                    return false;
  680|       |                
  681|  1.58M|                field->pData = *(void**)field->pField;
  682|  1.58M|                initialize_pointer_field(field->pData, field);
  683|  1.58M|                return decode_basic_field(stream, wire_type, field);
  684|  1.58M|            }
  685|       |    
  686|  27.8M|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  311|  27.8M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (686:9): [True: 27.8M, False: 1.67M]
  ------------------
  687|  27.8M|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (687:17): [True: 27.7M, False: 9.10k]
  ------------------
  688|  27.7M|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  325|  27.7M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  27.7M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  273|  27.7M|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (688:20): [True: 77.2k, False: 27.7M]
  ------------------
  689|  77.2k|            {
  690|       |                /* Packed array, multiple items come in at once. */
  691|  77.2k|                bool status = true;
  692|  77.2k|                pb_size_t *size = (pb_size_t*)field->pSize;
  693|  77.2k|                size_t allocated_size = *size;
  694|  77.2k|                pb_istream_t substream;
  695|       |                
  696|  77.2k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (696:21): [True: 46, False: 77.1k]
  ------------------
  697|     46|                    return false;
  698|       |                
  699|  13.9M|                while (substream.bytes_left)
  ------------------
  |  Branch (699:24): [True: 13.8M, False: 77.0k]
  ------------------
  700|  13.8M|                {
  701|  13.8M|                    if (*size == PB_SIZE_MAX)
  ------------------
  |  |  339|  13.8M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (701:25): [True: 8, False: 13.8M]
  ------------------
  702|      8|                    {
  703|      8|#ifndef PB_NO_ERRMSG
  704|      8|                        stream->errmsg = "too many array entries";
  705|      8|#endif
  706|      8|                        status = false;
  707|      8|                        break;
  708|      8|                    }
  709|       |
  710|  13.8M|                    if ((size_t)*size + 1 > allocated_size)
  ------------------
  |  Branch (710:25): [True: 1.15M, False: 12.7M]
  ------------------
  711|  1.15M|                    {
  712|       |                        /* Allocate more storage. This tries to guess the
  713|       |                         * number of remaining entries. Round the division
  714|       |                         * upwards. */
  715|  1.15M|                        size_t remain = (substream.bytes_left - 1) / field->data_size + 1;
  716|  1.15M|                        if (remain < PB_SIZE_MAX - allocated_size)
  ------------------
  |  |  339|  1.15M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (716:29): [True: 278k, False: 875k]
  ------------------
  717|   278k|                            allocated_size += remain;
  718|   875k|                        else
  719|   875k|                            allocated_size += 1;
  720|       |                        
  721|  1.15M|                        if (!allocate_field(&substream, field->pField, field->data_size, allocated_size))
  ------------------
  |  Branch (721:29): [True: 0, False: 1.15M]
  ------------------
  722|      0|                        {
  723|      0|                            status = false;
  724|      0|                            break;
  725|      0|                        }
  726|  1.15M|                    }
  727|       |
  728|       |                    /* Decode the array entry */
  729|  13.8M|                    field->pData = *(char**)field->pField + field->data_size * (*size);
  730|  13.8M|                    if (field->pData == NULL)
  ------------------
  |  Branch (730:25): [True: 0, False: 13.8M]
  ------------------
  731|      0|                    {
  732|       |                        /* Shouldn't happen, but satisfies static analyzers */
  733|      0|                        status = false;
  734|      0|                        break;
  735|      0|                    }
  736|  13.8M|                    initialize_pointer_field(field->pData, field);
  737|  13.8M|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (737:25): [True: 93, False: 13.8M]
  ------------------
  738|     93|                    {
  739|     93|                        status = false;
  740|     93|                        break;
  741|     93|                    }
  742|       |                    
  743|  13.8M|                    (*size)++;
  744|  13.8M|                }
  745|  77.1k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (745:21): [True: 0, False: 77.1k]
  ------------------
  746|      0|                    return false;
  747|       |                
  748|  77.1k|                return status;
  749|  77.1k|            }
  750|  27.7M|            else
  751|  27.7M|            {
  752|       |                /* Normal repeated field, i.e. only one item at a time. */
  753|  27.7M|                pb_size_t *size = (pb_size_t*)field->pSize;
  754|       |
  755|  27.7M|                if (*size == PB_SIZE_MAX)
  ------------------
  |  |  339|  27.7M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (755:21): [True: 1, False: 27.7M]
  ------------------
  756|      1|                    PB_RETURN_ERROR(stream, "too many array entries");
  ------------------
  |  |  920|      1|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      1|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  757|       |                
  758|  27.7M|                if (!allocate_field(stream, field->pField, field->data_size, (size_t)(*size + 1)))
  ------------------
  |  Branch (758:21): [True: 0, False: 27.7M]
  ------------------
  759|      0|                    return false;
  760|       |            
  761|  27.7M|                field->pData = *(char**)field->pField + field->data_size * (*size);
  762|  27.7M|                (*size)++;
  763|  27.7M|                initialize_pointer_field(field->pData, field);
  764|  27.7M|                return decode_basic_field(stream, wire_type, field);
  765|  27.7M|            }
  766|       |
  767|      0|        default:
  ------------------
  |  Branch (767:9): [True: 0, False: 29.4M]
  ------------------
  768|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  769|  29.4M|    }
  770|  29.4M|#endif
  771|  29.4M|}
pb_decode.c:initialize_pointer_field:
  630|  43.2M|{
  631|  43.2M|    if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  325|  43.2M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  43.2M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  281|  86.4M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (631:9): [True: 22.7k, False: 43.1M]
  ------------------
  632|  43.1M|        PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  325|  43.1M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  43.1M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  277|  43.1M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (632:9): [True: 1.14M, False: 42.0M]
  ------------------
  633|  1.17M|    {
  634|  1.17M|        *(void**)pItem = NULL;
  635|  1.17M|    }
  636|  42.0M|    else if (PB_LTYPE_IS_SUBMSG(field->type))
  ------------------
  |  |  326|  42.0M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|  42.0M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  42.0M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  84.0M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 160k, False: 41.8M]
  |  |  ------------------
  |  |  327|  42.0M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|  41.8M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  41.8M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|  41.8M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 41.8M]
  |  |  ------------------
  ------------------
  637|   160k|    {
  638|       |        /* We memset to zero so that any callbacks are set to NULL.
  639|       |         * Default values will be set by pb_dec_submessage(). */
  640|   160k|        memset(pItem, 0, field->data_size);
  641|   160k|    }
  642|  43.2M|}
pb_decode.c:pb_release_single_field:
 1265|  1.02M|{
 1266|  1.02M|    pb_type_t type;
 1267|  1.02M|    type = field->type;
 1268|       |
 1269|  1.02M|    if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|  1.02M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  1.02M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|  1.02M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (1269:9): [True: 48.4k, False: 979k]
  ------------------
 1270|  48.4k|    {
 1271|  48.4k|        if (*(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (1271:13): [True: 23.6k, False: 24.7k]
  ------------------
 1272|  23.6k|            return; /* This is not the current field in the union */
 1273|  48.4k|    }
 1274|       |
 1275|       |    /* Release anything contained inside an extension or submsg.
 1276|       |     * This has to be done even if the submsg itself is statically
 1277|       |     * allocated. */
 1278|  1.00M|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|  1.00M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  1.00M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|  1.00M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1278:9): [True: 8.22k, False: 995k]
  ------------------
 1279|  8.22k|    {
 1280|       |        /* Release fields from all extensions in the linked list */
 1281|  8.22k|        pb_extension_t *ext = *(pb_extension_t**)field->pData;
 1282|  14.9k|        while (ext != NULL)
  ------------------
  |  Branch (1282:16): [True: 6.69k, False: 8.22k]
  ------------------
 1283|  6.69k|        {
 1284|  6.69k|            pb_field_iter_t ext_iter;
 1285|  6.69k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (1285:17): [True: 6.69k, False: 0]
  ------------------
 1286|  6.69k|            {
 1287|  6.69k|                pb_release_single_field(&ext_iter);
 1288|  6.69k|            }
 1289|  6.69k|            ext = ext->next;
 1290|  6.69k|        }
 1291|  8.22k|    }
 1292|   995k|    else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|  1.99M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|   995k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|   995k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  1.99M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 137k, False: 857k]
  |  |  ------------------
  |  |  327|  1.99M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|   857k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|   857k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|   857k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 857k]
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|   137k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   137k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  320|   137k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1292:42): [True: 137k, False: 0]
  ------------------
 1293|   137k|    {
 1294|       |        /* Release fields in submessage or submsg array */
 1295|   137k|        pb_size_t count = 1;
 1296|       |        
 1297|   137k|        if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|   137k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   137k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|   137k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1297:13): [True: 125k, False: 12.4k]
  ------------------
 1298|   125k|        {
 1299|   125k|            field->pData = *(void**)field->pField;
 1300|   125k|        }
 1301|  12.4k|        else
 1302|  12.4k|        {
 1303|  12.4k|            field->pData = field->pField;
 1304|  12.4k|        }
 1305|       |        
 1306|   137k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  324|   137k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   137k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  311|   137k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1306:13): [True: 16.4k, False: 121k]
  ------------------
 1307|  16.4k|        {
 1308|  16.4k|            count = *(pb_size_t*)field->pSize;
 1309|       |
 1310|  16.4k|            if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  323|  16.4k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  16.4k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  318|  32.8k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1310:17): [True: 0, False: 16.4k]
  |  Branch (1310:54): [True: 0, False: 0]
  ------------------
 1311|      0|            {
 1312|       |                /* Protect against corrupted _count fields */
 1313|      0|                count = field->array_size;
 1314|      0|            }
 1315|  16.4k|        }
 1316|       |        
 1317|   137k|        if (field->pData)
  ------------------
  |  Branch (1317:13): [True: 96.4k, False: 41.3k]
  ------------------
 1318|  96.4k|        {
 1319|   269k|            for (; count > 0; count--)
  ------------------
  |  Branch (1319:20): [True: 173k, False: 96.4k]
  ------------------
 1320|   173k|            {
 1321|   173k|                pb_release(field->submsg_desc, field->pData);
 1322|   173k|                field->pData = (char*)field->pData + field->data_size;
 1323|   173k|            }
 1324|  96.4k|        }
 1325|   137k|    }
 1326|       |    
 1327|  1.00M|    if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|  1.00M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  1.00M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|  1.00M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1327:9): [True: 976k, False: 27.3k]
  ------------------
 1328|   976k|    {
 1329|   976k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  324|   976k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   976k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  311|  1.95M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1329:13): [True: 172k, False: 803k]
  ------------------
 1330|   172k|            (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  325|   172k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   172k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  281|   345k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (1330:14): [True: 8.22k, False: 164k]
  ------------------
 1331|   164k|             PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  325|   164k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   164k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                           PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  277|   164k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (1331:14): [True: 8.22k, False: 156k]
  ------------------
 1332|  16.4k|        {
 1333|       |            /* Release entries in repeated string or bytes array */
 1334|  16.4k|            void **pItem = *(void***)field->pField;
 1335|  16.4k|            pb_size_t count = *(pb_size_t*)field->pSize;
 1336|  1.18M|            for (; count > 0; count--)
  ------------------
  |  Branch (1336:20): [True: 1.17M, False: 16.4k]
  ------------------
 1337|  1.17M|            {
 1338|  1.17M|                pb_free(*pItem);
  ------------------
  |  |    4|  1.17M|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1339|  1.17M|                *pItem++ = NULL;
 1340|  1.17M|            }
 1341|  16.4k|        }
 1342|       |        
 1343|   976k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  324|   976k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   976k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  311|   976k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1343:13): [True: 172k, False: 803k]
  ------------------
 1344|   172k|        {
 1345|       |            /* We are going to release the array, so set the size to 0 */
 1346|   172k|            *(pb_size_t*)field->pSize = 0;
 1347|   172k|        }
 1348|       |        
 1349|       |        /* Release main pointer */
 1350|   976k|        pb_free(*(void**)field->pField);
  ------------------
  |  |    4|   976k|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1351|       |        *(void**)field->pField = NULL;
 1352|   976k|    }
 1353|  1.00M|}

pb_ostream_from_buffer:
   73|  2.84k|{
   74|  2.84k|    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|  2.84k|    stream.callback = &buf_write;
   83|  2.84k|#endif
   84|  2.84k|    stream.state = buf;
   85|  2.84k|    stream.max_size = bufsize;
   86|  2.84k|    stream.bytes_written = 0;
   87|  2.84k|#ifndef PB_NO_ERRMSG
   88|       |    stream.errmsg = NULL;
   89|  2.84k|#endif
   90|  2.84k|    return stream;
   91|  2.84k|}
pb_write:
   94|  39.9M|{
   95|  39.9M|    if (count > 0 && stream->callback != NULL)
  ------------------
  |  Branch (95:9): [True: 39.4M, False: 522k]
  |  Branch (95:22): [True: 34.5M, False: 4.92M]
  ------------------
   96|  34.5M|    {
   97|  34.5M|        if (stream->bytes_written + count < stream->bytes_written ||
  ------------------
  |  Branch (97:13): [True: 0, False: 34.5M]
  ------------------
   98|  34.5M|            stream->bytes_written + count > stream->max_size)
  ------------------
  |  Branch (98:13): [True: 170, False: 34.5M]
  ------------------
   99|    170|        {
  100|    170|            PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  920|    170|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|    170|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 170]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  101|    170|        }
  102|       |
  103|       |#ifdef PB_BUFFER_ONLY
  104|       |        if (!buf_write(stream, buf, count))
  105|       |            PB_RETURN_ERROR(stream, "io error");
  106|       |#else        
  107|  34.5M|        if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:13): [True: 0, False: 34.5M]
  ------------------
  108|      0|            PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|  34.5M|#endif
  110|  34.5M|    }
  111|       |    
  112|  39.9M|    stream->bytes_written += count;
  113|       |    return true;
  114|  39.9M|}
pb_encode:
  522|   106k|{
  523|   106k|    pb_field_iter_t iter;
  524|   106k|    if (!pb_field_iter_begin_const(&iter, fields, src_struct))
  ------------------
  |  Branch (524:9): [True: 40.3k, False: 66.2k]
  ------------------
  525|  40.3k|        return true; /* Empty message type */
  526|       |    
  527|   425k|    do {
  528|   425k|        if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|   425k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   425k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|   425k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (528:13): [True: 2.71k, False: 422k]
  ------------------
  529|  2.71k|        {
  530|       |            /* Special case for the extension field placeholder */
  531|  2.71k|            if (!encode_extension_field(stream, &iter))
  ------------------
  |  Branch (531:17): [True: 35, False: 2.68k]
  ------------------
  532|     35|                return false;
  533|  2.71k|        }
  534|   422k|        else
  535|   422k|        {
  536|       |            /* Regular field */
  537|   422k|            if (!encode_field(stream, &iter))
  ------------------
  |  Branch (537:17): [True: 180, False: 422k]
  ------------------
  538|    180|                return false;
  539|   422k|        }
  540|   425k|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (540:14): [True: 359k, False: 65.9k]
  ------------------
  541|       |    
  542|  65.9k|    return true;
  543|  66.2k|}
pb_encode_varint:
  617|  29.9M|{
  618|  29.9M|    if (value <= 0x7F)
  ------------------
  |  Branch (618:9): [True: 17.6M, False: 12.2M]
  ------------------
  619|  17.6M|    {
  620|       |        /* Fast path: single byte */
  621|  17.6M|        pb_byte_t byte = (pb_byte_t)value;
  622|  17.6M|        return pb_write(stream, &byte, 1);
  623|  17.6M|    }
  624|  12.2M|    else
  625|  12.2M|    {
  626|       |#ifdef PB_WITHOUT_64BIT
  627|       |        return pb_encode_varint_32(stream, value, 0);
  628|       |#else
  629|  12.2M|        return pb_encode_varint_32(stream, (uint32_t)value, (uint32_t)(value >> 32));
  630|  12.2M|#endif
  631|  12.2M|    }
  632|  29.9M|}
pb_encode_svarint:
  635|  4.13M|{
  636|  4.13M|    pb_uint64_t zigzagged;
  ------------------
  |  |   46|  4.13M|#define pb_uint64_t uint64_t
  ------------------
  637|  4.13M|    pb_uint64_t mask = ((pb_uint64_t)-1) >> 1; /* Satisfy clang -fsanitize=integer */
  ------------------
  |  |   46|  4.13M|#define pb_uint64_t uint64_t
  ------------------
  638|  4.13M|    if (value < 0)
  ------------------
  |  Branch (638:9): [True: 469k, False: 3.66M]
  ------------------
  639|   469k|        zigzagged = ~(((pb_uint64_t)value & mask) << 1);
  640|  3.66M|    else
  641|  3.66M|        zigzagged = (pb_uint64_t)value << 1;
  642|       |    
  643|  4.13M|    return pb_encode_varint(stream, zigzagged);
  644|  4.13M|}
pb_encode_fixed32:
  647|  18.2k|{
  648|  18.2k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
  649|       |    /* Fast path if we know that we're on little endian */
  650|  18.2k|    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|  18.2k|}
pb_encode_fixed64:
  664|  14.7k|{
  665|  14.7k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
  666|       |    /* Fast path if we know that we're on little endian */
  667|  14.7k|    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|  14.7k|}
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))
  ------------------
  |  |  325|  10.2M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  10.2M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  694|  10.2M|    {
  695|  2.95k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  265|  2.95k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (695:9): [True: 2.95k, False: 10.2M]
  ------------------
  696|   113k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  266|   113k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (696:9): [True: 110k, False: 10.1M]
  ------------------
  697|   155k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  267|   155k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (697:9): [True: 41.7k, False: 10.1M]
  ------------------
  698|   172k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  268|   172k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (698:9): [True: 16.9k, False: 10.2M]
  ------------------
  699|   172k|            wiretype = PB_WT_VARINT;
  700|   172k|            break;
  701|       |        
  702|  13.7k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  269|  13.7k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (702:9): [True: 13.7k, False: 10.2M]
  ------------------
  703|  13.7k|            wiretype = PB_WT_32BIT;
  704|  13.7k|            break;
  705|       |        
  706|  8.82k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  270|  8.82k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (706:9): [True: 8.82k, False: 10.2M]
  ------------------
  707|  8.82k|            wiretype = PB_WT_64BIT;
  708|  8.82k|            break;
  709|       |        
  710|   476k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  277|   476k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (710:9): [True: 476k, False: 9.76M]
  ------------------
  711|   531k|        case PB_LTYPE_STRING:
  ------------------
  |  |  281|   531k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (711:9): [True: 55.2k, False: 10.1M]
  ------------------
  712|   583k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  285|   583k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (712:9): [True: 51.9k, False: 10.1M]
  ------------------
  713|   583k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  290|   583k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (713:9): [True: 0, False: 10.2M]
  ------------------
  714|  10.0M|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  300|  10.0M|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (714:9): [True: 9.46M, False: 778k]
  ------------------
  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");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  720|  10.2M|    }
  721|       |    
  722|  10.2M|    return pb_encode_tag(stream, wiretype, field->tag);
  723|  10.2M|}
pb_encode_string:
  726|  9.99M|{
  727|  9.99M|    if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (727:9): [True: 8, False: 9.99M]
  ------------------
  728|      8|        return false;
  729|       |    
  730|  9.99M|    return pb_write(stream, buffer, size);
  731|  9.99M|}
pb_encode_submessage:
  734|  51.9k|{
  735|       |    /* First calculate the message size using a non-writing substream. */
  736|  51.9k|    pb_ostream_t substream = PB_OSTREAM_SIZING;
  ------------------
  |  |  126|  51.9k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  737|  51.9k|#if !defined(PB_NO_ENCODE_SIZE_CHECK) || PB_NO_ENCODE_SIZE_CHECK == 0
  738|  51.9k|    bool status;
  739|  51.9k|    size_t size;
  740|  51.9k|#endif
  741|       |    
  742|  51.9k|    if (!pb_encode(&substream, fields, src_struct))
  ------------------
  |  Branch (742:9): [True: 0, False: 51.9k]
  ------------------
  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|  51.9k|    if (!pb_encode_varint(stream, (pb_uint64_t)substream.bytes_written))
  ------------------
  |  Branch (750:9): [True: 21, False: 51.8k]
  ------------------
  751|     21|        return false;
  752|       |    
  753|  51.8k|    if (stream->callback == NULL)
  ------------------
  |  Branch (753:9): [True: 0, False: 51.8k]
  ------------------
  754|      0|        return pb_write(stream, NULL, substream.bytes_written); /* Just sizing */
  755|       |    
  756|  51.8k|    if (stream->bytes_written + substream.bytes_written > stream->max_size)
  ------------------
  |  Branch (756:9): [True: 45, False: 51.8k]
  ------------------
  757|     45|        PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  920|     45|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     45|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 45]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|  51.8k|    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|  51.8k|    substream.callback = stream->callback;
  766|  51.8k|    substream.state = stream->state;
  767|  51.8k|    substream.max_size = size;
  768|  51.8k|    substream.bytes_written = 0;
  769|  51.8k|#ifndef PB_NO_ERRMSG
  770|  51.8k|    substream.errmsg = NULL;
  771|  51.8k|#endif
  772|       |    
  773|  51.8k|    status = pb_encode(&substream, fields, src_struct);
  774|       |    
  775|  51.8k|    stream->bytes_written += substream.bytes_written;
  776|  51.8k|    stream->state = substream.state;
  777|  51.8k|#ifndef PB_NO_ERRMSG
  778|  51.8k|    stream->errmsg = substream.errmsg;
  779|  51.8k|#endif
  780|       |    
  781|  51.8k|    if (substream.bytes_written != size)
  ------------------
  |  Branch (781:9): [True: 0, False: 51.8k]
  ------------------
  782|      0|        PB_RETURN_ERROR(stream, "submsg size changed");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  783|       |
  784|  51.8k|    return status;
  785|  51.8k|#endif
  786|  51.8k|}
pb_encode.c:buf_write:
   54|  34.5M|{
   55|  34.5M|    pb_byte_t *dest = (pb_byte_t*)stream->state;
   56|  34.5M|    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|  34.5M|    if (buf != NULL)
  ------------------
  |  Branch (64:9): [True: 34.5M, False: 0]
  ------------------
   65|  34.5M|    {
   66|  34.5M|        memcpy(dest, buf, count * sizeof(pb_byte_t));
   67|  34.5M|    }
   68|       |
   69|       |    return true;
   70|  34.5M|}
pb_encode.c:encode_extension_field:
  497|  2.71k|{
  498|  2.71k|    const pb_extension_t *extension = *(const pb_extension_t* const *)field->pData;
  499|       |
  500|  5.39k|    while (extension)
  ------------------
  |  Branch (500:12): [True: 2.71k, False: 2.68k]
  ------------------
  501|  2.71k|    {
  502|  2.71k|        bool status;
  503|  2.71k|        if (extension->type->encode)
  ------------------
  |  Branch (503:13): [True: 0, False: 2.71k]
  ------------------
  504|      0|            status = extension->type->encode(stream, extension);
  505|  2.71k|        else
  506|  2.71k|            status = default_extension_encoder(stream, extension);
  507|       |
  508|  2.71k|        if (!status)
  ------------------
  |  Branch (508:13): [True: 35, False: 2.68k]
  ------------------
  509|     35|            return false;
  510|       |        
  511|  2.68k|        extension = extension->next;
  512|  2.68k|    }
  513|       |    
  514|  2.68k|    return true;
  515|  2.71k|}
pb_encode.c:default_extension_encoder:
  484|  2.71k|{
  485|  2.71k|    pb_field_iter_t iter;
  486|       |
  487|  2.71k|    if (!pb_field_iter_begin_extension_const(&iter, extension))
  ------------------
  |  Branch (487:9): [True: 0, False: 2.71k]
  ------------------
  488|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|  2.71k|    return encode_field(stream, &iter);
  491|  2.71k|}
pb_encode.c:encode_field:
  428|   425k|{
  429|       |    /* Check field presence */
  430|   425k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|   425k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   425k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|   425k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (430:9): [True: 8.32k, False: 417k]
  ------------------
  431|  8.32k|    {
  432|  8.32k|        if (*(const pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (432:13): [True: 7.90k, False: 426]
  ------------------
  433|  7.90k|        {
  434|       |            /* Different type oneof field */
  435|  7.90k|            return true;
  436|  7.90k|        }
  437|  8.32k|    }
  438|   417k|    else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  324|   417k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   417k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  309|   417k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (438:14): [True: 102k, False: 314k]
  ------------------
  439|   102k|    {
  440|   102k|        if (field->pSize)
  ------------------
  |  Branch (440:13): [True: 5.38k, False: 97.4k]
  ------------------
  441|  5.38k|        {
  442|  5.38k|            if (safe_read_bool(field->pSize) == false)
  ------------------
  |  Branch (442:17): [True: 5.19k, False: 182]
  ------------------
  443|  5.19k|            {
  444|       |                /* Missing optional field */
  445|  5.19k|                return true;
  446|  5.19k|            }
  447|  5.38k|        }
  448|  97.4k|        else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  323|  97.4k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  97.4k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  318|  97.4k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (448:18): [True: 0, False: 97.4k]
  ------------------
  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|   102k|    }
  455|       |
  456|   412k|    if (!field->pData)
  ------------------
  |  Branch (456:9): [True: 144k, False: 268k]
  ------------------
  457|   144k|    {
  458|   144k|        if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  324|   144k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   144k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  308|   144k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (458:13): [True: 0, False: 144k]
  ------------------
  459|      0|            PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  460|       |
  461|       |        /* Pointer field set to NULL */
  462|   144k|        return true;
  463|   144k|    }
  464|       |
  465|       |    /* Then encode field contents */
  466|   268k|    if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|   268k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   268k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  320|   268k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (466:9): [True: 0, False: 268k]
  ------------------
  467|      0|    {
  468|      0|        return encode_callback_field(stream, field);
  469|      0|    }
  470|   268k|    else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  324|   268k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   268k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  311|   268k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (470:14): [True: 5.50k, False: 262k]
  ------------------
  471|  5.50k|    {
  472|  5.50k|        return encode_array(stream, field);
  473|  5.50k|    }
  474|   262k|    else
  475|   262k|    {
  476|   262k|        return encode_basic_field(stream, field);
  477|   262k|    }
  478|   268k|}
pb_encode.c:safe_read_bool:
  125|  8.33k|{
  126|  8.33k|    const char *p = (const char *)pSize;
  127|  8.33k|    size_t i;
  128|  15.0k|    for (i = 0; i < sizeof(bool); i++)
  ------------------
  |  Branch (128:17): [True: 8.33k, False: 6.76k]
  ------------------
  129|  8.33k|    {
  130|  8.33k|        if (p[i] != 0)
  ------------------
  |  Branch (130:13): [True: 1.57k, False: 6.76k]
  ------------------
  131|  1.57k|            return true;
  132|  8.33k|    }
  133|  6.76k|    return false;
  134|  8.33k|}
pb_encode.c:encode_array:
  138|  5.50k|{
  139|  5.50k|    pb_size_t i;
  140|  5.50k|    pb_size_t count;
  141|  5.50k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  142|  5.50k|    size_t size;
  143|  5.50k|#endif
  144|       |
  145|  5.50k|    count = *(pb_size_t*)field->pSize;
  146|       |
  147|  5.50k|    if (count == 0)
  ------------------
  |  Branch (147:9): [True: 0, False: 5.50k]
  ------------------
  148|      0|        return true;
  149|       |
  150|  5.50k|    if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  323|  5.50k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  5.50k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  319|  11.0k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (150:9): [True: 0, False: 5.50k]
  |  Branch (150:54): [True: 0, False: 0]
  ------------------
  151|      0|        PB_RETURN_ERROR(stream, "array max size exceeded");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  152|       |    
  153|  5.50k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  154|       |    /* We always pack arrays if the datatype allows it. */
  155|  5.50k|    if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  325|  5.50k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  5.50k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  273|  5.50k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (155:9): [True: 2.55k, False: 2.94k]
  ------------------
  156|  2.55k|    {
  157|  2.55k|        if (!pb_encode_tag(stream, PB_WT_STRING, field->tag))
  ------------------
  |  Branch (157:13): [True: 2, False: 2.55k]
  ------------------
  158|      2|            return false;
  159|       |        
  160|       |        /* Determine the total size of packed array. */
  161|  2.55k|        if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  325|  2.55k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  2.55k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  269|  2.55k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (161:13): [True: 366, False: 2.19k]
  ------------------
  162|    366|        {
  163|    366|            size = 4 * (size_t)count;
  164|    366|        }
  165|  2.19k|        else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  325|  2.19k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  2.19k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  270|  2.19k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (165:18): [True: 217, False: 1.97k]
  ------------------
  166|    217|        {
  167|    217|            size = 8 * (size_t)count;
  168|    217|        }
  169|  1.97k|        else
  170|  1.97k|        { 
  171|  1.97k|            pb_ostream_t sizestream = PB_OSTREAM_SIZING;
  ------------------
  |  |  126|  1.97k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  172|  1.97k|            void *pData_orig = field->pData;
  173|  4.73M|            for (i = 0; i < count; i++)
  ------------------
  |  Branch (173:25): [True: 4.73M, False: 1.97k]
  ------------------
  174|  4.73M|            {
  175|  4.73M|                if (!pb_enc_varint(&sizestream, field))
  ------------------
  |  Branch (175:21): [True: 0, False: 4.73M]
  ------------------
  176|      0|                    PB_RETURN_ERROR(stream, PB_GET_ERROR(&sizestream));
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  |  Branch (916:92): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  177|  4.73M|                field->pData = (char*)field->pData + field->data_size;
  178|  4.73M|            }
  179|  1.97k|            field->pData = pData_orig;
  180|  1.97k|            size = sizestream.bytes_written;
  181|  1.97k|        }
  182|       |        
  183|  2.55k|        if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (183:13): [True: 3, False: 2.55k]
  ------------------
  184|      3|            return false;
  185|       |        
  186|  2.55k|        if (stream->callback == NULL)
  ------------------
  |  Branch (186:13): [True: 0, False: 2.55k]
  ------------------
  187|      0|            return pb_write(stream, NULL, size); /* Just sizing.. */
  188|       |        
  189|       |        /* Write the data */
  190|  4.74M|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (190:21): [True: 4.74M, False: 2.54k]
  ------------------
  191|  4.74M|        {
  192|  4.74M|            if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  325|  4.74M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  4.74M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  269|  9.48M|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  325|  4.73M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  4.73M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  270|  4.73M|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (192:17): [True: 4.43k, False: 4.73M]
  |  Branch (192:62): [True: 5.89k, False: 4.73M]
  ------------------
  193|  10.3k|            {
  194|  10.3k|                if (!pb_enc_fixed(stream, field))
  ------------------
  |  Branch (194:21): [True: 3, False: 10.3k]
  ------------------
  195|      3|                    return false;
  196|  10.3k|            }
  197|  4.73M|            else
  198|  4.73M|            {
  199|  4.73M|                if (!pb_enc_varint(stream, field))
  ------------------
  |  Branch (199:21): [True: 5, False: 4.73M]
  ------------------
  200|      5|                    return false;
  201|  4.73M|            }
  202|       |
  203|  4.74M|            field->pData = (char*)field->pData + field->data_size;
  204|  4.74M|        }
  205|  2.55k|    }
  206|  2.94k|    else /* Unpacked fields */
  207|  2.94k|#endif
  208|  2.94k|    {
  209|  9.97M|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (209:21): [True: 9.97M, False: 2.91k]
  ------------------
  210|  9.97M|        {
  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.97M|            if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  323|  9.97M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  9.97M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  319|  19.9M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (215:17): [True: 9.97M, False: 0]
  ------------------
  216|  9.97M|                (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  325|  9.97M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  9.97M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  281|  19.9M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (216:18): [True: 10.6k, False: 9.96M]
  ------------------
  217|  9.96M|                 PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  325|  9.96M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  9.96M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                               PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  277|  9.96M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (217:18): [True: 473k, False: 9.49M]
  ------------------
  218|   484k|            {
  219|   484k|                bool status;
  220|   484k|                void *pData_orig = field->pData;
  221|   484k|                field->pData = *(void* const*)field->pData;
  222|       |
  223|   484k|                if (!field->pData)
  ------------------
  |  Branch (223:21): [True: 0, False: 484k]
  ------------------
  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|   484k|                else
  230|   484k|                {
  231|   484k|                    status = encode_basic_field(stream, field);
  232|   484k|                }
  233|       |
  234|   484k|                field->pData = pData_orig;
  235|       |
  236|   484k|                if (!status)
  ------------------
  |  Branch (236:21): [True: 7, False: 484k]
  ------------------
  237|      7|                    return false;
  238|   484k|            }
  239|  9.49M|            else
  240|  9.49M|            {
  241|  9.49M|                if (!encode_basic_field(stream, field))
  ------------------
  |  Branch (241:21): [True: 20, False: 9.49M]
  ------------------
  242|     20|                    return false;
  243|  9.49M|            }
  244|  9.97M|            field->pData = (char*)field->pData + field->data_size;
  245|  9.97M|        }
  246|  2.94k|    }
  247|       |    
  248|  5.46k|    return true;
  249|  5.50k|}
pb_encode.c:pb_enc_varint:
  798|  9.63M|{
  799|  9.63M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  325|  9.63M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  9.63M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  267|  9.63M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (799:9): [True: 842k, False: 8.79M]
  ------------------
  800|   842k|    {
  801|       |        /* Perform unsigned integer extension */
  802|   842k|        pb_uint64_t value = 0;
  ------------------
  |  |   46|   842k|#define pb_uint64_t uint64_t
  ------------------
  803|       |
  804|   842k|        if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (804:13): [True: 5.52k, False: 836k]
  ------------------
  805|  5.52k|            value = *(const uint_least8_t*)field->pData;
  806|   836k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (806:18): [True: 5.52k, False: 831k]
  ------------------
  807|  5.52k|            value = *(const uint_least16_t*)field->pData;
  808|   831k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (808:18): [True: 480k, False: 351k]
  ------------------
  809|   480k|            value = *(const uint32_t*)field->pData;
  810|   351k|        else if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (810:18): [True: 351k, False: 0]
  ------------------
  811|   351k|            value = *(const pb_uint64_t*)field->pData;
  812|      0|        else
  813|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  814|       |
  815|   842k|        return pb_encode_varint(stream, value);
  816|   842k|    }
  817|  8.79M|    else
  818|  8.79M|    {
  819|       |        /* Perform signed integer extension */
  820|  8.79M|        pb_int64_t value = 0;
  ------------------
  |  |   45|  8.79M|#define pb_int64_t int64_t
  ------------------
  821|       |
  822|  8.79M|        if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (822:13): [True: 1.79M, False: 6.99M]
  ------------------
  823|  1.79M|            value = *(const int_least8_t*)field->pData;
  824|  6.99M|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (824:18): [True: 11.0k, False: 6.98M]
  ------------------
  825|  11.0k|            value = *(const int_least16_t*)field->pData;
  826|  6.98M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (826:18): [True: 2.29M, False: 4.68M]
  ------------------
  827|  2.29M|            value = *(const int32_t*)field->pData;
  828|  4.68M|        else if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (828:18): [True: 4.68M, False: 0]
  ------------------
  829|  4.68M|            value = *(const pb_int64_t*)field->pData;
  830|      0|        else
  831|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  832|       |
  833|  8.79M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  325|  8.79M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  8.79M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  268|  8.79M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (833:13): [True: 4.13M, False: 4.65M]
  ------------------
  834|  4.13M|            return pb_encode_svarint(stream, value);
  835|       |#ifdef PB_WITHOUT_64BIT
  836|       |        else if (value < 0)
  837|       |            return pb_encode_varint_32(stream, (uint32_t)value, (uint32_t)-1);
  838|       |#endif
  839|  4.65M|        else
  840|  4.65M|            return pb_encode_varint(stream, (pb_uint64_t)value);
  841|       |
  842|  8.79M|    }
  843|  9.63M|}
pb_encode.c:pb_enc_fixed:
  846|  32.9k|{
  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|  32.9k|    if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (854:9): [True: 18.2k, False: 14.7k]
  ------------------
  855|  18.2k|    {
  856|  18.2k|        return pb_encode_fixed32(stream, field->pData);
  857|  18.2k|    }
  858|  14.7k|#ifndef PB_WITHOUT_64BIT
  859|  14.7k|    else if (field->data_size == sizeof(uint64_t))
  ------------------
  |  Branch (859:14): [True: 14.7k, False: 0]
  ------------------
  860|  14.7k|    {
  861|  14.7k|        return pb_encode_fixed64(stream, field->pData);
  862|  14.7k|    }
  863|      0|#endif
  864|      0|    else
  865|      0|    {
  866|       |        PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  867|      0|    }
  868|  32.9k|}
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))
  ------------------
  |  |  325|  10.2M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  10.2M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  383|  10.2M|    {
  384|  2.95k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  265|  2.95k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (384:9): [True: 2.95k, False: 10.2M]
  ------------------
  385|  2.95k|            return pb_enc_bool(stream, field);
  386|       |
  387|   110k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  266|   110k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (387:9): [True: 110k, False: 10.1M]
  ------------------
  388|   152k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  267|   152k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (388:9): [True: 41.7k, False: 10.1M]
  ------------------
  389|   169k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  268|   169k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (389:9): [True: 16.9k, False: 10.2M]
  ------------------
  390|   169k|            return pb_enc_varint(stream, field);
  391|       |
  392|  13.7k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  269|  13.7k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (392:9): [True: 13.7k, False: 10.2M]
  ------------------
  393|  22.6k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  270|  22.6k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (393:9): [True: 8.82k, False: 10.2M]
  ------------------
  394|  22.6k|            return pb_enc_fixed(stream, field);
  395|       |
  396|   476k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  277|   476k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (396:9): [True: 476k, False: 9.76M]
  ------------------
  397|   476k|            return pb_enc_bytes(stream, field);
  398|       |
  399|  55.2k|        case PB_LTYPE_STRING:
  ------------------
  |  |  281|  55.2k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (399:9): [True: 55.2k, False: 10.1M]
  ------------------
  400|  55.2k|            return pb_enc_string(stream, field);
  401|       |
  402|  51.9k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  285|  51.9k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (402:9): [True: 51.9k, False: 10.1M]
  ------------------
  403|  51.9k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  290|  51.9k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (403:9): [True: 0, False: 10.2M]
  ------------------
  404|  51.9k|            return pb_enc_submessage(stream, field);
  405|       |
  406|  9.46M|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  300|  9.46M|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (406:9): [True: 9.46M, False: 778k]
  ------------------
  407|  9.46M|            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");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  411|  10.2M|    }
  412|  10.2M|}
pb_encode.c:pb_enc_bool:
  791|  2.95k|{
  792|  2.95k|    uint32_t value = safe_read_bool(field->pData) ? 1 : 0;
  ------------------
  |  Branch (792:22): [True: 1.38k, False: 1.56k]
  ------------------
  793|  2.95k|    PB_UNUSED(field);
  ------------------
  |  |  169|  2.95k|#define PB_UNUSED(x) (void)(x)
  ------------------
  794|  2.95k|    return pb_encode_varint(stream, value);
  795|  2.95k|}
pb_encode.c:pb_enc_bytes:
  871|   476k|{
  872|   476k|    const pb_bytes_array_t *bytes = NULL;
  873|       |
  874|   476k|    bytes = (const pb_bytes_array_t*)field->pData;
  875|       |    
  876|   476k|    if (bytes == NULL)
  ------------------
  |  Branch (876:9): [True: 0, False: 476k]
  ------------------
  877|      0|    {
  878|       |        /* Treat null pointer as an empty bytes field */
  879|      0|        return pb_encode_string(stream, NULL, 0);
  880|      0|    }
  881|       |    
  882|   476k|    if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  323|   476k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   476k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  318|   953k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (882:9): [True: 0, False: 476k]
  ------------------
  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");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  886|      0|    }
  887|       |    
  888|   476k|    return pb_encode_string(stream, bytes->bytes, (size_t)bytes->size);
  889|   476k|}
pb_encode.c:pb_enc_string:
  892|  55.2k|{
  893|  55.2k|    size_t size = 0;
  894|  55.2k|    size_t max_size = (size_t)field->data_size;
  895|  55.2k|    const char *str = (const char*)field->pData;
  896|       |    
  897|  55.2k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|  55.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  55.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|  55.2k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (897:9): [True: 55.1k, False: 182]
  ------------------
  898|  55.1k|    {
  899|  55.1k|        max_size = (size_t)-1;
  900|  55.1k|    }
  901|    182|    else
  902|    182|    {
  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|    182|        if (max_size == 0)
  ------------------
  |  Branch (908:13): [True: 0, False: 182]
  ------------------
  909|      0|            PB_RETURN_ERROR(stream, "zero-length string");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  910|       |
  911|    182|        max_size -= 1;
  912|    182|    }
  913|       |
  914|       |
  915|  55.2k|    if (str == NULL)
  ------------------
  |  Branch (915:9): [True: 0, False: 55.2k]
  ------------------
  916|      0|    {
  917|      0|        size = 0; /* Treat null pointer as an empty string */
  918|      0|    }
  919|  55.2k|    else
  920|  55.2k|    {
  921|  55.2k|        const char *p = str;
  922|       |
  923|       |        /* strnlen() is not always available, so just use a loop */
  924|   302k|        while (size < max_size && *p != '\0')
  ------------------
  |  Branch (924:16): [True: 302k, False: 15]
  |  Branch (924:35): [True: 247k, False: 55.2k]
  ------------------
  925|   247k|        {
  926|   247k|            size++;
  927|   247k|            p++;
  928|   247k|        }
  929|       |
  930|  55.2k|        if (*p != '\0')
  ------------------
  |  Branch (930:13): [True: 0, False: 55.2k]
  ------------------
  931|      0|        {
  932|      0|            PB_RETURN_ERROR(stream, "unterminated string");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  933|      0|        }
  934|  55.2k|    }
  935|       |
  936|       |#ifdef PB_VALIDATE_UTF8
  937|       |    if (!pb_validate_utf8(str))
  938|       |        PB_RETURN_ERROR(stream, "invalid utf8");
  939|       |#endif
  940|       |
  941|  55.2k|    return pb_encode_string(stream, (const pb_byte_t*)str, size);
  942|  55.2k|}
pb_encode.c:pb_enc_submessage:
  945|  51.9k|{
  946|  51.9k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (946:9): [True: 0, False: 51.9k]
  ------------------
  947|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  948|       |
  949|  51.9k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  325|  51.9k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  51.9k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  290|   103k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (949:9): [True: 0, False: 51.9k]
  |  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|  51.9k|    return pb_encode_submessage(stream, field->submsg_desc, field->pData);
  961|  51.9k|}
pb_encode.c:pb_enc_fixed_length_bytes:
  964|  9.46M|{
  965|  9.46M|    return pb_encode_string(stream, (const pb_byte_t*)field->pData, (size_t)field->data_size);
  966|  9.46M|}
pb_encode.c:pb_encode_varint_32:
  583|  12.2M|{
  584|  12.2M|    size_t i = 0;
  585|  12.2M|    pb_byte_t buffer[10];
  586|  12.2M|    pb_byte_t byte = (pb_byte_t)(low & 0x7F);
  587|  12.2M|    low >>= 7;
  588|       |
  589|  27.0M|    while (i < 4 && (low != 0 || high != 0))
  ------------------
  |  Branch (589:12): [True: 26.2M, False: 759k]
  |  Branch (589:22): [True: 14.8M, False: 11.4M]
  |  Branch (589:34): [True: 4.15k, False: 11.4M]
  ------------------
  590|  14.8M|    {
  591|  14.8M|        byte |= 0x80;
  592|  14.8M|        buffer[i++] = byte;
  593|  14.8M|        byte = (pb_byte_t)(low & 0x7F);
  594|  14.8M|        low >>= 7;
  595|  14.8M|    }
  596|       |
  597|  12.2M|    if (high)
  ------------------
  |  Branch (597:9): [True: 724k, False: 11.5M]
  ------------------
  598|   724k|    {
  599|   724k|        byte = (pb_byte_t)(byte | ((high & 0x07) << 4));
  600|   724k|        high >>= 3;
  601|       |
  602|  3.98M|        while (high)
  ------------------
  |  Branch (602:16): [True: 3.25M, False: 724k]
  ------------------
  603|  3.25M|        {
  604|  3.25M|            byte |= 0x80;
  605|  3.25M|            buffer[i++] = byte;
  606|  3.25M|            byte = (pb_byte_t)(high & 0x7F);
  607|  3.25M|            high >>= 7;
  608|  3.25M|        }
  609|   724k|    }
  610|       |
  611|  12.2M|    buffer[i++] = byte;
  612|       |
  613|  12.2M|    return pb_write(stream, buffer, i);
  614|  12.2M|}

malloc_with_check:
   58|  1.73M|{
   59|  1.73M|    const size_t check2 = CHECK2;
  ------------------
  |  |   18|  1.73M|#define CHECK2 ((size_t)0x600DCAFE)
  ------------------
   60|  1.73M|    char *buf = NULL;
   61|       |
   62|  1.73M|    if (size <= g_max_alloc_bytes - g_alloc_bytes)
  ------------------
  |  Branch (62:9): [True: 1.73M, False: 0]
  ------------------
   63|  1.73M|    {
   64|  1.73M|        buf = malloc(round_blocksize(size + GUARD_SIZE));
  ------------------
  |  |   15|  1.73M|#define GUARD_SIZE (sizeof(size_t)*3)
  ------------------
   65|  1.73M|    }
   66|       |
   67|  1.73M|    if (buf)
  ------------------
  |  Branch (67:9): [True: 1.73M, False: 0]
  ------------------
   68|  1.73M|    {
   69|  1.73M|        ((size_t*)buf)[0] = size;
   70|  1.73M|        ((size_t*)buf)[1] = CHECK1;
  ------------------
  |  |   17|  1.73M|#define CHECK1 ((size_t)0xDEADBEEF)
  ------------------
   71|  1.73M|        memcpy(buf + PREFIX_SIZE + size, &check2, sizeof(check2));
  ------------------
  |  |   16|  1.73M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   72|       |
   73|  1.73M|        g_alloc_count++;
   74|  1.73M|        g_alloc_bytes += size;
   75|  1.73M|        if (DEBUG_MALLOC) fprintf(stderr, "Alloc 0x%04x/%u\n", (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   25|  1.73M|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (25:22): [Folded, False: 1.73M]
  |  |  ------------------
  ------------------
                      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.73M|        return buf + PREFIX_SIZE;
  ------------------
  |  |   16|  1.73M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   77|  1.73M|    }
   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.73M|}
free_with_check:
   87|  2.15M|{
   88|  2.15M|    if (mem)
  ------------------
  |  Branch (88:9): [True: 1.73M, False: 428k]
  ------------------
   89|  1.73M|    {
   90|  1.73M|        char *buf = (char*)mem - PREFIX_SIZE;
  ------------------
  |  |   16|  1.73M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   91|  1.73M|        size_t check2 = 0;
   92|  1.73M|        size_t size = ((size_t*)buf)[0];
   93|  1.73M|        if (DEBUG_MALLOC) fprintf(stderr, "Release 0x%04x/%u\n", (unsigned)(uintptr_t)mem, (unsigned)size);
  ------------------
  |  |   25|  1.73M|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (25:22): [Folded, False: 1.73M]
  |  |  ------------------
  ------------------
   94|  1.73M|        assert(((size_t*)buf)[1] == CHECK1);
  ------------------
  |  Branch (94:9): [True: 0, False: 1.73M]
  |  Branch (94:9): [True: 1.73M, False: 0]
  ------------------
   95|  1.73M|        memcpy(&check2, buf + PREFIX_SIZE + size, sizeof(check2));
  ------------------
  |  |   16|  1.73M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   96|  1.73M|        assert(check2 == CHECK2);
  ------------------
  |  Branch (96:9): [True: 0, False: 1.73M]
  |  Branch (96:9): [True: 1.73M, False: 0]
  ------------------
   97|  1.73M|        assert(g_alloc_count > 0);
  ------------------
  |  Branch (97:9): [True: 0, False: 1.73M]
  |  Branch (97:9): [True: 1.73M, False: 0]
  ------------------
   98|  1.73M|        assert(g_alloc_bytes >= size);
  ------------------
  |  Branch (98:9): [True: 0, False: 1.73M]
  |  Branch (98:9): [True: 1.73M, False: 0]
  ------------------
   99|  1.73M|        ((size_t*)buf)[1] = 0;
  100|  1.73M|        memset(buf + PREFIX_SIZE + size, 0, sizeof(check2));
  ------------------
  |  |   16|  1.73M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  101|  1.73M|        g_alloc_count--;
  102|  1.73M|        g_alloc_bytes -= size;
  103|  1.73M|        free(buf);
  104|  1.73M|    }
  105|  2.15M|}
realloc_with_check:
  109|  31.7M|{
  110|  31.7M|    if (!ptr && size)
  ------------------
  |  Branch (110:9): [True: 1.71M, False: 30.0M]
  |  Branch (110:17): [True: 1.71M, False: 0]
  ------------------
  111|  1.71M|    {
  112|       |        /* Allocate new block and write guard values */
  113|  1.71M|        return malloc_with_check(size);
  114|  1.71M|    }
  115|  30.0M|    else if (ptr && size)
  ------------------
  |  Branch (115:14): [True: 30.0M, False: 0]
  |  Branch (115:21): [True: 30.0M, False: 0]
  ------------------
  116|  30.0M|    {
  117|       |        /* Change block size */
  118|  30.0M|        char *buf = (char*)ptr - PREFIX_SIZE;
  ------------------
  |  |   16|  30.0M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  119|  30.0M|        size_t check2 = 0;
  120|  30.0M|        size_t oldsize = ((size_t*)buf)[0];
  121|  30.0M|        assert(((size_t*)buf)[1] == CHECK1);
  ------------------
  |  Branch (121:9): [True: 0, False: 30.0M]
  |  Branch (121:9): [True: 30.0M, False: 0]
  ------------------
  122|  30.0M|        memcpy(&check2, buf + PREFIX_SIZE + oldsize, sizeof(check2));
  ------------------
  |  |   16|  30.0M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  123|  30.0M|        assert(check2 == CHECK2);
  ------------------
  |  Branch (123:9): [True: 0, False: 30.0M]
  |  Branch (123:9): [True: 30.0M, False: 0]
  ------------------
  124|  30.0M|        assert(g_alloc_count > 0);
  ------------------
  |  Branch (124:9): [True: 0, False: 30.0M]
  |  Branch (124:9): [True: 30.0M, False: 0]
  ------------------
  125|  30.0M|        assert(g_alloc_bytes >= oldsize);
  ------------------
  |  Branch (125:9): [True: 0, False: 30.0M]
  |  Branch (125:9): [True: 30.0M, False: 0]
  ------------------
  126|       |
  127|  30.0M|        if (size <= g_max_alloc_bytes - (g_alloc_bytes - oldsize))
  ------------------
  |  Branch (127:13): [True: 30.0M, False: 0]
  ------------------
  128|  30.0M|        {
  129|  30.0M|            size_t new_rounded = round_blocksize(size + GUARD_SIZE);
  ------------------
  |  |   15|  30.0M|#define GUARD_SIZE (sizeof(size_t)*3)
  ------------------
  130|  30.0M|            size_t old_rounded = round_blocksize(oldsize + GUARD_SIZE);
  ------------------
  |  |   15|  30.0M|#define GUARD_SIZE (sizeof(size_t)*3)
  ------------------
  131|       |
  132|  30.0M|            if (new_rounded != old_rounded)
  ------------------
  |  Branch (132:17): [True: 318k, False: 29.6M]
  ------------------
  133|   318k|            {
  134|   318k|                buf = realloc(buf, new_rounded);
  135|   318k|            }
  136|  30.0M|        }
  137|      0|        else
  138|      0|        {
  139|      0|            buf = NULL;
  140|      0|        }
  141|       |
  142|  30.0M|        if (!buf)
  ------------------
  |  Branch (142:13): [True: 0, False: 30.0M]
  ------------------
  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.0M|        ((size_t*)buf)[0] = size;
  149|  30.0M|        ((size_t*)buf)[1] = CHECK1;
  ------------------
  |  |   17|  30.0M|#define CHECK1 ((size_t)0xDEADBEEF)
  ------------------
  150|  30.0M|        memcpy(buf + PREFIX_SIZE + size, &check2, sizeof(check2));
  ------------------
  |  |   16|  30.0M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  151|  30.0M|        g_alloc_bytes -= oldsize;
  152|  30.0M|        g_alloc_bytes += size;
  153|       |
  154|  30.0M|        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.0M|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (25:22): [Folded, False: 30.0M]
  |  |  ------------------
  ------------------
                      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.0M|        return buf + PREFIX_SIZE;
  ------------------
  |  |   16|  30.0M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  156|  30.0M|    }
  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|  31.7M|}
get_alloc_count:
  172|  17.6k|{
  173|  17.6k|    return g_alloc_count;
  174|  17.6k|}
get_allocation_size:
  178|  1.49M|{
  179|  1.49M|    char *buf = (char*)mem - PREFIX_SIZE;
  ------------------
  |  |   16|  1.49M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  180|  1.49M|    return ((size_t*)buf)[0];
  181|  1.49M|}
malloc_wrappers.c:round_blocksize:
   39|  61.7M|{
   40|  61.7M|    if (size < 256)
  ------------------
  |  Branch (40:9): [True: 4.35M, False: 57.4M]
  ------------------
   41|  4.35M|    {
   42|  4.35M|        return size;
   43|  4.35M|    }
   44|  57.4M|    else
   45|  57.4M|    {
   46|  57.4M|        return (size + 1023) / 1024 * 1024;
   47|  57.4M|    }
   48|  61.7M|}

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

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

validate_static:
    7|  5.90k|{
    8|  5.90k|    pb_size_t count = 1;
    9|  5.90k|    pb_size_t i;
   10|  5.90k|    bool truebool = true;
   11|  5.90k|    bool falsebool = false;
   12|       |
   13|  5.90k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  324|  5.90k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  5.90k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  311|  11.8k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 0, False: 5.90k]
  |  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|  5.90k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  324|  5.90k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  5.90k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  309|  11.8k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 0, False: 5.90k]
  |  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|  5.90k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|  5.90k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  5.90k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|  5.90k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 5.90k, False: 0]
  ------------------
   26|  5.90k|    {
   27|  5.90k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 5.54k, False: 360]
  ------------------
   28|  5.54k|        {
   29|       |            /* Some different field in oneof */
   30|  5.54k|            return;
   31|  5.54k|        }
   32|  5.90k|    }
   33|       |
   34|    720|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 360, False: 360]
  ------------------
   35|    360|    {
   36|    360|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|    360|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  325|    360|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|    360|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  281|    360|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 0, False: 360]
  ------------------
   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|    360|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  325|    360|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|    360|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  277|    360|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 0, False: 360]
  ------------------
   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|    360|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  325|    360|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|    360|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  265|    360|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 0, False: 360]
  ------------------
   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|    360|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  326|    360|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|    360|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|    360|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|    720|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 360, False: 0]
  |  |  ------------------
  |  |  327|    360|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|      0|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   56|    360|        {
   57|    360|            validate_message(pData, 0, iter->submsg_desc);
   58|    360|        }
   59|    360|    }
   60|    360|}
validate_pointer:
   63|   647k|{
   64|   647k|    pb_size_t count = 1;
   65|   647k|    pb_size_t i;
   66|   647k|    bool truebool = true;
   67|   647k|    bool falsebool = false;
   68|       |
   69|   647k|    if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|   647k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   647k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|   647k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (69:9): [True: 11.8k, False: 635k]
  ------------------
   70|  11.8k|    {
   71|  11.8k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (71:13): [True: 11.2k, False: 560]
  ------------------
   72|  11.2k|        {
   73|       |            /* Some different field in oneof */
   74|  11.2k|            return;
   75|  11.2k|        }
   76|  11.8k|    }
   77|   635k|    else if (!iter->pData)
  ------------------
  |  Branch (77:14): [True: 268k, False: 367k]
  ------------------
   78|   268k|    {
   79|       |        /* Nothing allocated */
   80|   268k|        if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize != &iter->array_size)
  ------------------
  |  |  324|   268k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   268k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize != &iter->array_size)
  ------------------
  |  |  311|   536k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (80:13): [True: 111k, False: 156k]
  |  Branch (80:58): [True: 100k, False: 11.1k]
  ------------------
   81|   100k|        {
   82|   100k|            assert(*(pb_size_t*)iter->pSize == 0);
  ------------------
  |  Branch (82:13): [True: 0, False: 100k]
  |  Branch (82:13): [True: 100k, False: 0]
  ------------------
   83|   100k|        }
   84|   268k|        return;
   85|   268k|    }
   86|       |
   87|   368k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  324|   368k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   368k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  311|   368k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (87:9): [True: 12.0k, False: 356k]
  ------------------
   88|  12.0k|    {
   89|       |        /* Check that enough memory has been allocated for array */
   90|  12.0k|        size_t allocated_size = get_allocation_size(iter->pData);
   91|  12.0k|        count = *(pb_size_t*)iter->pSize;
   92|  12.0k|        assert(allocated_size >= count * iter->data_size);
  ------------------
  |  Branch (92:9): [True: 0, False: 12.0k]
  |  Branch (92:9): [True: 12.0k, False: 0]
  ------------------
   93|  12.0k|    }
   94|   356k|    else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  325|   356k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   356k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  281|   712k|#define PB_LTYPE_STRING 0x07U
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  325|   301k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   301k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  277|   301k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (94:14): [True: 301k, False: 54.9k]
  |  Branch (94:57): [True: 294k, False: 6.66k]
  ------------------
   95|   294k|    {
   96|   294k|        size_t allocated_size = get_allocation_size(iter->pData);
   97|   294k|        assert(allocated_size >= iter->data_size);
  ------------------
  |  Branch (97:9): [True: 0, False: 294k]
  |  Branch (97:9): [True: 294k, False: 0]
  ------------------
   98|   294k|    }
   99|       |
  100|  38.9M|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (100:17): [True: 38.6M, False: 368k]
  ------------------
  101|  38.6M|    {
  102|  38.6M|        void *pData = (char*)iter->pData + iter->data_size * i;
  103|       |
  104|  38.6M|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  325|  38.6M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  38.6M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  281|  38.6M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (104:13): [True: 77.4k, False: 38.5M]
  ------------------
  105|  77.4k|        {
  106|       |            /* Check that enough memory is allocated for string and that
  107|       |               the string is properly terminated. */
  108|  77.4k|            const char *str = pData;
  109|       |
  110|  77.4k|            if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  324|  77.4k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  77.4k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  311|  77.4k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (110:17): [True: 22.4k, False: 54.9k]
  ------------------
  111|  22.4k|            {
  112|       |                /* String arrays are stored as array of pointers */
  113|  22.4k|                str = ((const char**)iter->pData)[i];
  114|  22.4k|            }
  115|       |
  116|  77.4k|            assert(strlen(str) + 1 <= get_allocation_size(str));
  ------------------
  |  Branch (116:13): [True: 0, False: 77.4k]
  |  Branch (116:13): [True: 77.4k, False: 0]
  ------------------
  117|  77.4k|        }
  118|  38.5M|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  325|  38.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  38.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  277|  38.5M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (118:18): [True: 1.10M, False: 37.4M]
  ------------------
  119|  1.10M|        {
  120|       |            /* Bytes length must be at most statically allocated size */
  121|  1.10M|            const pb_bytes_array_t *bytes = pData;
  122|       |
  123|  1.10M|            if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  324|  1.10M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  1.10M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  311|  1.10M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (123:17): [True: 1.10M, False: 6.66k]
  ------------------
  124|  1.10M|            {
  125|       |                /* Bytes arrays are stored as array of pointers */
  126|  1.10M|                bytes = ((const pb_bytes_array_t**)iter->pData)[i];
  127|  1.10M|            }
  128|       |
  129|  1.10M|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= get_allocation_size(bytes));
  ------------------
  |  Branch (129:13): [True: 0, False: 1.10M]
  |  Branch (129:13): [True: 1.10M, False: 0]
  ------------------
  130|  1.10M|        }
  131|  37.4M|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  325|  37.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  37.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  265|  37.4M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (131:18): [True: 1.79M, False: 35.6M]
  ------------------
  132|  1.79M|        {
  133|       |            /* Bool fields must have valid value */
  134|  1.79M|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (134:13): [True: 1.79M, False: 0]
  |  Branch (134:13): [True: 0, False: 0]
  |  Branch (134:13): [True: 246k, False: 1.54M]
  |  Branch (134:13): [True: 1.54M, False: 0]
  ------------------
  135|  1.79M|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
  136|  1.79M|        }
  137|  35.6M|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  326|  35.6M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|  35.6M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  35.6M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  71.2M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 108k, False: 35.5M]
  |  |  ------------------
  |  |  327|  35.6M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|  35.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  35.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|  35.5M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 35.5M]
  |  |  ------------------
  ------------------
  138|   108k|        {
  139|   108k|            validate_message(pData, 0, iter->submsg_desc);
  140|   108k|        }
  141|  38.6M|    }
  142|   368k|}
validate_message:
  145|   114k|{
  146|   114k|    pb_field_iter_t iter;
  147|       |
  148|   114k|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 72.3k, False: 42.5k]
  ------------------
  149|  72.3k|    {
  150|  72.3k|        do
  151|   659k|        {
  152|   659k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  323|   659k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   659k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  318|   659k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 5.90k, False: 653k]
  ------------------
  153|  5.90k|            {
  154|  5.90k|                validate_static(&iter);
  155|  5.90k|            }
  156|   653k|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|   653k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   653k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|   653k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 647k, False: 5.90k]
  ------------------
  157|   647k|            {
  158|   647k|                validate_pointer(&iter);
  159|   647k|            }
  160|   659k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 587k, False: 72.3k]
  ------------------
  161|  72.3k|    }
  162|   114k|}

