pb_field_iter_begin:
  157|   635k|{
  158|   635k|    memset(iter, 0, sizeof(*iter));
  159|       |
  160|   635k|    iter->descriptor = desc;
  161|   635k|    iter->message = message;
  162|       |
  163|   635k|    return load_descriptor_values(iter);
  164|   635k|}
pb_field_iter_begin_extension:
  167|  86.3k|{
  168|  86.3k|    const pb_msgdesc_t *msg = (const pb_msgdesc_t*)extension->type->arg;
  169|  86.3k|    bool status;
  170|       |
  171|  86.3k|    uint32_t word0 = PB_PROGMEM_READU32(msg->field_info[0]);
  ------------------
  |  |  181|  86.3k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  172|  86.3k|    if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|  86.3k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  86.3k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|  86.3k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (172:9): [True: 0, False: 86.3k]
  ------------------
  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|  86.3k|    else
  180|  86.3k|    {
  181|  86.3k|        status = pb_field_iter_begin(iter, msg, extension->dest);
  182|  86.3k|    }
  183|       |
  184|  86.3k|    iter->pSize = &extension->found;
  185|  86.3k|    return status;
  186|  86.3k|}
pb_field_iter_next:
  189|  2.92M|{
  190|  2.92M|    advance_iterator(iter);
  191|  2.92M|    (void)load_descriptor_values(iter);
  192|  2.92M|    return iter->index != 0;
  193|  2.92M|}
pb_field_iter_find:
  196|  29.5M|{
  197|  29.5M|    if (iter->tag == tag)
  ------------------
  |  Branch (197:9): [True: 28.3M, False: 1.19M]
  ------------------
  198|  28.3M|    {
  199|  28.3M|        return true; /* Nothing to do, correct field already. */
  200|  28.3M|    }
  201|  1.19M|    else if (tag > iter->descriptor->largest_tag)
  ------------------
  |  Branch (201:14): [True: 310k, False: 881k]
  ------------------
  202|   310k|    {
  203|   310k|        return false;
  204|   310k|    }
  205|   881k|    else
  206|   881k|    {
  207|   881k|        pb_size_t start = iter->index;
  208|   881k|        uint32_t fieldinfo;
  209|       |
  210|   881k|        if (tag < iter->tag)
  ------------------
  |  Branch (210:13): [True: 216k, False: 664k]
  ------------------
  211|   216k|        {
  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|   216k|            iter->index = iter->descriptor->field_count;
  216|   216k|        }
  217|       |
  218|   881k|        do
  219|  9.85M|        {
  220|       |            /* Advance iterator but don't load values yet */
  221|  9.85M|            advance_iterator(iter);
  222|       |
  223|       |            /* Do fast check for tag number match */
  224|  9.85M|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  181|  9.85M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  225|       |
  226|  9.85M|            if (((fieldinfo >> 2) & 0x3F) == (tag & 0x3F))
  ------------------
  |  Branch (226:17): [True: 900k, False: 8.95M]
  ------------------
  227|   900k|            {
  228|       |                /* Good candidate, check further */
  229|   900k|                (void)load_descriptor_values(iter);
  230|       |
  231|   900k|                if (iter->tag == tag &&
  ------------------
  |  Branch (231:21): [True: 816k, False: 84.8k]
  ------------------
  232|   816k|                    PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|   816k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   816k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                                  PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|   816k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (232:21): [True: 812k, False: 3.87k]
  ------------------
  233|   812k|                {
  234|       |                    /* Found it */
  235|   812k|                    return true;
  236|   812k|                }
  237|   900k|            }
  238|  9.85M|        } while (iter->index != start);
  ------------------
  |  Branch (238:18): [True: 8.97M, False: 68.9k]
  ------------------
  239|       |
  240|       |        /* Searched all the way back to start, and found nothing. */
  241|  68.9k|        (void)load_descriptor_values(iter);
  242|       |        return false;
  243|   881k|    }
  244|  29.5M|}
pb_field_iter_find_extension:
  247|  9.64k|{
  248|  9.64k|    if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|  9.64k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  9.64k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|  9.64k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (248:9): [True: 0, False: 9.64k]
  ------------------
  249|      0|    {
  250|      0|        return true;
  251|      0|    }
  252|  9.64k|    else
  253|  9.64k|    {
  254|  9.64k|        pb_size_t start = iter->index;
  255|  9.64k|        uint32_t fieldinfo;
  256|       |
  257|  9.64k|        do
  258|   122k|        {
  259|       |            /* Advance iterator but don't load values yet */
  260|   122k|            advance_iterator(iter);
  261|       |
  262|       |            /* Do fast check for field type */
  263|   122k|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  181|   122k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  264|       |
  265|   122k|            if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|   122k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   122k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|   122k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (265:17): [True: 3.72k, False: 118k]
  ------------------
  266|  3.72k|            {
  267|  3.72k|                return load_descriptor_values(iter);
  268|  3.72k|            }
  269|   122k|        } while (iter->index != start);
  ------------------
  |  Branch (269:18): [True: 112k, False: 5.91k]
  ------------------
  270|       |
  271|       |        /* Searched all the way back to start, and found nothing. */
  272|  5.91k|        (void)load_descriptor_values(iter);
  273|       |        return false;
  274|  9.64k|    }
  275|  9.64k|}
pb_field_iter_begin_const:
  291|   210k|{
  292|   210k|    return pb_field_iter_begin(iter, desc, pb_const_cast(message));
  293|   210k|}
pb_field_iter_begin_extension_const:
  296|  2.74k|{
  297|  2.74k|    return pb_field_iter_begin_extension(iter, (pb_extension_t*)pb_const_cast(extension));
  298|  2.74k|}
pb_common.c:load_descriptor_values:
    9|  4.53M|{
   10|  4.53M|    uint32_t word0;
   11|  4.53M|    uint32_t data_offset;
   12|  4.53M|    int_least8_t size_offset;
   13|       |
   14|  4.53M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (14:9): [True: 208k, False: 4.32M]
  ------------------
   15|   208k|        return false;
   16|       |
   17|  4.32M|    word0 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  181|  4.32M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   18|  4.32M|    iter->type = (pb_type_t)((word0 >> 8) & 0xFF);
   19|       |
   20|  4.32M|    switch(word0 & 3)
   21|  4.32M|    {
   22|   728k|        case 0: {
  ------------------
  |  Branch (22:9): [True: 728k, False: 3.60M]
  ------------------
   23|       |            /* 1-word format */
   24|   728k|            iter->array_size = 1;
   25|   728k|            iter->tag = (pb_size_t)((word0 >> 2) & 0x3F);
   26|   728k|            size_offset = (int_least8_t)((word0 >> 24) & 0x0F);
   27|   728k|            data_offset = (word0 >> 16) & 0xFF;
   28|   728k|            iter->data_size = (pb_size_t)((word0 >> 28) & 0x0F);
   29|   728k|            break;
   30|      0|        }
   31|       |
   32|  2.97M|        case 1: {
  ------------------
  |  Branch (32:9): [True: 2.97M, False: 1.35M]
  ------------------
   33|       |            /* 2-word format */
   34|  2.97M|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  181|  2.97M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   35|       |
   36|  2.97M|            iter->array_size = (pb_size_t)((word0 >> 16) & 0x0FFF);
   37|  2.97M|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 28) << 6));
   38|  2.97M|            size_offset = (int_least8_t)((word0 >> 28) & 0x0F);
   39|  2.97M|            data_offset = word1 & 0xFFFF;
   40|  2.97M|            iter->data_size = (pb_size_t)((word1 >> 16) & 0x0FFF);
   41|  2.97M|            break;
   42|      0|        }
   43|       |
   44|   462k|        case 2: {
  ------------------
  |  Branch (44:9): [True: 462k, False: 3.86M]
  ------------------
   45|       |            /* 4-word format */
   46|   462k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  181|   462k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   47|   462k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  181|   462k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   48|   462k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  181|   462k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   49|       |
   50|   462k|            iter->array_size = (pb_size_t)(word0 >> 16);
   51|   462k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   52|   462k|            size_offset = (int_least8_t)(word1 & 0xFF);
   53|   462k|            data_offset = word2;
   54|   462k|            iter->data_size = (pb_size_t)word3;
   55|   462k|            break;
   56|      0|        }
   57|       |
   58|   162k|        default: {
  ------------------
  |  Branch (58:9): [True: 162k, False: 4.16M]
  ------------------
   59|       |            /* 8-word format */
   60|   162k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  181|   162k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   61|   162k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  181|   162k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   62|   162k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  181|   162k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   63|   162k|            uint32_t word4 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 4]);
  ------------------
  |  |  181|   162k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   64|       |
   65|   162k|            iter->array_size = (pb_size_t)word4;
   66|   162k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   67|   162k|            size_offset = (int_least8_t)(word1 & 0xFF);
   68|   162k|            data_offset = word2;
   69|   162k|            iter->data_size = (pb_size_t)word3;
   70|   162k|            break;
   71|      0|        }
   72|  4.32M|    }
   73|       |
   74|  4.32M|    if (!iter->message)
  ------------------
  |  Branch (74:9): [True: 0, False: 4.32M]
  ------------------
   75|      0|    {
   76|       |        /* Avoid doing arithmetic on null pointers, it is undefined */
   77|      0|        iter->pField = NULL;
   78|      0|        iter->pSize = NULL;
   79|      0|    }
   80|  4.32M|    else
   81|  4.32M|    {
   82|  4.32M|        iter->pField = (char*)iter->message + data_offset;
   83|       |
   84|  4.32M|        if (size_offset)
  ------------------
  |  Branch (84:13): [True: 758k, False: 3.57M]
  ------------------
   85|   758k|        {
   86|   758k|            iter->pSize = (char*)iter->pField - size_offset;
   87|   758k|        }
   88|  3.57M|        else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  324|  3.57M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  3.57M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  311|  7.14M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (88:18): [True: 54.7k, False: 3.51M]
  ------------------
   89|  54.7k|                 (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  323|  54.7k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  54.7k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                               (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  318|   109k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (89:19): [True: 0, False: 54.7k]
  ------------------
   90|  54.7k|                  PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  323|  54.7k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  54.7k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                                PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  319|  54.7k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (90:19): [True: 54.7k, False: 0]
  ------------------
   91|  54.7k|        {
   92|       |            /* Fixed count array */
   93|  54.7k|            iter->pSize = &iter->array_size;
   94|  54.7k|        }
   95|  3.51M|        else
   96|  3.51M|        {
   97|  3.51M|            iter->pSize = NULL;
   98|  3.51M|        }
   99|       |
  100|  4.32M|        if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  323|  4.32M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  4.32M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  319|  8.65M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (100:13): [True: 4.13M, False: 198k]
  |  Branch (100:57): [True: 4.13M, False: 0]
  ------------------
  101|  4.13M|        {
  102|  4.13M|            iter->pData = *(void**)iter->pField;
  103|  4.13M|        }
  104|   198k|        else
  105|   198k|        {
  106|   198k|            iter->pData = iter->pField;
  107|   198k|        }
  108|  4.32M|    }
  109|       |
  110|  4.32M|    if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  326|  4.32M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|  4.32M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  4.32M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  8.65M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 519k, False: 3.81M]
  |  |  ------------------
  |  |  327|  4.32M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|  3.81M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  3.81M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|  3.81M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 3.81M]
  |  |  ------------------
  ------------------
  111|   519k|    {
  112|   519k|        iter->submsg_desc = iter->descriptor->submsg_info[iter->submessage_index];
  113|   519k|    }
  114|  3.81M|    else
  115|  3.81M|    {
  116|  3.81M|        iter->submsg_desc = NULL;
  117|  3.81M|    }
  118|       |
  119|       |    return true;
  120|  4.32M|}
pb_common.c:advance_iterator:
  123|  12.8M|{
  124|  12.8M|    iter->index++;
  125|       |
  126|  12.8M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (126:9): [True: 627k, False: 12.2M]
  ------------------
  127|   627k|    {
  128|       |        /* Restart */
  129|   627k|        iter->index = 0;
  130|   627k|        iter->field_info_index = 0;
  131|   627k|        iter->submessage_index = 0;
  132|   627k|        iter->required_field_index = 0;
  133|   627k|    }
  134|  12.2M|    else
  135|  12.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|  12.2M|        uint32_t prev_descriptor = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  181|  12.2M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  143|  12.2M|        pb_type_t prev_type = (prev_descriptor >> 8) & 0xFF;
  144|  12.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|  12.2M|        iter->field_info_index = (pb_size_t)(iter->field_info_index + descriptor_len);
  151|  12.2M|        iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  324|  12.2M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  12.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|  12.2M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  152|  12.2M|        iter->submessage_index = (pb_size_t)(iter->submessage_index + PB_LTYPE_IS_SUBMSG(prev_type));
  ------------------
  |  |  326|  12.2M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|  12.2M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  12.2M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  24.5M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 1.60M, False: 10.6M]
  |  |  ------------------
  |  |  327|  12.2M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|  10.6M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  10.6M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|  10.6M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 10.6M]
  |  |  ------------------
  ------------------
  153|  12.2M|    }
  154|  12.8M|}
pb_common.c:pb_const_cast:
  278|   212k|{
  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|   212k|    union {
  283|   212k|        void *p1;
  284|   212k|        const void *p2;
  285|   212k|    } t;
  286|   212k|    t.p2 = p;
  287|   212k|    return t.p1;
  288|   212k|}

pb_read:
   82|  2.77M|{
   83|  2.77M|    if (count == 0)
  ------------------
  |  Branch (83:9): [True: 1.10M, False: 1.67M]
  ------------------
   84|  1.10M|        return true;
   85|       |
   86|  1.67M|#ifndef PB_BUFFER_ONLY
   87|  1.67M|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (87:6): [True: 101k, False: 1.56M]
  |  Branch (87:21): [True: 33.7k, False: 67.5k]
  ------------------
   88|  33.7k|	{
   89|       |		/* Skip input bytes */
   90|  33.7k|		pb_byte_t tmp[16];
   91|   187k|		while (count > 16)
  ------------------
  |  Branch (91:10): [True: 154k, False: 33.7k]
  ------------------
   92|   154k|		{
   93|   154k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (93:8): [True: 0, False: 154k]
  ------------------
   94|      0|				return false;
   95|       |			
   96|   154k|			count -= 16;
   97|   154k|		}
   98|       |		
   99|  33.7k|		return pb_read(stream, tmp, count);
  100|  33.7k|	}
  101|  1.63M|#endif
  102|       |
  103|  1.63M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (103:9): [True: 210, False: 1.63M]
  ------------------
  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.63M|#ifndef PB_BUFFER_ONLY
  107|  1.63M|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:9): [True: 0, False: 1.63M]
  ------------------
  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.63M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (114:9): [True: 0, False: 1.63M]
  ------------------
  115|      0|        stream->bytes_left = 0;
  116|  1.63M|    else
  117|  1.63M|        stream->bytes_left -= count;
  118|       |
  119|       |    return true;
  120|  1.63M|}
pb_istream_from_buffer:
  143|  6.53k|{
  144|  6.53k|    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.53k|    union {
  149|  6.53k|        void *state;
  150|  6.53k|        const void *c_state;
  151|  6.53k|    } state;
  152|       |#ifdef PB_BUFFER_ONLY
  153|       |    stream.callback = NULL;
  154|       |#else
  155|  6.53k|    stream.callback = &buf_read;
  156|  6.53k|#endif
  157|  6.53k|    state.c_state = buf;
  158|  6.53k|    stream.state = state.state;
  159|  6.53k|    stream.bytes_left = msglen;
  160|  6.53k|#ifndef PB_NO_ERRMSG
  161|       |    stream.errmsg = NULL;
  162|  6.53k|#endif
  163|  6.53k|    return stream;
  164|  6.53k|}
pb_decode_varint32:
  172|  61.2M|{
  173|  61.2M|    pb_byte_t byte;
  174|  61.2M|    uint32_t result;
  175|       |    
  176|  61.2M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (176:9): [True: 1.76k, False: 61.2M]
  ------------------
  177|  1.76k|    {
  178|  1.76k|        return false;
  179|  1.76k|    }
  180|       |    
  181|  61.2M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (181:9): [True: 33.2M, False: 27.9M]
  ------------------
  182|  33.2M|    {
  183|       |        /* Quick case, 1 byte value */
  184|  33.2M|        result = byte;
  185|  33.2M|    }
  186|  27.9M|    else
  187|  27.9M|    {
  188|       |        /* Multibyte case */
  189|  27.9M|        uint_fast8_t bitpos = 7;
  190|  27.9M|        result = byte & 0x7F;
  191|       |        
  192|  27.9M|        do
  193|  28.0M|        {
  194|  28.0M|            if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (194:17): [True: 61, False: 28.0M]
  ------------------
  195|     61|                return false;
  196|       |            
  197|  28.0M|            if (bitpos >= 32)
  ------------------
  |  Branch (197:17): [True: 6.84k, False: 28.0M]
  ------------------
  198|  6.84k|            {
  199|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  200|  6.84k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (200:44): [True: 6.72k, False: 118]
  ------------------
  201|  6.84k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (201:41): [True: 3.34k, False: 3.49k]
  ------------------
  202|  3.49k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (202:27): [True: 3.48k, False: 13]
  |  Branch (202:50): [True: 3.42k, False: 60]
  ------------------
  203|       |
  204|  6.84k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (204:21): [True: 3, False: 6.84k]
  |  Branch (204:37): [True: 73, False: 6.77k]
  ------------------
  205|     76|                {
  206|     76|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  920|     76|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     76|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 76]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  207|     76|                }
  208|  6.84k|            }
  209|  28.0M|            else if (bitpos == 28)
  ------------------
  |  Branch (209:22): [True: 7.24k, False: 28.0M]
  ------------------
  210|  7.24k|            {
  211|  7.24k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (211:21): [True: 4.55k, False: 2.68k]
  |  Branch (211:43): [True: 26, False: 4.53k]
  ------------------
  212|     26|                {
  213|     26|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  920|     26|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     26|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  214|     26|                }
  215|  7.22k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  216|  7.22k|            }
  217|  28.0M|            else
  218|  28.0M|            {
  219|  28.0M|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  220|  28.0M|            }
  221|  28.0M|            bitpos = (uint_fast8_t)(bitpos + 7);
  222|  28.0M|        } while (byte & 0x80);
  ------------------
  |  Branch (222:18): [True: 96.1k, False: 27.9M]
  ------------------
  223|  27.9M|   }
  224|       |   
  225|  61.2M|   *dest = result;
  226|       |   return true;
  227|  61.2M|}
pb_decode_varint:
  231|  9.72M|{
  232|  9.72M|    pb_byte_t byte;
  233|  9.72M|    uint_fast8_t bitpos = 0;
  234|  9.72M|    uint64_t result = 0;
  235|       |    
  236|  9.72M|    do
  237|  16.5M|    {
  238|  16.5M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (238:13): [True: 84, False: 16.5M]
  ------------------
  239|     84|            return false;
  240|       |
  241|  16.5M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (241:13): [True: 88.4k, False: 16.4M]
  |  Branch (241:29): [True: 30, False: 88.3k]
  ------------------
  242|     30|            PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  920|     30|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     30|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 30]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  243|       |
  244|  16.5M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  245|  16.5M|        bitpos = (uint_fast8_t)(bitpos + 7);
  246|  16.5M|    } while (byte & 0x80);
  ------------------
  |  Branch (246:14): [True: 6.78M, False: 9.72M]
  ------------------
  247|       |    
  248|  9.72M|    *dest = result;
  249|       |    return true;
  250|  9.72M|}
pb_decode_tag:
  279|  29.6M|{
  280|  29.6M|    uint32_t temp;
  281|  29.6M|    *eof = false;
  282|  29.6M|    *wire_type = (pb_wire_type_t) 0;
  283|  29.6M|    *tag = 0;
  284|       |
  285|  29.6M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (285:9): [True: 165k, False: 29.5M]
  ------------------
  286|   165k|    {
  287|   165k|        *eof = true;
  288|   165k|        return false;
  289|   165k|    }
  290|       |
  291|  29.5M|    if (!pb_decode_varint32(stream, &temp))
  ------------------
  |  Branch (291:9): [True: 1.64k, False: 29.5M]
  ------------------
  292|  1.64k|    {
  293|  1.64k|#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.64k|        if (stream->callback != buf_read && stream->bytes_left == 0)
  ------------------
  |  Branch (301:13): [True: 1.54k, False: 101]
  |  Branch (301:45): [True: 1.54k, False: 0]
  ------------------
  302|  1.54k|        {
  303|  1.54k|#ifndef PB_NO_ERRMSG
  304|  1.54k|            if (strcmp(stream->errmsg, "io error") == 0)
  ------------------
  |  Branch (304:17): [True: 1.54k, False: 0]
  ------------------
  305|  1.54k|                stream->errmsg = NULL;
  306|  1.54k|#endif
  307|  1.54k|            *eof = true;
  308|  1.54k|        }
  309|  1.64k|#endif
  310|  1.64k|        return false;
  311|  1.64k|    }
  312|       |    
  313|  29.5M|    *tag = temp >> 3;
  314|  29.5M|    *wire_type = (pb_wire_type_t)(temp & 7);
  315|       |    return true;
  316|  29.5M|}
pb_skip_field:
  319|   375k|{
  320|   375k|    switch (wire_type)
  321|   375k|    {
  322|   188k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (322:9): [True: 188k, False: 187k]
  ------------------
  323|  15.2k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (323:9): [True: 15.2k, False: 360k]
  ------------------
  324|   120k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (324:9): [True: 120k, False: 255k]
  ------------------
  325|  51.0k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (325:9): [True: 51.0k, False: 324k]
  ------------------
  326|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (326:2): [True: 0, False: 375k]
  ------------------
  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|     87|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  920|     87|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     87|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 87]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (331:9): [True: 87, False: 375k]
  ------------------
  332|   375k|    }
  333|   375k|}
pb_make_string_substream:
  384|   238k|{
  385|   238k|    uint32_t size;
  386|   238k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (386:9): [True: 112, False: 238k]
  ------------------
  387|    112|        return false;
  388|       |    
  389|   238k|    *substream = *stream;
  390|   238k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (390:9): [True: 72, False: 238k]
  ------------------
  391|     72|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  920|     72|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     72|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 72]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  392|       |    
  393|   238k|    substream->bytes_left = (size_t)size;
  394|   238k|    stream->bytes_left -= (size_t)size;
  395|       |    return true;
  396|   238k|}
pb_close_string_substream:
  399|   238k|{
  400|   238k|    if (substream->bytes_left) {
  ------------------
  |  Branch (400:9): [True: 112, False: 238k]
  ------------------
  401|    112|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (401:13): [True: 0, False: 112]
  ------------------
  402|      0|            return false;
  403|    112|    }
  404|       |
  405|   238k|    stream->state = substream->state;
  406|       |
  407|   238k|#ifndef PB_NO_ERRMSG
  408|   238k|    stream->errmsg = substream->errmsg;
  409|   238k|#endif
  410|       |    return true;
  411|   238k|}
pb_decode_ex:
 1199|  8.07k|{
 1200|  8.07k|    bool status;
 1201|       |
 1202|  8.07k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  111|  8.07k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1202:9): [True: 8.07k, False: 0]
  ------------------
 1203|  8.07k|    {
 1204|  8.07k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1205|  8.07k|    }
 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.07k|#ifdef PB_ENABLE_MALLOC
 1219|  8.07k|    if (!status)
  ------------------
  |  Branch (1219:9): [True: 2.12k, False: 5.95k]
  ------------------
 1220|  2.12k|        pb_release(fields, dest_struct);
 1221|  8.07k|#endif
 1222|       |    
 1223|  8.07k|    return status;
 1224|  8.07k|}
pb_decode:
 1227|  2.87k|{
 1228|  2.87k|    return pb_decode_ex(stream, fields, dest_struct, 0);
 1229|  2.87k|}
pb_release:
 1356|   170k|{
 1357|   170k|    pb_field_iter_t iter;
 1358|       |    
 1359|   170k|    if (!dest_struct)
  ------------------
  |  Branch (1359:9): [True: 0, False: 170k]
  ------------------
 1360|      0|        return; /* Ignore NULL pointers, similar to free() */
 1361|       |
 1362|   170k|    if (!pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1362:9): [True: 63.5k, False: 106k]
  ------------------
 1363|  63.5k|        return; /* Empty message type */
 1364|       |    
 1365|   106k|    do
 1366|   937k|    {
 1367|   937k|        pb_release_single_field(&iter);
 1368|   937k|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (1368:14): [True: 831k, False: 106k]
  ------------------
 1369|   106k|}
pb_decode_bool:
 1382|  3.89M|{
 1383|  3.89M|    uint32_t value;
 1384|  3.89M|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1384:9): [True: 70, False: 3.89M]
  ------------------
 1385|     70|        return false;
 1386|       |
 1387|  3.89M|    *(bool*)dest = (value != 0);
 1388|       |    return true;
 1389|  3.89M|}
pb_decode_svarint:
 1392|  4.17M|{
 1393|  4.17M|    pb_uint64_t value;
  ------------------
  |  |   57|  4.17M|#define pb_uint64_t uint64_t
  ------------------
 1394|  4.17M|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1394:9): [True: 38, False: 4.17M]
  ------------------
 1395|     38|        return false;
 1396|       |    
 1397|  4.17M|    if (value & 1)
  ------------------
  |  Branch (1397:9): [True: 587k, False: 3.58M]
  ------------------
 1398|   587k|        *dest = (pb_int64_t)(~(value >> 1));
 1399|  3.58M|    else
 1400|  3.58M|        *dest = (pb_int64_t)(value >> 1);
 1401|       |    
 1402|       |    return true;
 1403|  4.17M|}
pb_decode_fixed32:
 1406|  77.6k|{
 1407|  77.6k|    union {
 1408|  77.6k|        uint32_t fixed32;
 1409|  77.6k|        pb_byte_t bytes[4];
 1410|  77.6k|    } u;
 1411|       |
 1412|  77.6k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1412:9): [True: 18, False: 77.6k]
  ------------------
 1413|     18|        return false;
 1414|       |
 1415|  77.6k|#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|  77.6k|    *(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|  77.6k|}
pb_decode_fixed64:
 1429|  54.4k|{
 1430|  54.4k|    union {
 1431|  54.4k|        uint64_t fixed64;
 1432|  54.4k|        pb_byte_t bytes[8];
 1433|  54.4k|    } u;
 1434|       |
 1435|  54.4k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1435:9): [True: 18, False: 54.4k]
  ------------------
 1436|     18|        return false;
 1437|       |
 1438|  54.4k|#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|  54.4k|    *(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|  54.4k|}
pb_decode.c:buf_read:
   69|  75.2M|{
   70|  75.2M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   71|  75.2M|    stream->state = (pb_byte_t*)stream->state + count;
   72|       |    
   73|  75.2M|    if (buf != NULL)
  ------------------
  |  Branch (73:9): [True: 75.2M, False: 67.4k]
  ------------------
   74|  75.2M|    {
   75|  75.2M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   76|  75.2M|    }
   77|       |    
   78|       |    return true;
   79|  75.2M|}
pb_decode.c:pb_readbyte:
  125|   105M|{
  126|   105M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (126:9): [True: 371, False: 105M]
  ------------------
  127|    371|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  920|    371|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|    371|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 371]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|       |
  129|   105M|#ifndef PB_BUFFER_ONLY
  130|   105M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (130:9): [True: 1.54k, False: 105M]
  ------------------
  131|  1.54k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  920|  1.54k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|  1.54k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 1.54k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|       |#else
  133|       |    *buf = *(const pb_byte_t*)stream->state;
  134|       |    stream->state = (pb_byte_t*)stream->state + 1;
  135|       |#endif
  136|       |
  137|   105M|    stream->bytes_left--;
  138|       |    
  139|       |    return true;    
  140|   105M|}
pb_decode.c:pb_skip_varint:
  254|   188k|{
  255|   188k|    pb_byte_t byte;
  256|   188k|    do
  257|   222k|    {
  258|   222k|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (258:13): [True: 61, False: 222k]
  ------------------
  259|     61|            return false;
  260|   222k|    } while (byte & 0x80);
  ------------------
  |  Branch (260:14): [True: 33.8k, False: 188k]
  ------------------
  261|   188k|    return true;
  262|   188k|}
pb_decode.c:pb_skip_string:
  265|   120k|{
  266|   120k|    uint32_t length;
  267|   120k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (267:9): [True: 52, False: 120k]
  ------------------
  268|     52|        return false;
  269|       |    
  270|   120k|    if ((size_t)length != length)
  ------------------
  |  Branch (270:9): [True: 0, False: 120k]
  ------------------
  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|   120k|    return pb_read(stream, NULL, (size_t)length);
  276|   120k|}
pb_decode.c:pb_decode_inner:
 1028|   168k|{
 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|   168k|    uint32_t extension_range_start = 0;
 1034|   168k|    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|   168k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  339|   168k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
 1041|   168k|    pb_size_t fixed_count_size = 0;
 1042|   168k|    pb_size_t fixed_count_total_size = 0;
 1043|       |
 1044|       |    /* Tag and wire type of next field from the input stream */
 1045|   168k|    uint32_t tag;
 1046|   168k|    pb_wire_type_t wire_type;
 1047|   168k|    bool eof;
 1048|       |
 1049|       |    /* Track presence of required fields */
 1050|   168k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1051|   168k|    const uint32_t allbits = ~(uint32_t)0;
 1052|       |
 1053|       |    /* Descriptor for the structure field matching the tag decoded from stream */
 1054|   168k|    pb_field_iter_t iter;
 1055|       |
 1056|   168k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1056:9): [True: 105k, False: 63.5k]
  ------------------
 1057|   105k|    {
 1058|   105k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |  110|   105k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1058:13): [True: 95.8k, False: 9.47k]
  ------------------
 1059|  95.8k|        {
 1060|  95.8k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1060:17): [True: 0, False: 95.8k]
  ------------------
 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|  95.8k|        }
 1063|   105k|    }
 1064|       |
 1065|  29.6M|    while (pb_decode_tag(stream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1065:12): [True: 29.5M, False: 166k]
  ------------------
 1066|  29.5M|    {
 1067|  29.5M|        if (tag == 0)
  ------------------
  |  Branch (1067:13): [True: 70, False: 29.5M]
  ------------------
 1068|     70|        {
 1069|     70|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  112|     70|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1069:15): [True: 0, False: 70]
  ------------------
 1070|      0|          {
 1071|      0|            eof = true;
 1072|      0|            break;
 1073|      0|          }
 1074|     70|          else
 1075|     70|          {
 1076|     70|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1077|     70|          }
 1078|     70|        }
 1079|       |
 1080|  29.5M|        if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|  29.1M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  29.1M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|  29.1M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1080:13): [True: 379k, False: 29.1M]
  |  Branch (1080:48): [True: 946, False: 29.1M]
  ------------------
 1081|   380k|        {
 1082|       |            /* No match found, check if it matches an extension. */
 1083|   380k|            if (extension_range_start == 0)
  ------------------
  |  Branch (1083:17): [True: 9.64k, False: 370k]
  ------------------
 1084|  9.64k|            {
 1085|  9.64k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1085:21): [True: 3.72k, False: 5.91k]
  ------------------
 1086|  3.72k|                {
 1087|  3.72k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1088|  3.72k|                    extension_range_start = iter.tag;
 1089|  3.72k|                }
 1090|       |
 1091|  9.64k|                if (!extensions)
  ------------------
  |  Branch (1091:21): [True: 6.55k, False: 3.09k]
  ------------------
 1092|  6.55k|                {
 1093|  6.55k|                    extension_range_start = (uint32_t)-1;
 1094|  6.55k|                }
 1095|  9.64k|            }
 1096|       |
 1097|   380k|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1097:17): [True: 70.3k, False: 310k]
  ------------------
 1098|  70.3k|            {
 1099|  70.3k|                size_t pos = stream->bytes_left;
 1100|       |
 1101|  70.3k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1101:21): [True: 108, False: 70.1k]
  ------------------
 1102|    108|                    return false;
 1103|       |
 1104|  70.1k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1104:21): [True: 4.60k, False: 65.5k]
  ------------------
 1105|  4.60k|                {
 1106|       |                    /* The field was handled */
 1107|  4.60k|                    continue;
 1108|  4.60k|                }
 1109|  70.1k|            }
 1110|       |
 1111|       |            /* No match found, skip data */
 1112|   375k|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1112:17): [True: 305, False: 375k]
  ------------------
 1113|    305|                return false;
 1114|   375k|            continue;
 1115|   375k|        }
 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.1M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  324|  29.1M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  29.1M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  311|  58.2M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1120:13): [True: 27.5M, False: 1.60M]
  |  Branch (1120:57): [True: 1.52k, False: 27.5M]
  ------------------
 1121|  1.52k|        {
 1122|  1.52k|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1122:17): [True: 937, False: 587]
  ------------------
 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|    937|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  339|  1.87k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1127:21): [True: 420, False: 517]
  ------------------
 1128|    420|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1128:21): [True: 34, False: 386]
  ------------------
 1129|     34|                {
 1130|     34|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1131|     34|                }
 1132|       |
 1133|    903|                fixed_count_field = iter.index;
 1134|    903|                fixed_count_size = 0;
 1135|    903|                fixed_count_total_size = iter.array_size;
 1136|    903|            }
 1137|       |
 1138|  1.49k|            iter.pSize = &fixed_count_size;
 1139|  1.49k|        }
 1140|       |
 1141|  29.1M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  324|  29.1M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  29.1M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  308|  58.2M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1141:13): [True: 1.56M, False: 27.5M]
  ------------------
 1142|  1.56M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  230|  1.56M|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1142:16): [True: 1.56M, False: 0]
  ------------------
 1143|  1.56M|        {
 1144|  1.56M|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1145|  1.56M|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1146|  1.56M|        }
 1147|       |
 1148|  29.1M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1148:13): [True: 1.36k, False: 29.1M]
  ------------------
 1149|  1.36k|            return false;
 1150|  29.1M|    }
 1151|       |
 1152|   166k|    if (!eof)
  ------------------
  |  Branch (1152:9): [True: 101, False: 166k]
  ------------------
 1153|    101|    {
 1154|       |        /* pb_decode_tag() returned error before end of stream */
 1155|    101|        return false;
 1156|    101|    }
 1157|       |
 1158|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1159|   166k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  339|   333k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1159:9): [True: 421, False: 166k]
  ------------------
 1160|    421|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1160:9): [True: 38, False: 383]
  ------------------
 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|   166k|    {
 1167|   166k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1168|       |
 1169|   166k|        if (req_field_count > 0)
  ------------------
  |  Branch (1169:13): [True: 98.7k, False: 68.1k]
  ------------------
 1170|  98.7k|        {
 1171|  98.7k|            pb_size_t i;
 1172|       |
 1173|  98.7k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  230|  98.7k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1173:17): [True: 0, False: 98.7k]
  ------------------
 1174|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  230|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1175|       |
 1176|       |            /* Check the whole words */
 1177|  98.7k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1177:25): [True: 0, False: 98.7k]
  ------------------
 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|  98.7k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1184:17): [True: 98.7k, False: 0]
  ------------------
 1185|  98.7k|            {
 1186|  98.7k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1186:21): [True: 453, False: 98.2k]
  ------------------
 1187|  98.7k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1188|    453|                {
 1189|    453|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  920|    453|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|    453|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 453]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1190|    453|                }
 1191|  98.7k|            }
 1192|  98.7k|        }
 1193|   166k|    }
 1194|       |
 1195|   166k|    return true;
 1196|   166k|}
pb_decode.c:pb_message_set_to_defaults:
  989|   102k|{
  990|   102k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   60|   102k|#define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
  991|   102k|    uint32_t tag = 0;
  992|   102k|    pb_wire_type_t wire_type = PB_WT_VARINT;
  993|   102k|    bool eof;
  994|       |
  995|   102k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (995:9): [True: 0, False: 102k]
  ------------------
  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|   102k|    do
 1003|   911k|    {
 1004|   911k|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (1004:13): [True: 0, False: 911k]
  ------------------
 1005|      0|            return false;
 1006|       |
 1007|   911k|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (1007:13): [True: 0, False: 911k]
  |  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|   911k|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (1018:14): [True: 808k, False: 102k]
  ------------------
 1019|       |
 1020|   102k|    return true;
 1021|   102k|}
pb_decode.c:pb_field_set_to_default:
  907|   911k|{
  908|   911k|    pb_type_t type;
  909|   911k|    type = field->type;
  910|       |
  911|   911k|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|   911k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   911k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|   911k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (911:9): [True: 8.07k, False: 903k]
  ------------------
  912|  8.07k|    {
  913|  8.07k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  914|  14.6k|        while (ext != NULL)
  ------------------
  |  Branch (914:16): [True: 6.53k, False: 8.07k]
  ------------------
  915|  6.53k|        {
  916|  6.53k|            pb_field_iter_t ext_iter;
  917|  6.53k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (917:17): [True: 6.53k, False: 0]
  ------------------
  918|  6.53k|            {
  919|  6.53k|                ext->found = false;
  920|  6.53k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (920:21): [True: 0, False: 6.53k]
  ------------------
  921|      0|                    return false;
  922|  6.53k|            }
  923|  6.53k|            ext = ext->next;
  924|  6.53k|        }
  925|  8.07k|    }
  926|   903k|    else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  323|   903k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   903k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  318|   903k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (926:14): [True: 14.6k, False: 888k]
  ------------------
  927|  14.6k|    {
  928|  14.6k|        bool init_data = true;
  929|  14.6k|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  324|  14.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  14.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  309|  29.2k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (929:13): [True: 0, False: 14.6k]
  |  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.6k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  324|  14.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  14.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  311|  29.2k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (935:18): [True: 0, False: 14.6k]
  ------------------
  936|  14.6k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|  14.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  14.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|  14.6k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (936:18): [True: 8.07k, False: 6.53k]
  ------------------
  937|  8.07k|        {
  938|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
  939|       |               ONEOF: Set which_field to 0. */
  940|  8.07k|            *(pb_size_t*)field->pSize = 0;
  941|  8.07k|            init_data = false;
  942|  8.07k|        }
  943|       |
  944|  14.6k|        if (init_data)
  ------------------
  |  Branch (944:13): [True: 6.53k, False: 8.07k]
  ------------------
  945|  6.53k|        {
  946|  6.53k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  326|  13.0k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|  6.53k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  6.53k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  13.0k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 6.53k, False: 0]
  |  |  ------------------
  |  |  327|  13.0k|                               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.53k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (947:18): [True: 0, False: 6.53k]
  ------------------
  948|  6.53k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (948:18): [True: 0, False: 6.53k]
  ------------------
  949|  6.53k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (949:18): [True: 0, False: 6.53k]
  ------------------
  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.53k|            else
  962|  6.53k|            {
  963|       |                /* Initialize to zeros */
  964|  6.53k|                memset(field->pData, 0, (size_t)field->data_size);
  965|  6.53k|            }
  966|  6.53k|        }
  967|  14.6k|    }
  968|   888k|    else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|   888k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   888k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|   888k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (968:14): [True: 888k, False: 0]
  ------------------
  969|   888k|    {
  970|       |        /* Initialize the pointer to NULL. */
  971|   888k|        *(void**)field->pField = NULL;
  972|       |
  973|       |        /* Initialize array count to 0. */
  974|   888k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  324|   888k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   888k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  311|  1.77M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (974:13): [True: 169k, False: 718k]
  ------------------
  975|   718k|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|   718k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   718k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|   718k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (975:13): [True: 16.1k, False: 702k]
  ------------------
  976|   185k|        {
  977|   185k|            *(pb_size_t*)field->pSize = 0;
  978|   185k|        }
  979|   888k|    }
  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|   911k|    return true;
  986|   911k|}
pb_decode.c:decode_extension:
  885|  70.3k|{
  886|  70.3k|    size_t pos = stream->bytes_left;
  887|       |    
  888|   140k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (888:12): [True: 70.3k, False: 70.1k]
  |  Branch (888:33): [True: 70.3k, False: 0]
  ------------------
  889|  70.3k|    {
  890|  70.3k|        bool status;
  891|  70.3k|        if (extension->type->decode)
  ------------------
  |  Branch (891:13): [True: 0, False: 70.3k]
  ------------------
  892|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  893|  70.3k|        else
  894|  70.3k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  895|       |
  896|  70.3k|        if (!status)
  ------------------
  |  Branch (896:13): [True: 108, False: 70.1k]
  ------------------
  897|    108|            return false;
  898|       |        
  899|  70.1k|        extension = extension->next;
  900|  70.1k|    }
  901|       |    
  902|  70.1k|    return true;
  903|  70.3k|}
pb_decode.c:default_extension_decoder:
  868|  70.3k|{
  869|  70.3k|    pb_field_iter_t iter;
  870|       |
  871|  70.3k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (871:9): [True: 0, False: 70.3k]
  ------------------
  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|  70.3k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (874:9): [True: 65.5k, False: 4.70k]
  |  Branch (874:28): [True: 0, False: 4.70k]
  ------------------
  875|  65.5k|        return true;
  876|       |
  877|  4.70k|    extension->found = true;
  878|  4.70k|    return decode_field(stream, wire_type, &iter);
  879|  70.3k|}
pb_decode.c:decode_field:
  836|  29.1M|{
  837|  29.1M|#ifdef PB_ENABLE_MALLOC
  838|       |    /* When decoding an oneof field, check if there is old data that must be
  839|       |     * released first. */
  840|  29.1M|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|  29.1M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  29.1M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|  29.1M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (840:9): [True: 23.9k, False: 29.1M]
  ------------------
  841|  23.9k|    {
  842|  23.9k|        if (!pb_release_union_field(stream, field))
  ------------------
  |  Branch (842:13): [True: 0, False: 23.9k]
  ------------------
  843|      0|            return false;
  844|  23.9k|    }
  845|  29.1M|#endif
  846|       |
  847|  29.1M|    switch (PB_ATYPE(field->type))
  ------------------
  |  |  323|  29.1M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  29.1M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
  848|  29.1M|    {
  849|  11.6k|        case PB_ATYPE_STATIC:
  ------------------
  |  |  318|  11.6k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (849:9): [True: 11.6k, False: 29.1M]
  ------------------
  850|  11.6k|            return decode_static_field(stream, wire_type, field);
  851|       |        
  852|  29.1M|        case PB_ATYPE_POINTER:
  ------------------
  |  |  319|  29.1M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (852:9): [True: 29.1M, False: 11.6k]
  ------------------
  853|  29.1M|            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.1M]
  ------------------
  856|      0|            return decode_callback_field(stream, wire_type, field);
  857|       |        
  858|      0|        default:
  ------------------
  |  Branch (858:9): [True: 0, False: 29.1M]
  ------------------
  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.1M|    }
  861|  29.1M|}
pb_decode.c:pb_release_union_field:
 1235|  23.9k|{
 1236|  23.9k|    pb_field_iter_t old_field = *field;
 1237|  23.9k|    pb_size_t old_tag = *(pb_size_t*)field->pSize; /* Previous which_ value */
 1238|  23.9k|    pb_size_t new_tag = field->tag; /* New which_ value */
 1239|       |
 1240|  23.9k|    if (old_tag == 0)
  ------------------
  |  Branch (1240:9): [True: 1.02k, False: 22.9k]
  ------------------
 1241|  1.02k|        return true; /* Ok, no old data in union */
 1242|       |
 1243|  22.9k|    if (old_tag == new_tag)
  ------------------
  |  Branch (1243:9): [True: 11.8k, False: 11.0k]
  ------------------
 1244|  11.8k|        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|  11.0k|    if (!pb_field_iter_find(&old_field, old_tag))
  ------------------
  |  Branch (1248:9): [True: 0, False: 11.0k]
  ------------------
 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|  11.0k|    pb_release_single_field(&old_field);
 1252|       |
 1253|  11.0k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|  11.0k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  11.0k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|  11.0k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1253:9): [True: 7.38k, False: 3.65k]
  ------------------
 1254|  7.38k|    {
 1255|       |        /* Initialize the pointer to NULL to make sure it is valid
 1256|       |         * even in case of error return. */
 1257|  7.38k|        *(void**)field->pField = NULL;
 1258|  7.38k|        field->pData = NULL;
 1259|  7.38k|    }
 1260|       |
 1261|       |    return true;
 1262|  11.0k|}
pb_decode.c:decode_static_field:
  489|  11.6k|{
  490|  11.6k|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  324|  11.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  11.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  491|  11.6k|    {
  492|  4.70k|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  308|  4.70k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (492:9): [True: 4.70k, False: 6.89k]
  ------------------
  493|  4.70k|            return decode_basic_field(stream, wire_type, field);
  494|       |            
  495|  2.08k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  309|  2.08k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (495:9): [True: 2.08k, False: 9.51k]
  ------------------
  496|  2.08k|            if (field->pSize != NULL)
  ------------------
  |  Branch (496:17): [True: 2.08k, False: 0]
  ------------------
  497|  2.08k|                *(bool*)field->pSize = true;
  498|  2.08k|            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: 11.6k]
  ------------------
  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|  4.81k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  313|  4.81k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (543:9): [True: 4.81k, False: 6.79k]
  ------------------
  544|  4.81k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  326|  9.62k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|  4.81k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  4.81k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  9.62k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 4.81k, False: 0]
  |  |  ------------------
  |  |  327|  9.62k|                               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|  4.81k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (545:17): [True: 3.91k, False: 893]
  ------------------
  546|  3.91k|            {
  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|  3.91k|                memset(field->pData, 0, (size_t)field->data_size);
  555|       |
  556|       |                /* Set default values for the submessage fields. */
  557|  3.91k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (557:21): [True: 0, False: 3.91k]
  ------------------
  558|  3.91k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (558:21): [True: 0, False: 3.91k]
  ------------------
  559|  3.91k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (559:21): [True: 0, False: 3.91k]
  ------------------
  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|  3.91k|            }
  569|  4.81k|            *(pb_size_t*)field->pSize = field->tag;
  570|       |
  571|  4.81k|            return decode_basic_field(stream, wire_type, field);
  572|       |
  573|      0|        default:
  ------------------
  |  Branch (573:9): [True: 0, False: 11.6k]
  ------------------
  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|  11.6k|    }
  576|  11.6k|}
pb_decode.c:decode_basic_field:
  418|  41.3M|{
  419|  41.3M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  325|  41.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  41.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  420|  41.3M|    {
  421|  3.89M|        case PB_LTYPE_BOOL:
  ------------------
  |  |  265|  3.89M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (421:9): [True: 3.89M, False: 37.4M]
  ------------------
  422|  3.89M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (422:17): [True: 3.53M, False: 358k]
  |  Branch (422:46): [True: 17, False: 3.53M]
  ------------------
  423|     17|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     17|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     17|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  424|       |
  425|  3.89M|            return pb_dec_bool(stream, field);
  426|       |
  427|  4.79M|        case PB_LTYPE_VARINT:
  ------------------
  |  |  266|  4.79M|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (427:9): [True: 4.79M, False: 36.5M]
  ------------------
  428|  5.55M|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  267|  5.55M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (428:9): [True: 752k, False: 40.6M]
  ------------------
  429|  9.72M|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  268|  9.72M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (429:9): [True: 4.17M, False: 37.2M]
  ------------------
  430|  9.72M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (430:17): [True: 8.76M, False: 957k]
  |  Branch (430:46): [True: 73, False: 8.76M]
  ------------------
  431|     73|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     73|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     73|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 73]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  432|       |
  433|  9.72M|            return pb_dec_varint(stream, field);
  434|       |
  435|  77.6k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  269|  77.6k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (435:9): [True: 77.6k, False: 41.3M]
  ------------------
  436|  77.6k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (436:17): [True: 9.94k, False: 67.7k]
  |  Branch (436:45): [True: 15, False: 9.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|  77.6k|            return pb_decode_fixed32(stream, field->pData);
  440|       |
  441|  54.4k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  270|  54.4k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (441:9): [True: 54.4k, False: 41.3M]
  ------------------
  442|  54.4k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (442:17): [True: 10.4k, False: 44.0k]
  |  Branch (442:45): [True: 12, False: 10.4k]
  ------------------
  443|     12|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     12|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     12|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|  54.4k|            return pb_decode_fixed64(stream, field->pData);
  456|      0|#endif
  457|       |
  458|   943k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  277|   943k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (458:9): [True: 943k, False: 40.4M]
  ------------------
  459|   943k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (459:17): [True: 12, False: 943k]
  ------------------
  460|     12|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     12|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     12|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  461|       |
  462|   943k|            return pb_dec_bytes(stream, field);
  463|       |
  464|  95.3k|        case PB_LTYPE_STRING:
  ------------------
  |  |  281|  95.3k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (464:9): [True: 95.3k, False: 41.2M]
  ------------------
  465|  95.3k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (465:17): [True: 12, False: 95.2k]
  ------------------
  466|     12|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     12|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     12|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  467|       |
  468|  95.2k|            return pb_dec_string(stream, field);
  469|       |
  470|   160k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  285|   160k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (470:9): [True: 160k, False: 41.2M]
  ------------------
  471|   160k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  290|   160k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (471:9): [True: 0, False: 41.3M]
  ------------------
  472|   160k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (472:17): [True: 25, False: 160k]
  ------------------
  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|   160k|            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: 14.9M]
  ------------------
  478|  26.4M|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (478:17): [True: 8, False: 26.4M]
  ------------------
  479|      8|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|      8|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      8|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  480|       |
  481|  26.4M|            return pb_dec_fixed_length_bytes(stream, field);
  482|       |
  483|      0|        default:
  ------------------
  |  Branch (483:9): [True: 0, False: 41.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|  41.3M|    }
  486|  41.3M|}
pb_decode.c:pb_dec_bool:
 1456|  3.89M|{
 1457|  3.89M|    return pb_decode_bool(stream, (bool*)field->pData);
 1458|  3.89M|}
pb_decode.c:pb_dec_varint:
 1461|  9.72M|{
 1462|  9.72M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  325|  9.72M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  9.72M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  267|  9.72M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1462:9): [True: 752k, False: 8.97M]
  ------------------
 1463|   752k|    {
 1464|   752k|        pb_uint64_t value, clamped;
  ------------------
  |  |   57|   752k|#define pb_uint64_t uint64_t
  ------------------
 1465|   752k|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1465:13): [True: 27, False: 752k]
  ------------------
 1466|     27|            return false;
 1467|       |
 1468|       |        /* Cast to the proper field size, while checking for overflows */
 1469|   752k|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1469:13): [True: 420k, False: 332k]
  ------------------
 1470|   420k|            clamped = *(pb_uint64_t*)field->pData = value;
 1471|   332k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1471:18): [True: 310k, False: 21.5k]
  ------------------
 1472|   310k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1473|  21.5k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1473:18): [True: 10.7k, False: 10.8k]
  ------------------
 1474|  10.7k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1475|  10.8k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1475:18): [True: 10.8k, False: 0]
  ------------------
 1476|  10.8k|            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|   752k|        if (clamped != value)
  ------------------
  |  Branch (1480:13): [True: 110, False: 752k]
  ------------------
 1481|    110|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  920|    110|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|    110|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 110]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1482|       |
 1483|   752k|        return true;
 1484|   752k|    }
 1485|  8.97M|    else
 1486|  8.97M|    {
 1487|  8.97M|        pb_uint64_t value;
  ------------------
  |  |   57|  8.97M|#define pb_uint64_t uint64_t
  ------------------
 1488|  8.97M|        pb_int64_t svalue;
  ------------------
  |  |   56|  8.97M|#define pb_int64_t int64_t
  ------------------
 1489|  8.97M|        pb_int64_t clamped;
  ------------------
  |  |   56|  8.97M|#define pb_int64_t int64_t
  ------------------
 1490|       |
 1491|  8.97M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  325|  8.97M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  8.97M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  268|  8.97M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1491:13): [True: 4.17M, False: 4.79M]
  ------------------
 1492|  4.17M|        {
 1493|  4.17M|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1493:17): [True: 38, False: 4.17M]
  ------------------
 1494|     38|                return false;
 1495|  4.17M|        }
 1496|  4.79M|        else
 1497|  4.79M|        {
 1498|  4.79M|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1498:17): [True: 49, False: 4.79M]
  ------------------
 1499|     49|                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.79M|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1507:17): [True: 1.12M, False: 3.67M]
  ------------------
 1508|  1.12M|                svalue = (pb_int64_t)value;
 1509|  3.67M|            else
 1510|  3.67M|                svalue = (int32_t)value;
 1511|  4.79M|        }
 1512|       |
 1513|       |        /* Cast to the proper field size, while checking for overflows */
 1514|  8.97M|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1514:13): [True: 5.23M, False: 3.73M]
  ------------------
 1515|  5.23M|            clamped = *(pb_int64_t*)field->pData = svalue;
 1516|  3.73M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1516:18): [True: 3.69M, False: 42.4k]
  ------------------
 1517|  3.69M|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1518|  42.4k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1518:18): [True: 21.2k, False: 21.1k]
  ------------------
 1519|  21.2k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1520|  21.1k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1520:18): [True: 21.1k, False: 0]
  ------------------
 1521|  21.1k|            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|  8.97M|        if (clamped != svalue)
  ------------------
  |  Branch (1525:13): [True: 95, False: 8.97M]
  ------------------
 1526|     95|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  920|     95|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     95|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 95]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1527|       |
 1528|  8.97M|        return true;
 1529|  8.97M|    }
 1530|  9.72M|}
pb_decode.c:pb_dec_bytes:
 1533|   943k|{
 1534|   943k|    uint32_t size;
 1535|   943k|    size_t alloc_size;
 1536|   943k|    pb_bytes_array_t *dest;
 1537|       |    
 1538|   943k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1538:9): [True: 24, False: 943k]
  ------------------
 1539|     24|        return false;
 1540|       |    
 1541|   943k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  339|   943k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1541:9): [True: 36, False: 943k]
  ------------------
 1542|     36|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  920|     36|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     36|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 36]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1543|       |    
 1544|   943k|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  403|   943k|#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes))
  ------------------
 1545|   943k|    if (size > alloc_size)
  ------------------
  |  Branch (1545:9): [True: 0, False: 943k]
  ------------------
 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|   943k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|   943k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   943k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|   943k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1548:9): [True: 943k, False: 0]
  ------------------
 1549|   943k|    {
 1550|       |#ifndef PB_ENABLE_MALLOC
 1551|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1552|       |#else
 1553|   943k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1553:13): [True: 32, False: 943k]
  ------------------
 1554|     32|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1555|       |
 1556|   943k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1556:13): [True: 0, False: 943k]
  ------------------
 1557|      0|            return false;
 1558|   943k|        dest = *(pb_bytes_array_t**)field->pData;
 1559|   943k|#endif
 1560|   943k|    }
 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|   943k|    dest->size = (pb_size_t)size;
 1569|   943k|    return pb_read(stream, dest->bytes, (size_t)size);
 1570|   943k|}
pb_decode.c:allocate_field:
  584|  31.1M|{    
  585|  31.1M|    void *ptr = *(void**)pData;
  586|       |    
  587|  31.1M|    if (data_size == 0 || array_size == 0)
  ------------------
  |  Branch (587:9): [True: 0, False: 31.1M]
  |  Branch (587:27): [True: 0, False: 31.1M]
  ------------------
  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.1M|    {
  606|  31.1M|        const size_t check_limit = (size_t)1 << (sizeof(size_t) * 4);
  607|  31.1M|        if (data_size >= check_limit || array_size >= check_limit)
  ------------------
  |  Branch (607:13): [True: 0, False: 31.1M]
  |  Branch (607:41): [True: 0, False: 31.1M]
  ------------------
  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.1M|    }
  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.1M|    ptr = pb_realloc(ptr, array_size * data_size);
  ------------------
  |  |    3|  31.1M|#define pb_realloc(ptr,size) realloc_with_check(ptr,size)
  ------------------
  621|  31.1M|    if (ptr == NULL)
  ------------------
  |  Branch (621:9): [True: 0, False: 31.1M]
  ------------------
  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.1M|    *(void**)pData = ptr;
  625|       |    return true;
  626|  31.1M|}
pb_decode.c:pb_dec_string:
 1573|  95.2k|{
 1574|  95.2k|    uint32_t size;
 1575|  95.2k|    size_t alloc_size;
 1576|  95.2k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1577|       |
 1578|  95.2k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1578:9): [True: 27, False: 95.2k]
  ------------------
 1579|     27|        return false;
 1580|       |
 1581|  95.2k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1581:9): [True: 3, False: 95.2k]
  ------------------
 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|  95.2k|    alloc_size = (size_t)(size + 1);
 1586|       |
 1587|  95.2k|    if (alloc_size < size)
  ------------------
  |  Branch (1587:9): [True: 0, False: 95.2k]
  ------------------
 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|  95.2k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|  95.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  95.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|  95.2k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1590:9): [True: 93.1k, False: 2.07k]
  ------------------
 1591|  93.1k|    {
 1592|       |#ifndef PB_ENABLE_MALLOC
 1593|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1594|       |#else
 1595|  93.1k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1595:13): [True: 65, False: 93.1k]
  ------------------
 1596|     65|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  920|     65|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     65|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 65]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1597|       |
 1598|  93.1k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1598:13): [True: 0, False: 93.1k]
  ------------------
 1599|      0|            return false;
 1600|  93.1k|        dest = *(pb_byte_t**)field->pData;
 1601|  93.1k|#endif
 1602|  93.1k|    }
 1603|  2.07k|    else
 1604|  2.07k|    {
 1605|  2.07k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1605:13): [True: 52, False: 2.01k]
  ------------------
 1606|     52|            PB_RETURN_ERROR(stream, "string overflow");
  ------------------
  |  |  920|     52|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     52|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 52]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1607|  2.07k|    }
 1608|       |    
 1609|  95.1k|    dest[size] = 0;
 1610|       |
 1611|  95.1k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1611:9): [True: 2, False: 95.1k]
  ------------------
 1612|      2|        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|  95.1k|    return true;
 1620|  95.1k|}
pb_decode.c:pb_dec_submessage:
 1623|   160k|{
 1624|   160k|    bool status = true;
 1625|   160k|    bool submsg_consumed = false;
 1626|   160k|    pb_istream_t substream;
 1627|       |
 1628|   160k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1628:9): [True: 137, False: 160k]
  ------------------
 1629|    137|        return false;
 1630|       |    
 1631|   160k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1631:9): [True: 0, False: 160k]
  ------------------
 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|   160k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  325|   160k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   160k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  290|   321k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1637:9): [True: 0, False: 160k]
  |  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|   160k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1653:9): [True: 160k, False: 0]
  |  Branch (1653:19): [True: 160k, False: 0]
  ------------------
 1654|   160k|    {
 1655|   160k|        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|   160k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  323|   160k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   160k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  318|   321k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1659:13): [True: 9.47k, False: 151k]
  ------------------
 1660|  9.47k|            PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  324|  9.47k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  9.47k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  311|  9.47k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1660:13): [True: 9.47k, False: 0]
  ------------------
 1661|  9.47k|        {
 1662|  9.47k|            flags = PB_DECODE_NOINIT;
  ------------------
  |  |  110|  9.47k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1663|  9.47k|        }
 1664|       |
 1665|   160k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1666|   160k|    }
 1667|       |    
 1668|   160k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1668:9): [True: 0, False: 160k]
  ------------------
 1669|      0|        return false;
 1670|       |
 1671|   160k|    return status;
 1672|   160k|}
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: 3, False: 26.4M]
  ------------------
 1679|      3|        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: 31, False: 26.4M]
  ------------------
 1682|     31|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  920|     31|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     31|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1683|       |
 1684|  26.4M|    if (size == 0)
  ------------------
  |  Branch (1684:9): [True: 25.4M, False: 1.00M]
  ------------------
 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.00M|    if (size != field->data_size)
  ------------------
  |  Branch (1691:9): [True: 49, False: 1.00M]
  ------------------
 1692|     49|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  920|     49|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     49|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 49]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1693|       |
 1694|  1.00M|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1695|  1.00M|}
pb_decode.c:decode_pointer_field:
  646|  29.1M|{
  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.1M|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  324|  29.1M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  29.1M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  653|  29.1M|    {
  654|  1.56M|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  308|  1.56M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (654:9): [True: 1.56M, False: 27.5M]
  ------------------
  655|  1.58M|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  309|  1.58M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (655:9): [True: 17.6k, False: 29.1M]
  ------------------
  656|  1.60M|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  313|  1.60M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (656:9): [True: 19.1k, False: 29.1M]
  ------------------
  657|  1.60M|            if (PB_LTYPE_IS_SUBMSG(field->type) && *(void**)field->pField != NULL)
  ------------------
  |  |  326|  3.20M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|  1.60M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  1.60M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  3.20M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 78.5k, False: 1.52M]
  |  |  ------------------
  |  |  327|  3.20M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|  1.52M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  1.52M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|  1.52M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 1.52M]
  |  |  ------------------
  ------------------
  |  Branch (657:52): [True: 39.7k, False: 38.8k]
  ------------------
  658|  39.7k|            {
  659|       |                /* Duplicate field, have to release the old allocation first. */
  660|       |                /* FIXME: Does this work correctly for oneofs? */
  661|  39.7k|                pb_release_single_field(field);
  662|  39.7k|            }
  663|       |        
  664|  1.60M|            if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|  1.60M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  1.60M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|  1.60M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (664:17): [True: 19.1k, False: 1.58M]
  ------------------
  665|  19.1k|            {
  666|  19.1k|                *(pb_size_t*)field->pSize = field->tag;
  667|  19.1k|            }
  668|       |
  669|  1.60M|            if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  325|  1.60M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  1.60M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  281|  3.20M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (669:17): [True: 75.0k, False: 1.52M]
  ------------------
  670|  1.52M|                PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  325|  1.52M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  1.52M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  277|  1.52M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (670:17): [True: 19.1k, False: 1.50M]
  ------------------
  671|  94.1k|            {
  672|       |                /* pb_dec_string and pb_dec_bytes handle allocation themselves */
  673|  94.1k|                field->pData = field->pField;
  674|  94.1k|                return decode_basic_field(stream, wire_type, field);
  675|  94.1k|            }
  676|  1.50M|            else
  677|  1.50M|            {
  678|  1.50M|                if (!allocate_field(stream, field->pField, field->data_size, 1))
  ------------------
  |  Branch (678:21): [True: 0, False: 1.50M]
  ------------------
  679|      0|                    return false;
  680|       |                
  681|  1.50M|                field->pData = *(void**)field->pField;
  682|  1.50M|                initialize_pointer_field(field->pData, field);
  683|  1.50M|                return decode_basic_field(stream, wire_type, field);
  684|  1.50M|            }
  685|       |    
  686|  27.5M|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  311|  27.5M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (686:9): [True: 27.5M, False: 1.60M]
  ------------------
  687|  27.5M|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (687:17): [True: 27.5M, False: 8.79k]
  ------------------
  688|  27.5M|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  325|  27.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  27.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  273|  27.5M|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (688:20): [True: 78.0k, False: 27.4M]
  ------------------
  689|  78.0k|            {
  690|       |                /* Packed array, multiple items come in at once. */
  691|  78.0k|                bool status = true;
  692|  78.0k|                pb_size_t *size = (pb_size_t*)field->pSize;
  693|  78.0k|                size_t allocated_size = *size;
  694|  78.0k|                pb_istream_t substream;
  695|       |                
  696|  78.0k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (696:21): [True: 47, False: 77.9k]
  ------------------
  697|     47|                    return false;
  698|       |                
  699|  12.3M|                while (substream.bytes_left)
  ------------------
  |  Branch (699:24): [True: 12.3M, False: 77.8k]
  ------------------
  700|  12.3M|                {
  701|  12.3M|                    if (*size == PB_SIZE_MAX)
  ------------------
  |  |  339|  12.3M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (701:25): [True: 7, False: 12.3M]
  ------------------
  702|      7|                    {
  703|      7|#ifndef PB_NO_ERRMSG
  704|      7|                        stream->errmsg = "too many array entries";
  705|      7|#endif
  706|      7|                        status = false;
  707|      7|                        break;
  708|      7|                    }
  709|       |
  710|  12.3M|                    if ((size_t)*size + 1 > allocated_size)
  ------------------
  |  Branch (710:25): [True: 1.12M, False: 11.2M]
  ------------------
  711|  1.12M|                    {
  712|       |                        /* Allocate more storage. This tries to guess the
  713|       |                         * number of remaining entries. Round the division
  714|       |                         * upwards. */
  715|  1.12M|                        size_t remain = (substream.bytes_left - 1) / field->data_size + 1;
  716|  1.12M|                        if (remain < PB_SIZE_MAX - allocated_size)
  ------------------
  |  |  339|  1.12M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (716:29): [True: 268k, False: 852k]
  ------------------
  717|   268k|                            allocated_size += remain;
  718|   852k|                        else
  719|   852k|                            allocated_size += 1;
  720|       |                        
  721|  1.12M|                        if (!allocate_field(&substream, field->pField, field->data_size, allocated_size))
  ------------------
  |  Branch (721:29): [True: 0, False: 1.12M]
  ------------------
  722|      0|                        {
  723|      0|                            status = false;
  724|      0|                            break;
  725|      0|                        }
  726|  1.12M|                    }
  727|       |
  728|       |                    /* Decode the array entry */
  729|  12.3M|                    field->pData = *(char**)field->pField + field->data_size * (*size);
  730|  12.3M|                    if (field->pData == NULL)
  ------------------
  |  Branch (730:25): [True: 0, False: 12.3M]
  ------------------
  731|      0|                    {
  732|       |                        /* Shouldn't happen, but satisfies static analyzers */
  733|      0|                        status = false;
  734|      0|                        break;
  735|      0|                    }
  736|  12.3M|                    initialize_pointer_field(field->pData, field);
  737|  12.3M|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (737:25): [True: 91, False: 12.3M]
  ------------------
  738|     91|                    {
  739|     91|                        status = false;
  740|     91|                        break;
  741|     91|                    }
  742|       |                    
  743|  12.3M|                    (*size)++;
  744|  12.3M|                }
  745|  77.9k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (745:21): [True: 0, False: 77.9k]
  ------------------
  746|      0|                    return false;
  747|       |                
  748|  77.9k|                return status;
  749|  77.9k|            }
  750|  27.4M|            else
  751|  27.4M|            {
  752|       |                /* Normal repeated field, i.e. only one item at a time. */
  753|  27.4M|                pb_size_t *size = (pb_size_t*)field->pSize;
  754|       |
  755|  27.4M|                if (*size == PB_SIZE_MAX)
  ------------------
  |  |  339|  27.4M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (755:21): [True: 1, False: 27.4M]
  ------------------
  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.4M|                if (!allocate_field(stream, field->pField, field->data_size, (size_t)(*size + 1)))
  ------------------
  |  Branch (758:21): [True: 0, False: 27.4M]
  ------------------
  759|      0|                    return false;
  760|       |            
  761|  27.4M|                field->pData = *(char**)field->pField + field->data_size * (*size);
  762|  27.4M|                (*size)++;
  763|  27.4M|                initialize_pointer_field(field->pData, field);
  764|  27.4M|                return decode_basic_field(stream, wire_type, field);
  765|  27.4M|            }
  766|       |
  767|      0|        default:
  ------------------
  |  Branch (767:9): [True: 0, False: 29.1M]
  ------------------
  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.1M|    }
  770|  29.1M|#endif
  771|  29.1M|}
pb_decode.c:initialize_pointer_field:
  630|  41.2M|{
  631|  41.2M|    if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  325|  41.2M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  41.2M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  281|  82.5M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (631:9): [True: 18.1k, False: 41.2M]
  ------------------
  632|  41.2M|        PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  325|  41.2M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  41.2M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  277|  41.2M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (632:9): [True: 924k, False: 40.3M]
  ------------------
  633|   942k|    {
  634|   942k|        *(void**)pItem = NULL;
  635|   942k|    }
  636|  40.3M|    else if (PB_LTYPE_IS_SUBMSG(field->type))
  ------------------
  |  |  326|  40.3M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|  40.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  40.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  80.6M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 151k, False: 40.1M]
  |  |  ------------------
  |  |  327|  40.3M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|  40.1M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  40.1M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|  40.1M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 40.1M]
  |  |  ------------------
  ------------------
  637|   151k|    {
  638|       |        /* We memset to zero so that any callbacks are set to NULL.
  639|       |         * Default values will be set by pb_dec_submessage(). */
  640|   151k|        memset(pItem, 0, field->data_size);
  641|   151k|    }
  642|  41.2M|}
pb_decode.c:pb_release_single_field:
 1265|   995k|{
 1266|   995k|    pb_type_t type;
 1267|   995k|    type = field->type;
 1268|       |
 1269|   995k|    if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|   995k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   995k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|   995k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (1269:9): [True: 46.8k, False: 948k]
  ------------------
 1270|  46.8k|    {
 1271|  46.8k|        if (*(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (1271:13): [True: 23.8k, False: 23.0k]
  ------------------
 1272|  23.8k|            return; /* This is not the current field in the union */
 1273|  46.8k|    }
 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|   971k|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|   971k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   971k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|   971k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1278:9): [True: 8.29k, False: 963k]
  ------------------
 1279|  8.29k|    {
 1280|       |        /* Release fields from all extensions in the linked list */
 1281|  8.29k|        pb_extension_t *ext = *(pb_extension_t**)field->pData;
 1282|  15.0k|        while (ext != NULL)
  ------------------
  |  Branch (1282:16): [True: 6.74k, False: 8.29k]
  ------------------
 1283|  6.74k|        {
 1284|  6.74k|            pb_field_iter_t ext_iter;
 1285|  6.74k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (1285:17): [True: 6.74k, False: 0]
  ------------------
 1286|  6.74k|            {
 1287|  6.74k|                pb_release_single_field(&ext_iter);
 1288|  6.74k|            }
 1289|  6.74k|            ext = ext->next;
 1290|  6.74k|        }
 1291|  8.29k|    }
 1292|   963k|    else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  326|  1.92M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|   963k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|   963k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  1.92M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 133k, False: 830k]
  |  |  ------------------
  |  |  327|  1.92M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|   830k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|   830k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|   830k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 830k]
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|   133k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   133k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  320|   133k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1292:42): [True: 133k, False: 0]
  ------------------
 1293|   133k|    {
 1294|       |        /* Release fields in submessage or submsg array */
 1295|   133k|        pb_size_t count = 1;
 1296|       |        
 1297|   133k|        if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|   133k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   133k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|   133k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1297:13): [True: 122k, False: 10.6k]
  ------------------
 1298|   122k|        {
 1299|   122k|            field->pData = *(void**)field->pField;
 1300|   122k|        }
 1301|  10.6k|        else
 1302|  10.6k|        {
 1303|  10.6k|            field->pData = field->pField;
 1304|  10.6k|        }
 1305|       |        
 1306|   133k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  324|   133k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   133k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  311|   133k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1306:13): [True: 16.5k, False: 116k]
  ------------------
 1307|  16.5k|        {
 1308|  16.5k|            count = *(pb_size_t*)field->pSize;
 1309|       |
 1310|  16.5k|            if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  323|  16.5k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  16.5k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  318|  33.1k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1310:17): [True: 0, False: 16.5k]
  |  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.5k|        }
 1316|       |        
 1317|   133k|        if (field->pData)
  ------------------
  |  Branch (1317:13): [True: 91.3k, False: 41.8k]
  ------------------
 1318|  91.3k|        {
 1319|   253k|            for (; count > 0; count--)
  ------------------
  |  Branch (1319:20): [True: 162k, False: 91.3k]
  ------------------
 1320|   162k|            {
 1321|   162k|                pb_release(field->submsg_desc, field->pData);
 1322|   162k|                field->pData = (char*)field->pData + field->data_size;
 1323|   162k|            }
 1324|  91.3k|        }
 1325|   133k|    }
 1326|       |    
 1327|   971k|    if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|   971k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   971k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|   971k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1327:9): [True: 945k, False: 25.7k]
  ------------------
 1328|   945k|    {
 1329|   945k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  324|   945k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   945k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  311|  1.89M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1329:13): [True: 174k, False: 771k]
  ------------------
 1330|   174k|            (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  325|   174k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   174k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  281|   348k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (1330:14): [True: 8.29k, False: 165k]
  ------------------
 1331|   165k|             PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  325|   165k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   165k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                           PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  277|   165k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (1331:14): [True: 8.29k, False: 157k]
  ------------------
 1332|  16.5k|        {
 1333|       |            /* Release entries in repeated string or bytes array */
 1334|  16.5k|            void **pItem = *(void***)field->pField;
 1335|  16.5k|            pb_size_t count = *(pb_size_t*)field->pSize;
 1336|   958k|            for (; count > 0; count--)
  ------------------
  |  Branch (1336:20): [True: 942k, False: 16.5k]
  ------------------
 1337|   942k|            {
 1338|   942k|                pb_free(*pItem);
  ------------------
  |  |    4|   942k|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1339|   942k|                *pItem++ = NULL;
 1340|   942k|            }
 1341|  16.5k|        }
 1342|       |        
 1343|   945k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  324|   945k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   945k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  311|   945k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1343:13): [True: 174k, False: 771k]
  ------------------
 1344|   174k|        {
 1345|       |            /* We are going to release the array, so set the size to 0 */
 1346|   174k|            *(pb_size_t*)field->pSize = 0;
 1347|   174k|        }
 1348|       |        
 1349|       |        /* Release main pointer */
 1350|   945k|        pb_free(*(void**)field->pField);
  ------------------
  |  |    4|   945k|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1351|       |        *(void**)field->pField = NULL;
 1352|   945k|    }
 1353|   971k|}

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

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

flakystream_callback:
    5|  32.2M|{
    6|  32.2M|    flakystream_t *state = stream->state;
    7|       |
    8|  32.2M|    if (state->position + count > state->msglen)
  ------------------
  |  Branch (8:9): [True: 1.54k, False: 32.2M]
  ------------------
    9|  1.54k|    {
   10|  1.54k|        stream->bytes_left = 0;
   11|  1.54k|        return false;
   12|  1.54k|    }
   13|  32.2M|    else if (state->position + count > state->fail_after)
  ------------------
  |  Branch (13:14): [True: 0, False: 32.2M]
  ------------------
   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|  32.2M|    memcpy(buf, state->buffer + state->position, count);
   19|  32.2M|    state->position += count;
   20|       |    return true;
   21|  32.2M|}
flakystream_init:
   24|  1.54k|{
   25|  1.54k|    memset(stream, 0, sizeof(*stream));
   26|  1.54k|    stream->stream.callback = flakystream_callback;
   27|       |    stream->stream.bytes_left = SIZE_MAX;
   28|  1.54k|    stream->stream.state = stream;
   29|  1.54k|    stream->buffer = buffer;
   30|  1.54k|    stream->position = 0;
   31|  1.54k|    stream->msglen = msglen;
   32|  1.54k|    stream->fail_after = fail_after;
   33|  1.54k|}

do_roundtrip:
  209|  1.54k|{
  210|  1.54k|    bool status;
  211|  1.54k|    uint32_t checksum2, checksum3;
  212|  1.54k|    size_t msglen2, msglen3;
  213|  1.54k|    uint8_t *buf2 = malloc_with_check(g_bufsize);
  214|  1.54k|    void *msg = malloc_with_check(structsize);
  215|       |
  216|       |    /* For proto2 types, we also test extension fields */
  217|  1.54k|    alltypes_static_TestExtension extmsg = alltypes_static_TestExtension_init_zero;
  ------------------
  |  |  248|  1.54k|#define alltypes_static_TestExtension_init_zero  {false, ""}
  ------------------
  218|  1.54k|    pb_extension_t ext = pb_extension_init_zero;
  ------------------
  |  |  503|  1.54k|#define pb_extension_init_zero {NULL,NULL,NULL,false}
  ------------------
  219|  1.54k|    pb_extension_t **ext_field = NULL;
  220|  1.54k|    ext.type = &alltypes_static_TestExtension_testextension;
  221|  1.54k|    ext.dest = &extmsg;
  222|  1.54k|    ext.next = NULL;
  223|       |
  224|  1.54k|    assert(buf2 && msg);
  ------------------
  |  Branch (224:5): [True: 0, False: 1.54k]
  |  Branch (224:5): [True: 0, False: 0]
  |  Branch (224:5): [True: 1.54k, False: 0]
  |  Branch (224:5): [True: 1.54k, False: 0]
  ------------------
  225|       |
  226|  1.54k|    if (msgtype == alltypes_static_AllTypes_fields)
  ------------------
  |  |  490|  1.54k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (226:9): [True: 0, False: 1.54k]
  ------------------
  227|      0|    {
  228|      0|        ext_field = &((alltypes_static_AllTypes*)msg)->extensions;
  229|      0|    }
  230|  1.54k|    else if (msgtype == alltypes_pointer_AllTypes_fields)
  ------------------
  |  |  465|  1.54k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  |  Branch (230:14): [True: 1.54k, False: 0]
  ------------------
  231|  1.54k|    {
  232|  1.54k|        ext_field = &((alltypes_pointer_AllTypes*)msg)->extensions;
  233|  1.54k|    }
  234|       |    
  235|       |    /* Decode and encode the input data.
  236|       |     * This will bring it into canonical format.
  237|       |     */
  238|  1.54k|    {
  239|  1.54k|        pb_istream_t stream = pb_istream_from_buffer(buffer, msglen);
  240|  1.54k|        memset(msg, 0, structsize);
  241|  1.54k|        if (ext_field) *ext_field = &ext;
  ------------------
  |  Branch (241:13): [True: 1.54k, False: 0]
  ------------------
  242|  1.54k|        status = pb_decode(&stream, msgtype, msg);
  243|  1.54k|        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.54k]
  ------------------
  244|  1.54k|        assert(status);
  ------------------
  |  Branch (244:9): [True: 0, False: 1.54k]
  |  Branch (244:9): [True: 1.54k, False: 0]
  ------------------
  245|       |
  246|  1.54k|        validate_message(msg, structsize, msgtype);
  247|  1.54k|    }
  248|       |    
  249|  1.54k|    {
  250|  1.54k|        pb_ostream_t stream = pb_ostream_from_buffer(buf2, g_bufsize);
  251|  1.54k|        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.54k|        if (!status && strcmp(PB_GET_ERROR(&stream), "stream full") != 0)
  ------------------
  |  |  917|    213|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (917:31): [True: 213, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (255:13): [True: 213, False: 1.32k]
  |  Branch (255:24): [True: 0, False: 213]
  ------------------
  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.54k|        msglen2 = stream.bytes_written;
  262|  1.54k|        checksum2 = xor32_checksum(buf2, msglen2);
  263|  1.54k|    }
  264|       |    
  265|  1.54k|    pb_release(msgtype, msg);
  266|       |
  267|       |    /* Then decode from canonical format and re-encode. Result should remain the same. */
  268|  1.54k|    if (status)
  ------------------
  |  Branch (268:9): [True: 1.32k, False: 213]
  ------------------
  269|  1.32k|    {
  270|  1.32k|        pb_istream_t stream = pb_istream_from_buffer(buf2, msglen2);
  271|  1.32k|        memset(msg, 0, structsize);
  272|  1.32k|        if (ext_field) *ext_field = &ext;
  ------------------
  |  Branch (272:13): [True: 1.32k, False: 0]
  ------------------
  273|  1.32k|        status = pb_decode(&stream, msgtype, msg);
  274|  1.32k|        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.32k]
  ------------------
  275|  1.32k|        assert(status);
  ------------------
  |  Branch (275:9): [True: 0, False: 1.32k]
  |  Branch (275:9): [True: 1.32k, False: 0]
  ------------------
  276|       |
  277|  1.32k|        validate_message(msg, structsize, msgtype);
  278|  1.32k|    }
  279|       |    
  280|  1.54k|    if (status)
  ------------------
  |  Branch (280:9): [True: 1.32k, False: 213]
  ------------------
  281|  1.32k|    {
  282|  1.32k|        pb_ostream_t stream = pb_ostream_from_buffer(buf2, g_bufsize);
  283|  1.32k|        status = pb_encode(&stream, msgtype, msg);
  284|  1.32k|        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.32k]
  ------------------
  285|  1.32k|        assert(status);
  ------------------
  |  Branch (285:9): [True: 0, False: 1.32k]
  |  Branch (285:9): [True: 1.32k, False: 0]
  ------------------
  286|  1.32k|        msglen3 = stream.bytes_written;
  287|  1.32k|        checksum3 = xor32_checksum(buf2, msglen3);
  288|       |
  289|  1.32k|        assert(msglen2 == msglen3);
  ------------------
  |  Branch (289:9): [True: 0, False: 1.32k]
  |  Branch (289:9): [True: 1.32k, False: 0]
  ------------------
  290|  1.32k|        assert(checksum2 == checksum3);
  ------------------
  |  Branch (290:9): [True: 0, False: 1.32k]
  |  Branch (290:9): [True: 1.32k, False: 0]
  ------------------
  291|  1.32k|    }
  292|       |    
  293|  1.54k|    pb_release(msgtype, msg);
  294|  1.54k|    free_with_check(msg);
  295|  1.54k|    free_with_check(buf2);
  296|  1.54k|}
do_roundtrips:
  300|  3.66k|{
  301|  3.66k|    size_t initial_alloc_count = get_alloc_count();
  302|  3.66k|    PB_UNUSED(expect_valid); /* Potentially unused depending on configuration */
  ------------------
  |  |  169|  3.66k|#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.66k|#ifdef FUZZTEST_PROTO2_POINTER
  322|  3.66k|    if (do_decode(data, size, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, 0, expect_valid))
  ------------------
  |  |  465|  3.66k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  |  Branch (322:9): [True: 1.54k, False: 2.12k]
  ------------------
  323|  1.54k|    {
  324|  1.54k|        do_roundtrip(data, size, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields);
  ------------------
  |  |  465|  1.54k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  325|  1.54k|        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, 0, true);
  ------------------
  |  |  465|  1.54k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  326|  1.54k|    }
  327|  3.66k|#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.66k]
  |  Branch (359:5): [True: 3.66k, False: 0]
  ------------------
  360|  3.66k|}
LLVMFuzzerTestOneInput:
  364|  3.66k|{
  365|  3.66k|    if (size > g_bufsize)
  ------------------
  |  Branch (365:9): [True: 4, False: 3.66k]
  ------------------
  366|      4|        return 0;
  367|       |
  368|  3.66k|    do_roundtrips(data, size, false);
  369|       |
  370|  3.66k|    return 0;
  371|  3.66k|}
fuzztest.c:xor32_checksum:
   52|  2.87k|{
   53|  2.87k|    const uint8_t *buf = (const uint8_t*)data;
   54|  2.87k|    uint32_t checksum = 1234;
   55|  78.0M|    for (; len > 0; len--)
  ------------------
  |  Branch (55:12): [True: 78.0M, False: 2.87k]
  ------------------
   56|  78.0M|    {
   57|  78.0M|        checksum ^= checksum << 13;
   58|  78.0M|        checksum ^= checksum >> 17;
   59|  78.0M|        checksum ^= checksum << 5;
   60|  78.0M|        checksum += *buf++;
   61|  78.0M|    }
   62|  2.87k|    return checksum;
   63|  2.87k|}
fuzztest.c:do_decode:
   66|  3.66k|{
   67|  3.66k|    bool status;
   68|  3.66k|    pb_istream_t stream;
   69|  3.66k|    size_t initial_alloc_count = get_alloc_count();
   70|  3.66k|    uint8_t *buf2 = malloc_with_check(g_bufsize); /* This is just to match the amount of memory allocations in do_roundtrips(). */
   71|  3.66k|    void *msg = malloc_with_check(structsize);
   72|  3.66k|    alltypes_static_TestExtension extmsg = alltypes_static_TestExtension_init_zero;
  ------------------
  |  |  248|  3.66k|#define alltypes_static_TestExtension_init_zero  {false, ""}
  ------------------
   73|  3.66k|    pb_extension_t ext = pb_extension_init_zero;
  ------------------
  |  |  503|  3.66k|#define pb_extension_init_zero {NULL,NULL,NULL,false}
  ------------------
   74|  3.66k|    assert(msg);
  ------------------
  |  Branch (74:5): [True: 0, False: 3.66k]
  |  Branch (74:5): [True: 3.66k, False: 0]
  ------------------
   75|       |
   76|  3.66k|    memset(msg, 0, structsize);
   77|  3.66k|    ext.type = &alltypes_static_TestExtension_testextension;
   78|  3.66k|    ext.dest = &extmsg;
   79|  3.66k|    ext.next = NULL;
   80|       |
   81|  3.66k|    if (msgtype == alltypes_static_AllTypes_fields)
  ------------------
  |  |  490|  3.66k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (81:9): [True: 0, False: 3.66k]
  ------------------
   82|      0|    {
   83|      0|        ((alltypes_static_AllTypes*)msg)->extensions = &ext;
   84|      0|    }
   85|  3.66k|    else if (msgtype == alltypes_pointer_AllTypes_fields)
  ------------------
  |  |  465|  3.66k|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  |  Branch (85:14): [True: 3.66k, False: 0]
  ------------------
   86|  3.66k|    {
   87|  3.66k|        ((alltypes_pointer_AllTypes*)msg)->extensions = &ext;
   88|  3.66k|    }
   89|       |
   90|  3.66k|    stream = pb_istream_from_buffer(buffer, msglen);
   91|  3.66k|    status = pb_decode_ex(&stream, msgtype, msg, flags);
   92|       |
   93|  3.66k|    if (status)
  ------------------
  |  Branch (93:9): [True: 1.54k, False: 2.12k]
  ------------------
   94|  1.54k|    {
   95|  1.54k|        validate_message(msg, structsize, msgtype);
   96|  1.54k|    }
   97|       |
   98|  3.66k|    if (assert_success)
  ------------------
  |  Branch (98:9): [True: 0, False: 3.66k]
  ------------------
   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.66k|    if (status)
  ------------------
  |  Branch (104:9): [True: 1.54k, False: 2.12k]
  ------------------
  105|  1.54k|    {
  106|       |        /* On error return, pb_release() should be called automatically. */
  107|  1.54k|        pb_release(msgtype, msg);
  108|  1.54k|    }
  109|       |
  110|  3.66k|    free_with_check(msg);
  111|  3.66k|    free_with_check(buf2);
  112|  3.66k|    assert(get_alloc_count() == initial_alloc_count);
  ------------------
  |  Branch (112:5): [True: 0, False: 3.66k]
  |  Branch (112:5): [True: 3.66k, False: 0]
  ------------------
  113|       |    
  114|  3.66k|    return status;
  115|  3.66k|}
fuzztest.c:do_stream_decode:
  118|  1.54k|{
  119|  1.54k|    bool status;
  120|  1.54k|    flakystream_t stream;
  121|  1.54k|    size_t initial_alloc_count = get_alloc_count();
  122|  1.54k|    void *msg = malloc_with_check(structsize);
  123|  1.54k|    assert(msg);
  ------------------
  |  Branch (123:5): [True: 0, False: 1.54k]
  |  Branch (123:5): [True: 1.54k, False: 0]
  ------------------
  124|       |
  125|  1.54k|    memset(msg, 0, structsize);
  126|  1.54k|    flakystream_init(&stream, buffer, msglen, fail_after);
  127|  1.54k|    status = pb_decode_ex(&stream.stream, msgtype, msg, flags);
  128|       |
  129|  1.54k|    if (status)
  ------------------
  |  Branch (129:9): [True: 1.54k, False: 0]
  ------------------
  130|  1.54k|    {
  131|  1.54k|        validate_message(msg, structsize, msgtype);
  132|  1.54k|    }
  133|       |
  134|  1.54k|    if (assert_success)
  ------------------
  |  Branch (134:9): [True: 1.54k, False: 0]
  ------------------
  135|  1.54k|    {
  136|  1.54k|        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.54k]
  ------------------
  137|  1.54k|        assert(status);
  ------------------
  |  Branch (137:9): [True: 0, False: 1.54k]
  |  Branch (137:9): [True: 1.54k, False: 0]
  ------------------
  138|  1.54k|    }
  139|       |
  140|  1.54k|    if (status)
  ------------------
  |  Branch (140:9): [True: 1.54k, False: 0]
  ------------------
  141|  1.54k|    {
  142|       |        /* On error return, pb_release() should be called automatically. */
  143|  1.54k|        pb_release(msgtype, msg);
  144|  1.54k|    }
  145|       |
  146|  1.54k|    free_with_check(msg);
  147|  1.54k|    assert(get_alloc_count() == initial_alloc_count);
  ------------------
  |  Branch (147:5): [True: 0, False: 1.54k]
  |  Branch (147:5): [True: 1.54k, False: 0]
  ------------------
  148|       |
  149|  1.54k|    return status;
  150|  1.54k|}

validate_static:
    7|  5.95k|{
    8|  5.95k|    pb_size_t count = 1;
    9|  5.95k|    pb_size_t i;
   10|  5.95k|    bool truebool = true;
   11|  5.95k|    bool falsebool = false;
   12|       |
   13|  5.95k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  324|  5.95k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  5.95k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  311|  11.9k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 0, False: 5.95k]
  |  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.95k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  324|  5.95k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  5.95k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  309|  11.9k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 0, False: 5.95k]
  |  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.95k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|  5.95k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  5.95k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|  5.95k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 5.95k, False: 0]
  ------------------
   26|  5.95k|    {
   27|  5.95k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 5.65k, False: 297]
  ------------------
   28|  5.65k|        {
   29|       |            /* Some different field in oneof */
   30|  5.65k|            return;
   31|  5.65k|        }
   32|  5.95k|    }
   33|       |
   34|    594|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 297, False: 297]
  ------------------
   35|    297|    {
   36|    297|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|    297|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  325|    297|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|    297|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  281|    297|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 0, False: 297]
  ------------------
   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|    297|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  325|    297|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|    297|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  277|    297|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 0, False: 297]
  ------------------
   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|    297|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  325|    297|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|    297|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  265|    297|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 0, False: 297]
  ------------------
   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|    297|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  326|    297|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|    297|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|    297|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|    594|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 297, False: 0]
  |  |  ------------------
  |  |  327|    297|                               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|    297|        {
   57|    297|            validate_message(pData, 0, iter->submsg_desc);
   58|    297|        }
   59|    297|    }
   60|    297|}
validate_pointer:
   63|   642k|{
   64|   642k|    pb_size_t count = 1;
   65|   642k|    pb_size_t i;
   66|   642k|    bool truebool = true;
   67|   642k|    bool falsebool = false;
   68|       |
   69|   642k|    if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|   642k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   642k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|   642k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (69:9): [True: 11.9k, False: 630k]
  ------------------
   70|  11.9k|    {
   71|  11.9k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (71:13): [True: 11.2k, False: 611]
  ------------------
   72|  11.2k|        {
   73|       |            /* Some different field in oneof */
   74|  11.2k|            return;
   75|  11.2k|        }
   76|  11.9k|    }
   77|   630k|    else if (!iter->pData)
  ------------------
  |  Branch (77:14): [True: 269k, False: 361k]
  ------------------
   78|   269k|    {
   79|       |        /* Nothing allocated */
   80|   269k|        if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize != &iter->array_size)
  ------------------
  |  |  324|   269k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   269k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize != &iter->array_size)
  ------------------
  |  |  311|   538k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (80:13): [True: 113k, False: 155k]
  |  Branch (80:58): [True: 102k, False: 11.4k]
  ------------------
   81|   102k|        {
   82|   102k|            assert(*(pb_size_t*)iter->pSize == 0);
  ------------------
  |  Branch (82:13): [True: 0, False: 102k]
  |  Branch (82:13): [True: 102k, False: 0]
  ------------------
   83|   102k|        }
   84|   269k|        return;
   85|   269k|    }
   86|       |
   87|   362k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  324|   362k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   362k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  311|   362k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (87:9): [True: 11.5k, False: 350k]
  ------------------
   88|  11.5k|    {
   89|       |        /* Check that enough memory has been allocated for array */
   90|  11.5k|        size_t allocated_size = get_allocation_size(iter->pData);
   91|  11.5k|        count = *(pb_size_t*)iter->pSize;
   92|  11.5k|        assert(allocated_size >= count * iter->data_size);
  ------------------
  |  Branch (92:9): [True: 0, False: 11.5k]
  |  Branch (92:9): [True: 11.5k, False: 0]
  ------------------
   93|  11.5k|    }
   94|   350k|    else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  325|   350k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   350k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  281|   701k|#define PB_LTYPE_STRING 0x07U
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  325|   298k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   298k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  277|   298k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (94:14): [True: 298k, False: 51.8k]
  |  Branch (94:57): [True: 292k, False: 6.64k]
  ------------------
   95|   292k|    {
   96|   292k|        size_t allocated_size = get_allocation_size(iter->pData);
   97|   292k|        assert(allocated_size >= iter->data_size);
  ------------------
  |  Branch (97:9): [True: 0, False: 292k]
  |  Branch (97:9): [True: 292k, False: 0]
  ------------------
   98|   292k|    }
   99|       |
  100|  37.3M|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (100:17): [True: 36.9M, False: 362k]
  ------------------
  101|  36.9M|    {
  102|  36.9M|        void *pData = (char*)iter->pData + iter->data_size * i;
  103|       |
  104|  36.9M|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  325|  36.9M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  36.9M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  281|  36.9M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (104:13): [True: 69.7k, False: 36.8M]
  ------------------
  105|  69.7k|        {
  106|       |            /* Check that enough memory is allocated for string and that
  107|       |               the string is properly terminated. */
  108|  69.7k|            const char *str = pData;
  109|       |
  110|  69.7k|            if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  324|  69.7k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  69.7k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  311|  69.7k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (110:17): [True: 17.9k, False: 51.8k]
  ------------------
  111|  17.9k|            {
  112|       |                /* String arrays are stored as array of pointers */
  113|  17.9k|                str = ((const char**)iter->pData)[i];
  114|  17.9k|            }
  115|       |
  116|  69.7k|            assert(strlen(str) + 1 <= get_allocation_size(str));
  ------------------
  |  Branch (116:13): [True: 0, False: 69.7k]
  |  Branch (116:13): [True: 69.7k, False: 0]
  ------------------
  117|  69.7k|        }
  118|  36.8M|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  325|  36.8M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  36.8M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  277|  36.8M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (118:18): [True: 862k, False: 36.0M]
  ------------------
  119|   862k|        {
  120|       |            /* Bytes length must be at most statically allocated size */
  121|   862k|            const pb_bytes_array_t *bytes = pData;
  122|       |
  123|   862k|            if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  324|   862k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   862k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  311|   862k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (123:17): [True: 855k, False: 6.64k]
  ------------------
  124|   855k|            {
  125|       |                /* Bytes arrays are stored as array of pointers */
  126|   855k|                bytes = ((const pb_bytes_array_t**)iter->pData)[i];
  127|   855k|            }
  128|       |
  129|   862k|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= get_allocation_size(bytes));
  ------------------
  |  Branch (129:13): [True: 0, False: 862k]
  |  Branch (129:13): [True: 862k, False: 0]
  ------------------
  130|   862k|        }
  131|  36.0M|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  325|  36.0M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  36.0M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  265|  36.0M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (131:18): [True: 1.52M, False: 34.5M]
  ------------------
  132|  1.52M|        {
  133|       |            /* Bool fields must have valid value */
  134|  1.52M|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (134:13): [True: 1.52M, False: 0]
  |  Branch (134:13): [True: 0, False: 0]
  |  Branch (134:13): [True: 231k, False: 1.29M]
  |  Branch (134:13): [True: 1.29M, False: 0]
  ------------------
  135|  1.52M|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
  136|  1.52M|        }
  137|  34.5M|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  326|  34.5M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|  34.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  34.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  69.0M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 102k, False: 34.4M]
  |  |  ------------------
  |  |  327|  34.5M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|  34.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  34.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|  34.4M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 34.4M]
  |  |  ------------------
  ------------------
  138|   102k|        {
  139|   102k|            validate_message(pData, 0, iter->submsg_desc);
  140|   102k|        }
  141|  36.9M|    }
  142|   362k|}
validate_message:
  145|   109k|{
  146|   109k|    pb_field_iter_t iter;
  147|       |
  148|   109k|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 69.3k, False: 39.8k]
  ------------------
  149|  69.3k|    {
  150|  69.3k|        do
  151|   654k|        {
  152|   654k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  323|   654k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   654k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  318|   654k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 5.95k, False: 648k]
  ------------------
  153|  5.95k|            {
  154|  5.95k|                validate_static(&iter);
  155|  5.95k|            }
  156|   648k|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|   648k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   648k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|   648k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 642k, False: 5.95k]
  ------------------
  157|   642k|            {
  158|   642k|                validate_pointer(&iter);
  159|   642k|            }
  160|   654k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 585k, False: 69.3k]
  ------------------
  161|  69.3k|    }
  162|   109k|}

