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

pb_read:
   82|  2.98M|{
   83|  2.98M|    if (count == 0)
  ------------------
  |  Branch (83:9): [True: 185k, False: 2.80M]
  ------------------
   84|   185k|        return true;
   85|       |
   86|  2.80M|#ifndef PB_BUFFER_ONLY
   87|  2.80M|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (87:6): [True: 348k, False: 2.45M]
  |  Branch (87:21): [True: 78.1k, False: 270k]
  ------------------
   88|  78.1k|	{
   89|       |		/* Skip input bytes */
   90|  78.1k|		pb_byte_t tmp[16];
   91|   552k|		while (count > 16)
  ------------------
  |  Branch (91:10): [True: 473k, False: 78.1k]
  ------------------
   92|   473k|		{
   93|   473k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (93:8): [True: 0, False: 473k]
  ------------------
   94|      0|				return false;
   95|       |			
   96|   473k|			count -= 16;
   97|   473k|		}
   98|       |		
   99|  78.1k|		return pb_read(stream, tmp, count);
  100|  78.1k|	}
  101|  2.72M|#endif
  102|       |
  103|  2.72M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (103:9): [True: 227, False: 2.72M]
  ------------------
  104|    227|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  920|    227|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|    227|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 227]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  105|       |    
  106|  2.72M|#ifndef PB_BUFFER_ONLY
  107|  2.72M|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:9): [True: 0, False: 2.72M]
  ------------------
  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|  2.72M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (114:9): [True: 0, False: 2.72M]
  ------------------
  115|      0|        stream->bytes_left = 0;
  116|  2.72M|    else
  117|  2.72M|        stream->bytes_left -= count;
  118|       |
  119|       |    return true;
  120|  2.72M|}
pb_istream_from_buffer:
  143|   105k|{
  144|   105k|    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|   105k|    union {
  149|   105k|        void *state;
  150|   105k|        const void *c_state;
  151|   105k|    } state;
  152|       |#ifdef PB_BUFFER_ONLY
  153|       |    stream.callback = NULL;
  154|       |#else
  155|   105k|    stream.callback = &buf_read;
  156|   105k|#endif
  157|   105k|    state.c_state = buf;
  158|   105k|    stream.state = state.state;
  159|   105k|    stream.bytes_left = msglen;
  160|   105k|#ifndef PB_NO_ERRMSG
  161|       |    stream.errmsg = NULL;
  162|   105k|#endif
  163|   105k|    return stream;
  164|   105k|}
pb_decode_varint32:
  172|  9.47M|{
  173|  9.47M|    pb_byte_t byte;
  174|  9.47M|    uint32_t result;
  175|       |    
  176|  9.47M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (176:9): [True: 1.42k, False: 9.47M]
  ------------------
  177|  1.42k|    {
  178|  1.42k|        return false;
  179|  1.42k|    }
  180|       |    
  181|  9.47M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (181:9): [True: 8.25M, False: 1.22M]
  ------------------
  182|  8.25M|    {
  183|       |        /* Quick case, 1 byte value */
  184|  8.25M|        result = byte;
  185|  8.25M|    }
  186|  1.22M|    else
  187|  1.22M|    {
  188|       |        /* Multibyte case */
  189|  1.22M|        uint_fast8_t bitpos = 7;
  190|  1.22M|        result = byte & 0x7F;
  191|       |        
  192|  1.22M|        do
  193|  1.53M|        {
  194|  1.53M|            if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (194:17): [True: 40, False: 1.53M]
  ------------------
  195|     40|                return false;
  196|       |            
  197|  1.53M|            if (bitpos >= 32)
  ------------------
  |  Branch (197:17): [True: 17.8k, False: 1.51M]
  ------------------
  198|  17.8k|            {
  199|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  200|  17.8k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (200:44): [True: 17.3k, False: 501]
  ------------------
  201|  17.8k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (201:41): [True: 4.74k, False: 13.1k]
  ------------------
  202|  13.1k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (202:27): [True: 13.1k, False: 12]
  |  Branch (202:50): [True: 13.0k, False: 61]
  ------------------
  203|       |
  204|  17.8k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (204:21): [True: 2, False: 17.8k]
  |  Branch (204:37): [True: 72, False: 17.8k]
  ------------------
  205|     74|                {
  206|     74|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  920|     74|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     74|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 74]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  207|     74|                }
  208|  17.8k|            }
  209|  1.51M|            else if (bitpos == 28)
  ------------------
  |  Branch (209:22): [True: 12.8k, False: 1.50M]
  ------------------
  210|  12.8k|            {
  211|  12.8k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (211:21): [True: 4.62k, False: 8.22k]
  |  Branch (211:43): [True: 20, False: 4.60k]
  ------------------
  212|     20|                {
  213|     20|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  920|     20|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     20|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  214|     20|                }
  215|  12.8k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  216|  12.8k|            }
  217|  1.50M|            else
  218|  1.50M|            {
  219|  1.50M|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  220|  1.50M|            }
  221|  1.53M|            bitpos = (uint_fast8_t)(bitpos + 7);
  222|  1.53M|        } while (byte & 0x80);
  ------------------
  |  Branch (222:18): [True: 311k, False: 1.22M]
  ------------------
  223|  1.22M|   }
  224|       |   
  225|  9.47M|   *dest = result;
  226|       |   return true;
  227|  9.47M|}
pb_decode_varint:
  231|  5.59M|{
  232|  5.59M|    pb_byte_t byte;
  233|  5.59M|    uint_fast8_t bitpos = 0;
  234|  5.59M|    uint64_t result = 0;
  235|       |    
  236|  5.59M|    do
  237|  6.86M|    {
  238|  6.86M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (238:13): [True: 53, False: 6.86M]
  ------------------
  239|     53|            return false;
  240|       |
  241|  6.86M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (241:13): [True: 55.6k, False: 6.80M]
  |  Branch (241:29): [True: 25, False: 55.6k]
  ------------------
  242|     25|            PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  243|       |
  244|  6.86M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  245|  6.86M|        bitpos = (uint_fast8_t)(bitpos + 7);
  246|  6.86M|    } while (byte & 0x80);
  ------------------
  |  Branch (246:14): [True: 1.26M, False: 5.59M]
  ------------------
  247|       |    
  248|  5.59M|    *dest = result;
  249|       |    return true;
  250|  5.59M|}
pb_decode_tag:
  279|  8.68M|{
  280|  8.68M|    uint32_t temp;
  281|  8.68M|    *eof = false;
  282|  8.68M|    *wire_type = (pb_wire_type_t) 0;
  283|  8.68M|    *tag = 0;
  284|       |
  285|  8.68M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (285:9): [True: 259k, False: 8.42M]
  ------------------
  286|   259k|    {
  287|   259k|        *eof = true;
  288|   259k|        return false;
  289|   259k|    }
  290|       |
  291|  8.42M|    if (!pb_decode_varint32(stream, &temp))
  ------------------
  |  Branch (291:9): [True: 1.41k, False: 8.42M]
  ------------------
  292|  1.41k|    {
  293|  1.41k|#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.41k|        if (stream->callback != buf_read && stream->bytes_left == 0)
  ------------------
  |  Branch (301:13): [True: 1.30k, False: 109]
  |  Branch (301:45): [True: 1.30k, False: 0]
  ------------------
  302|  1.30k|        {
  303|  1.30k|#ifndef PB_NO_ERRMSG
  304|  1.30k|            if (strcmp(stream->errmsg, "io error") == 0)
  ------------------
  |  Branch (304:17): [True: 1.30k, False: 0]
  ------------------
  305|  1.30k|                stream->errmsg = NULL;
  306|  1.30k|#endif
  307|  1.30k|            *eof = true;
  308|  1.30k|        }
  309|  1.41k|#endif
  310|  1.41k|        return false;
  311|  1.41k|    }
  312|       |    
  313|  8.42M|    *tag = temp >> 3;
  314|  8.42M|    *wire_type = (pb_wire_type_t)(temp & 7);
  315|       |    return true;
  316|  8.42M|}
pb_skip_field:
  319|  1.38M|{
  320|  1.38M|    switch (wire_type)
  321|  1.38M|    {
  322|   975k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (322:9): [True: 975k, False: 410k]
  ------------------
  323|  86.7k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (323:9): [True: 86.7k, False: 1.29M]
  ------------------
  324|   189k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (324:9): [True: 189k, False: 1.19M]
  ------------------
  325|   134k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (325:9): [True: 134k, False: 1.25M]
  ------------------
  326|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (326:2): [True: 0, False: 1.38M]
  ------------------
  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|     91|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  920|     91|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     91|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 91]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (331:9): [True: 91, False: 1.38M]
  ------------------
  332|  1.38M|    }
  333|  1.38M|}
pb_make_string_substream:
  384|   340k|{
  385|   340k|    uint32_t size;
  386|   340k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (386:9): [True: 59, False: 340k]
  ------------------
  387|     59|        return false;
  388|       |    
  389|   340k|    *substream = *stream;
  390|   340k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (390:9): [True: 90, False: 340k]
  ------------------
  391|     90|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  920|     90|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     90|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 90]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  392|       |    
  393|   340k|    substream->bytes_left = (size_t)size;
  394|   340k|    stream->bytes_left -= (size_t)size;
  395|       |    return true;
  396|   340k|}
pb_close_string_substream:
  399|   340k|{
  400|   340k|    if (substream->bytes_left) {
  ------------------
  |  Branch (400:9): [True: 20.6k, False: 319k]
  ------------------
  401|  20.6k|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (401:13): [True: 0, False: 20.6k]
  ------------------
  402|      0|            return false;
  403|  20.6k|    }
  404|       |
  405|   340k|    stream->state = substream->state;
  406|       |
  407|   340k|#ifndef PB_NO_ERRMSG
  408|   340k|    stream->errmsg = substream->errmsg;
  409|   340k|#endif
  410|       |    return true;
  411|   340k|}
pb_decode_ex:
 1199|  8.24k|{
 1200|  8.24k|    bool status;
 1201|       |
 1202|  8.24k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  111|  8.24k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1202:9): [True: 8.24k, False: 0]
  ------------------
 1203|  8.24k|    {
 1204|  8.24k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1205|  8.24k|    }
 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|       |#ifdef PB_ENABLE_MALLOC
 1219|       |    if (!status)
 1220|       |        pb_release(fields, dest_struct);
 1221|       |#endif
 1222|       |    
 1223|  8.24k|    return status;
 1224|  8.24k|}
pb_decode:
 1227|  3.92k|{
 1228|  3.92k|    return pb_decode_ex(stream, fields, dest_struct, 0);
 1229|  3.92k|}
pb_release:
 1372|  6.54k|{
 1373|       |    /* Nothing to release without PB_ENABLE_MALLOC. */
 1374|  6.54k|    PB_UNUSED(fields);
  ------------------
  |  |  169|  6.54k|#define PB_UNUSED(x) (void)(x)
  ------------------
 1375|  6.54k|    PB_UNUSED(dest_struct);
  ------------------
  |  |  169|  6.54k|#define PB_UNUSED(x) (void)(x)
  ------------------
 1376|  6.54k|}
pb_decode_bool:
 1382|   257k|{
 1383|   257k|    uint32_t value;
 1384|   257k|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1384:9): [True: 18, False: 257k]
  ------------------
 1385|     18|        return false;
 1386|       |
 1387|   257k|    *(bool*)dest = (value != 0);
 1388|       |    return true;
 1389|   257k|}
pb_decode_svarint:
 1392|   179k|{
 1393|   179k|    pb_uint64_t value;
  ------------------
  |  |   57|   179k|#define pb_uint64_t uint64_t
  ------------------
 1394|   179k|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1394:9): [True: 29, False: 179k]
  ------------------
 1395|     29|        return false;
 1396|       |    
 1397|   179k|    if (value & 1)
  ------------------
  |  Branch (1397:9): [True: 30.4k, False: 148k]
  ------------------
 1398|  30.4k|        *dest = (pb_int64_t)(~(value >> 1));
 1399|   148k|    else
 1400|   148k|        *dest = (pb_int64_t)(value >> 1);
 1401|       |    
 1402|       |    return true;
 1403|   179k|}
pb_decode_fixed32:
 1406|   284k|{
 1407|   284k|    union {
 1408|   284k|        uint32_t fixed32;
 1409|   284k|        pb_byte_t bytes[4];
 1410|   284k|    } u;
 1411|       |
 1412|   284k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1412:9): [True: 14, False: 284k]
  ------------------
 1413|     14|        return false;
 1414|       |
 1415|   284k|#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|   284k|    *(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|   284k|}
pb_decode_fixed64:
 1429|   228k|{
 1430|   228k|    union {
 1431|   228k|        uint64_t fixed64;
 1432|   228k|        pb_byte_t bytes[8];
 1433|   228k|    } u;
 1434|       |
 1435|   228k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1435:9): [True: 16, False: 228k]
  ------------------
 1436|     16|        return false;
 1437|       |
 1438|   228k|#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|   228k|    *(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|   228k|}
pb_decode.c:buf_read:
   69|  15.8M|{
   70|  15.8M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   71|  15.8M|    stream->state = (pb_byte_t*)stream->state + count;
   72|       |    
   73|  15.8M|    if (buf != NULL)
  ------------------
  |  Branch (73:9): [True: 15.5M, False: 269k]
  ------------------
   74|  15.5M|    {
   75|  15.5M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   76|  15.5M|    }
   77|       |    
   78|       |    return true;
   79|  15.8M|}
pb_decode.c:pb_readbyte:
  125|  17.8M|{
  126|  17.8M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (126:9): [True: 206, False: 17.8M]
  ------------------
  127|    206|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  920|    206|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|    206|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 206]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|       |
  129|  17.8M|#ifndef PB_BUFFER_ONLY
  130|  17.8M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (130:9): [True: 1.30k, False: 17.8M]
  ------------------
  131|  1.30k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  920|  1.30k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|  1.30k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 1.30k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|       |#else
  133|       |    *buf = *(const pb_byte_t*)stream->state;
  134|       |    stream->state = (pb_byte_t*)stream->state + 1;
  135|       |#endif
  136|       |
  137|  17.8M|    stream->bytes_left--;
  138|       |    
  139|       |    return true;    
  140|  17.8M|}
pb_decode.c:pb_skip_varint:
  254|   975k|{
  255|   975k|    pb_byte_t byte;
  256|   975k|    do
  257|  1.21M|    {
  258|  1.21M|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (258:13): [True: 75, False: 1.21M]
  ------------------
  259|     75|            return false;
  260|  1.21M|    } while (byte & 0x80);
  ------------------
  |  Branch (260:14): [True: 237k, False: 975k]
  ------------------
  261|   975k|    return true;
  262|   975k|}
pb_decode.c:pb_skip_string:
  265|   189k|{
  266|   189k|    uint32_t length;
  267|   189k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (267:9): [True: 46, False: 189k]
  ------------------
  268|     46|        return false;
  269|       |    
  270|   189k|    if ((size_t)length != length)
  ------------------
  |  Branch (270:9): [True: 0, False: 189k]
  ------------------
  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|   189k|    return pb_read(stream, NULL, (size_t)length);
  276|   189k|}
pb_decode.c:pb_decode_inner:
 1028|   262k|{
 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|   262k|    uint32_t extension_range_start = 0;
 1034|   262k|    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|   262k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  339|   262k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
 1041|   262k|    pb_size_t fixed_count_size = 0;
 1042|   262k|    pb_size_t fixed_count_total_size = 0;
 1043|       |
 1044|       |    /* Tag and wire type of next field from the input stream */
 1045|   262k|    uint32_t tag;
 1046|   262k|    pb_wire_type_t wire_type;
 1047|   262k|    bool eof;
 1048|       |
 1049|       |    /* Track presence of required fields */
 1050|   262k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1051|   262k|    const uint32_t allbits = ~(uint32_t)0;
 1052|       |
 1053|       |    /* Descriptor for the structure field matching the tag decoded from stream */
 1054|   262k|    pb_field_iter_t iter;
 1055|       |
 1056|   262k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1056:9): [True: 143k, False: 119k]
  ------------------
 1057|   143k|    {
 1058|   143k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |  110|   143k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1058:13): [True: 12.3k, False: 130k]
  ------------------
 1059|  12.3k|        {
 1060|  12.3k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1060:17): [True: 0, False: 12.3k]
  ------------------
 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|  12.3k|        }
 1063|   143k|    }
 1064|       |
 1065|  8.15M|    while (pb_decode_tag(stream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1065:12): [True: 7.89M, False: 261k]
  ------------------
 1066|  7.89M|    {
 1067|  7.89M|        if (tag == 0)
  ------------------
  |  Branch (1067:13): [True: 45, False: 7.89M]
  ------------------
 1068|     45|        {
 1069|     45|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  112|     45|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1069:15): [True: 0, False: 45]
  ------------------
 1070|      0|          {
 1071|      0|            eof = true;
 1072|      0|            break;
 1073|      0|          }
 1074|     45|          else
 1075|     45|          {
 1076|     45|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  920|     45|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     45|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 45]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1077|     45|          }
 1078|     45|        }
 1079|       |
 1080|  7.89M|        if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|  6.49M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  6.49M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|  6.49M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1080:13): [True: 1.39M, False: 6.49M]
  |  Branch (1080:48): [True: 393, False: 6.49M]
  ------------------
 1081|  1.39M|        {
 1082|       |            /* No match found, check if it matches an extension. */
 1083|  1.39M|            if (extension_range_start == 0)
  ------------------
  |  Branch (1083:17): [True: 25.5k, False: 1.36M]
  ------------------
 1084|  25.5k|            {
 1085|  25.5k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1085:21): [True: 3.55k, False: 21.9k]
  ------------------
 1086|  3.55k|                {
 1087|  3.55k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1088|  3.55k|                    extension_range_start = iter.tag;
 1089|  3.55k|                }
 1090|       |
 1091|  25.5k|                if (!extensions)
  ------------------
  |  Branch (1091:21): [True: 22.8k, False: 2.66k]
  ------------------
 1092|  22.8k|                {
 1093|  22.8k|                    extension_range_start = (uint32_t)-1;
 1094|  22.8k|                }
 1095|  25.5k|            }
 1096|       |
 1097|  1.39M|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1097:17): [True: 127k, False: 1.26M]
  ------------------
 1098|   127k|            {
 1099|   127k|                size_t pos = stream->bytes_left;
 1100|       |
 1101|   127k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1101:21): [True: 39, False: 127k]
  ------------------
 1102|     39|                    return false;
 1103|       |
 1104|   127k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1104:21): [True: 5.31k, False: 121k]
  ------------------
 1105|  5.31k|                {
 1106|       |                    /* The field was handled */
 1107|  5.31k|                    continue;
 1108|  5.31k|                }
 1109|   127k|            }
 1110|       |
 1111|       |            /* No match found, skip data */
 1112|  1.38M|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1112:17): [True: 316, False: 1.38M]
  ------------------
 1113|    316|                return false;
 1114|  1.38M|            continue;
 1115|  1.38M|        }
 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|  6.49M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  324|  6.49M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  6.49M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  311|  12.9M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1120:13): [True: 45.6k, False: 6.45M]
  |  Branch (1120:57): [True: 4.36k, False: 41.3k]
  ------------------
 1121|  4.36k|        {
 1122|  4.36k|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1122:17): [True: 3.91k, False: 451]
  ------------------
 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|  3.91k|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  339|  7.82k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1127:21): [True: 2.30k, False: 1.60k]
  ------------------
 1128|  2.30k|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1128:21): [True: 4, False: 2.30k]
  ------------------
 1129|      4|                {
 1130|      4|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  920|      4|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      4|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1131|      4|                }
 1132|       |
 1133|  3.90k|                fixed_count_field = iter.index;
 1134|  3.90k|                fixed_count_size = 0;
 1135|  3.90k|                fixed_count_total_size = iter.array_size;
 1136|  3.90k|            }
 1137|       |
 1138|  4.35k|            iter.pSize = &fixed_count_size;
 1139|  4.35k|        }
 1140|       |
 1141|  6.49M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  324|  6.49M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  6.49M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  308|  12.9M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1141:13): [True: 6.04M, False: 453k]
  ------------------
 1142|  6.04M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  230|  6.04M|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1142:16): [True: 6.04M, False: 0]
  ------------------
 1143|  6.04M|        {
 1144|  6.04M|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1145|  6.04M|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1146|  6.04M|        }
 1147|       |
 1148|  6.49M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1148:13): [True: 1.12k, False: 6.49M]
  ------------------
 1149|  1.12k|            return false;
 1150|  6.49M|    }
 1151|       |
 1152|   261k|    if (!eof)
  ------------------
  |  Branch (1152:9): [True: 109, False: 261k]
  ------------------
 1153|    109|    {
 1154|       |        /* pb_decode_tag() returned error before end of stream */
 1155|    109|        return false;
 1156|    109|    }
 1157|       |
 1158|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1159|   261k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  339|   522k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1159:9): [True: 1.55k, False: 259k]
  ------------------
 1160|  1.55k|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1160:9): [True: 10, False: 1.54k]
  ------------------
 1161|     10|    {
 1162|     10|        PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  920|     10|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     10|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1163|     10|    }
 1164|       |
 1165|       |    /* Check that all required fields were present. */
 1166|   261k|    {
 1167|   261k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1168|       |
 1169|   261k|        if (req_field_count > 0)
  ------------------
  |  Branch (1169:13): [True: 136k, False: 124k]
  ------------------
 1170|   136k|        {
 1171|   136k|            pb_size_t i;
 1172|       |
 1173|   136k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  230|   136k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1173:17): [True: 0, False: 136k]
  ------------------
 1174|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  230|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1175|       |
 1176|       |            /* Check the whole words */
 1177|   136k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1177:25): [True: 0, False: 136k]
  ------------------
 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|   136k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1184:17): [True: 136k, False: 0]
  ------------------
 1185|   136k|            {
 1186|   136k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1186:21): [True: 297, False: 136k]
  ------------------
 1187|   136k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1188|    297|                {
 1189|    297|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  920|    297|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|    297|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 297]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1190|    297|                }
 1191|   136k|            }
 1192|   136k|        }
 1193|   261k|    }
 1194|       |
 1195|   260k|    return true;
 1196|   261k|}
pb_decode.c:pb_message_set_to_defaults:
  989|  96.4k|{
  990|  96.4k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   60|  96.4k|#define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
  991|  96.4k|    uint32_t tag = 0;
  992|  96.4k|    pb_wire_type_t wire_type = PB_WT_VARINT;
  993|  96.4k|    bool eof;
  994|       |
  995|  96.4k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (995:9): [True: 90.7k, False: 5.63k]
  ------------------
  996|  90.7k|    {
  997|  90.7k|        defstream = pb_istream_from_buffer(iter->descriptor->default_value, (size_t)-1);
  998|  90.7k|        if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (998:13): [True: 0, False: 90.7k]
  ------------------
  999|      0|            return false;
 1000|  90.7k|    }
 1001|       |
 1002|  96.4k|    do
 1003|   879k|    {
 1004|   879k|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (1004:13): [True: 0, False: 879k]
  ------------------
 1005|      0|            return false;
 1006|       |
 1007|   879k|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (1007:13): [True: 816k, False: 63.3k]
  |  Branch (1007:25): [True: 441k, False: 374k]
  ------------------
 1008|   441k|        {
 1009|       |            /* We have a default value for this field in the defstream */
 1010|   441k|            if (!decode_field(&defstream, wire_type, iter))
  ------------------
  |  Branch (1010:17): [True: 0, False: 441k]
  ------------------
 1011|      0|                return false;
 1012|   441k|            if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1012:17): [True: 0, False: 441k]
  ------------------
 1013|      0|                return false;
 1014|       |
 1015|   441k|            if (iter->pSize)
  ------------------
  |  Branch (1015:17): [True: 218k, False: 223k]
  ------------------
 1016|   218k|                *(bool*)iter->pSize = false;
 1017|   441k|        }
 1018|   879k|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (1018:14): [True: 783k, False: 96.4k]
  ------------------
 1019|       |
 1020|  96.4k|    return true;
 1021|  96.4k|}
pb_decode.c:pb_field_set_to_default:
  907|   879k|{
  908|   879k|    pb_type_t type;
  909|   879k|    type = field->type;
  910|       |
  911|   879k|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  325|   879k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   879k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  294|   879k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (911:9): [True: 8.24k, False: 871k]
  ------------------
  912|  8.24k|    {
  913|  8.24k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  914|  13.8k|        while (ext != NULL)
  ------------------
  |  Branch (914:16): [True: 5.63k, False: 8.24k]
  ------------------
  915|  5.63k|        {
  916|  5.63k|            pb_field_iter_t ext_iter;
  917|  5.63k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (917:17): [True: 5.63k, False: 0]
  ------------------
  918|  5.63k|            {
  919|  5.63k|                ext->found = false;
  920|  5.63k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (920:21): [True: 0, False: 5.63k]
  ------------------
  921|      0|                    return false;
  922|  5.63k|            }
  923|  5.63k|            ext = ext->next;
  924|  5.63k|        }
  925|  8.24k|    }
  926|   871k|    else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  323|   871k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   871k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  318|   871k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (926:14): [True: 820k, False: 51.3k]
  ------------------
  927|   820k|    {
  928|   820k|        bool init_data = true;
  929|   820k|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  324|   820k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   820k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  309|  1.64M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (929:13): [True: 235k, False: 585k]
  |  Branch (929:52): [True: 235k, False: 0]
  ------------------
  930|   235k|        {
  931|       |            /* Set has_field to false. Still initialize the optional field
  932|       |             * itself also. */
  933|   235k|            *(bool*)field->pSize = false;
  934|   235k|        }
  935|   585k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  324|   585k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   585k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  311|  1.17M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (935:18): [True: 145k, False: 439k]
  ------------------
  936|   439k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|   439k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   439k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|   439k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (936:18): [True: 24.7k, False: 414k]
  ------------------
  937|   170k|        {
  938|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
  939|       |               ONEOF: Set which_field to 0. */
  940|   170k|            *(pb_size_t*)field->pSize = 0;
  941|   170k|            init_data = false;
  942|   170k|        }
  943|       |
  944|   820k|        if (init_data)
  ------------------
  |  Branch (944:13): [True: 649k, False: 170k]
  ------------------
  945|   649k|        {
  946|   649k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  326|  1.29M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|   649k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|   649k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|  1.29M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 63.3k, False: 586k]
  |  |  ------------------
  |  |  327|  1.29M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|   586k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|   586k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|   586k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 586k]
  |  |  ------------------
  ------------------
  947|  63.3k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (947:18): [True: 24.7k, False: 38.6k]
  ------------------
  948|  38.6k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (948:18): [True: 0, False: 38.6k]
  ------------------
  949|  38.6k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (949:18): [True: 0, False: 38.6k]
  ------------------
  950|  24.7k|            {
  951|       |                /* Initialize submessage to defaults.
  952|       |                 * Only needed if it has default values
  953|       |                 * or callback/submessage fields. */
  954|  24.7k|                pb_field_iter_t submsg_iter;
  955|  24.7k|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (955:21): [True: 24.7k, False: 0]
  ------------------
  956|  24.7k|                {
  957|  24.7k|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (957:25): [True: 0, False: 24.7k]
  ------------------
  958|      0|                        return false;
  959|  24.7k|                }
  960|  24.7k|            }
  961|   625k|            else
  962|   625k|            {
  963|       |                /* Initialize to zeros */
  964|   625k|                memset(field->pData, 0, (size_t)field->data_size);
  965|   625k|            }
  966|   649k|        }
  967|   820k|    }
  968|  51.3k|    else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|  51.3k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  51.3k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|  51.3k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (968:14): [True: 0, False: 51.3k]
  ------------------
  969|      0|    {
  970|       |        /* Initialize the pointer to NULL. */
  971|      0|        *(void**)field->pField = NULL;
  972|       |
  973|       |        /* Initialize array count to 0. */
  974|      0|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  324|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  311|      0|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (974:13): [True: 0, False: 0]
  ------------------
  975|      0|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|      0|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (975:13): [True: 0, False: 0]
  ------------------
  976|      0|        {
  977|      0|            *(pb_size_t*)field->pSize = 0;
  978|      0|        }
  979|      0|    }
  980|  51.3k|    else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  323|  51.3k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  51.3k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  320|  51.3k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (980:14): [True: 51.3k, False: 0]
  ------------------
  981|  51.3k|    {
  982|       |        /* Don't overwrite callback */
  983|  51.3k|    }
  984|       |
  985|   879k|    return true;
  986|   879k|}
pb_decode.c:decode_extension:
  885|   127k|{
  886|   127k|    size_t pos = stream->bytes_left;
  887|       |    
  888|   254k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (888:12): [True: 127k, False: 127k]
  |  Branch (888:33): [True: 127k, False: 0]
  ------------------
  889|   127k|    {
  890|   127k|        bool status;
  891|   127k|        if (extension->type->decode)
  ------------------
  |  Branch (891:13): [True: 0, False: 127k]
  ------------------
  892|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  893|   127k|        else
  894|   127k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  895|       |
  896|   127k|        if (!status)
  ------------------
  |  Branch (896:13): [True: 39, False: 127k]
  ------------------
  897|     39|            return false;
  898|       |        
  899|   127k|        extension = extension->next;
  900|   127k|    }
  901|       |    
  902|   127k|    return true;
  903|   127k|}
pb_decode.c:default_extension_decoder:
  868|   127k|{
  869|   127k|    pb_field_iter_t iter;
  870|       |
  871|   127k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (871:9): [True: 0, False: 127k]
  ------------------
  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|   127k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (874:9): [True: 121k, False: 5.35k]
  |  Branch (874:28): [True: 0, False: 5.35k]
  ------------------
  875|   121k|        return true;
  876|       |
  877|  5.35k|    extension->found = true;
  878|  5.35k|    return decode_field(stream, wire_type, &iter);
  879|   127k|}
pb_decode.c:decode_field:
  836|  6.94M|{
  837|       |#ifdef PB_ENABLE_MALLOC
  838|       |    /* When decoding an oneof field, check if there is old data that must be
  839|       |     * released first. */
  840|       |    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  841|       |    {
  842|       |        if (!pb_release_union_field(stream, field))
  843|       |            return false;
  844|       |    }
  845|       |#endif
  846|       |
  847|  6.94M|    switch (PB_ATYPE(field->type))
  ------------------
  |  |  323|  6.94M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  6.94M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
  848|  6.94M|    {
  849|  6.88M|        case PB_ATYPE_STATIC:
  ------------------
  |  |  318|  6.88M|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (849:9): [True: 6.88M, False: 61.6k]
  ------------------
  850|  6.88M|            return decode_static_field(stream, wire_type, field);
  851|       |        
  852|      0|        case PB_ATYPE_POINTER:
  ------------------
  |  |  319|      0|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (852:9): [True: 0, False: 6.94M]
  ------------------
  853|      0|            return decode_pointer_field(stream, wire_type, field);
  854|       |        
  855|  61.6k|        case PB_ATYPE_CALLBACK:
  ------------------
  |  |  320|  61.6k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (855:9): [True: 61.6k, False: 6.88M]
  ------------------
  856|  61.6k|            return decode_callback_field(stream, wire_type, field);
  857|       |        
  858|      0|        default:
  ------------------
  |  Branch (858:9): [True: 0, False: 6.94M]
  ------------------
  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|  6.94M|    }
  861|  6.94M|}
pb_decode.c:decode_static_field:
  489|  6.88M|{
  490|  6.88M|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  324|  6.88M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  6.88M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  491|  6.88M|    {
  492|  6.23M|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  308|  6.23M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (492:9): [True: 6.23M, False: 652k]
  ------------------
  493|  6.23M|            return decode_basic_field(stream, wire_type, field);
  494|       |            
  495|   448k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  309|   448k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (495:9): [True: 448k, False: 6.43M]
  ------------------
  496|   448k|            if (field->pSize != NULL)
  ------------------
  |  Branch (496:17): [True: 448k, False: 0]
  ------------------
  497|   448k|                *(bool*)field->pSize = true;
  498|   448k|            return decode_basic_field(stream, wire_type, field);
  499|       |    
  500|  36.5k|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  311|  36.5k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (500:9): [True: 36.5k, False: 6.84M]
  ------------------
  501|  36.5k|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (501:17): [True: 23.5k, False: 13.0k]
  ------------------
  502|  23.5k|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  325|  23.5k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  23.5k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  273|  23.5k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (502:20): [True: 10.8k, False: 12.6k]
  ------------------
  503|  10.8k|            {
  504|       |                /* Packed array */
  505|  10.8k|                bool status = true;
  506|  10.8k|                pb_istream_t substream;
  507|  10.8k|                pb_size_t *size = (pb_size_t*)field->pSize;
  508|  10.8k|                field->pData = (char*)field->pField + field->data_size * (*size);
  509|       |
  510|  10.8k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (510:21): [True: 55, False: 10.8k]
  ------------------
  511|     55|                    return false;
  512|       |
  513|  46.7k|                while (substream.bytes_left > 0 && *size < field->array_size)
  ------------------
  |  Branch (513:24): [True: 35.9k, False: 10.7k]
  |  Branch (513:52): [True: 35.9k, False: 26]
  ------------------
  514|  35.9k|                {
  515|  35.9k|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (515:25): [True: 27, False: 35.8k]
  ------------------
  516|     27|                    {
  517|     27|                        status = false;
  518|     27|                        break;
  519|     27|                    }
  520|  35.8k|                    (*size)++;
  521|  35.8k|                    field->pData = (char*)field->pData + field->data_size;
  522|  35.8k|                }
  523|       |
  524|  10.8k|                if (substream.bytes_left != 0)
  ------------------
  |  Branch (524:21): [True: 47, False: 10.7k]
  ------------------
  525|     47|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  920|     47|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     47|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  526|  10.7k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (526:21): [True: 0, False: 10.7k]
  ------------------
  527|      0|                    return false;
  528|       |
  529|  10.7k|                return status;
  530|  10.7k|            }
  531|  25.7k|            else
  532|  25.7k|            {
  533|       |                /* Repeated field */
  534|  25.7k|                pb_size_t *size = (pb_size_t*)field->pSize;
  535|  25.7k|                field->pData = (char*)field->pField + field->data_size * (*size);
  536|       |
  537|  25.7k|                if ((*size)++ >= field->array_size)
  ------------------
  |  Branch (537:21): [True: 3, False: 25.6k]
  ------------------
  538|      3|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  539|       |
  540|  25.6k|                return decode_basic_field(stream, wire_type, field);
  541|  25.7k|            }
  542|       |
  543|   168k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  313|   168k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (543:9): [True: 168k, False: 6.71M]
  ------------------
  544|   168k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  326|   336k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|   168k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|   168k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|   336k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 131k, False: 36.8k]
  |  |  ------------------
  |  |  327|   336k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|  36.8k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|  36.8k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|  36.8k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 36.8k, False: 0]
  |  |  ------------------
  ------------------
  545|   168k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (545:17): [True: 91.0k, False: 77.1k]
  ------------------
  546|  91.0k|            {
  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|  91.0k|                memset(field->pData, 0, (size_t)field->data_size);
  555|       |
  556|       |                /* Set default values for the submessage fields. */
  557|  91.0k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (557:21): [True: 53.6k, False: 37.4k]
  ------------------
  558|  37.4k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (558:21): [True: 0, False: 37.4k]
  ------------------
  559|  37.4k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (559:21): [True: 0, False: 37.4k]
  ------------------
  560|  53.6k|                {
  561|  53.6k|                    pb_field_iter_t submsg_iter;
  562|  53.6k|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (562:25): [True: 53.6k, False: 0]
  ------------------
  563|  53.6k|                    {
  564|  53.6k|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (564:29): [True: 0, False: 53.6k]
  ------------------
  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|  53.6k|                    }
  567|  53.6k|                }
  568|  91.0k|            }
  569|   168k|            *(pb_size_t*)field->pSize = field->tag;
  570|       |
  571|   168k|            return decode_basic_field(stream, wire_type, field);
  572|       |
  573|      0|        default:
  ------------------
  |  Branch (573:9): [True: 0, False: 6.88M]
  ------------------
  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|  6.88M|    }
  576|  6.88M|}
pb_decode.c:decode_basic_field:
  418|  6.90M|{
  419|  6.90M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  325|  6.90M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  6.90M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  420|  6.90M|    {
  421|   257k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  265|   257k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (421:9): [True: 257k, False: 6.65M]
  ------------------
  422|   257k|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (422:17): [True: 1.44k, False: 256k]
  |  Branch (422:46): [True: 8, False: 1.43k]
  ------------------
  423|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  424|       |
  425|   257k|            return pb_dec_bool(stream, field);
  426|       |
  427|  4.25M|        case PB_LTYPE_VARINT:
  ------------------
  |  |  266|  4.25M|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (427:9): [True: 4.25M, False: 2.65M]
  ------------------
  428|  5.42M|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  267|  5.42M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (428:9): [True: 1.16M, False: 5.74M]
  ------------------
  429|  5.59M|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  268|  5.59M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (429:9): [True: 179k, False: 6.72M]
  ------------------
  430|  5.59M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (430:17): [True: 23.8k, False: 5.57M]
  |  Branch (430:46): [True: 51, False: 23.8k]
  ------------------
  431|     51|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     51|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     51|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 51]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  432|       |
  433|  5.59M|            return pb_dec_varint(stream, field);
  434|       |
  435|   284k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  269|   284k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (435:9): [True: 284k, False: 6.62M]
  ------------------
  436|   284k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (436:17): [True: 5.75k, False: 278k]
  |  Branch (436:45): [True: 22, False: 5.73k]
  ------------------
  437|     22|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     22|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     22|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  438|       |
  439|   284k|            return pb_decode_fixed32(stream, field->pData);
  440|       |
  441|   228k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  270|   228k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (441:9): [True: 228k, False: 6.68M]
  ------------------
  442|   228k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (442:17): [True: 4.93k, False: 223k]
  |  Branch (442:45): [True: 15, False: 4.91k]
  ------------------
  443|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|   228k|            return pb_decode_fixed64(stream, field->pData);
  456|      0|#endif
  457|       |
  458|  48.1k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  277|  48.1k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (458:9): [True: 48.1k, False: 6.86M]
  ------------------
  459|  48.1k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (459:17): [True: 10, False: 48.1k]
  ------------------
  460|     10|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     10|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     10|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  461|       |
  462|  48.1k|            return pb_dec_bytes(stream, field);
  463|       |
  464|   186k|        case PB_LTYPE_STRING:
  ------------------
  |  |  281|   186k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (464:9): [True: 186k, False: 6.72M]
  ------------------
  465|   186k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (465:17): [True: 12, False: 186k]
  ------------------
  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|   186k|            return pb_dec_string(stream, field);
  469|       |
  470|   239k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  285|   239k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (470:9): [True: 239k, False: 6.67M]
  ------------------
  471|   276k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  290|   276k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (471:9): [True: 36.8k, False: 6.87M]
  ------------------
  472|   276k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (472:17): [True: 16, False: 276k]
  ------------------
  473|     16|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|     16|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     16|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  474|       |
  475|   276k|            return pb_dec_submessage(stream, field);
  476|       |
  477|  27.7k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  300|  27.7k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (477:9): [True: 27.7k, False: 6.88M]
  ------------------
  478|  27.7k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (478:17): [True: 4, False: 27.7k]
  ------------------
  479|      4|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  920|      4|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      4|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  480|       |
  481|  27.7k|            return pb_dec_fixed_length_bytes(stream, field);
  482|       |
  483|      0|        default:
  ------------------
  |  Branch (483:9): [True: 0, False: 6.90M]
  ------------------
  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|  6.90M|    }
  486|  6.90M|}
pb_decode.c:pb_dec_bool:
 1456|   257k|{
 1457|   257k|    return pb_decode_bool(stream, (bool*)field->pData);
 1458|   257k|}
pb_decode.c:pb_dec_varint:
 1461|  5.59M|{
 1462|  5.59M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  325|  5.59M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  5.59M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  267|  5.59M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1462:9): [True: 1.16M, False: 4.43M]
  ------------------
 1463|  1.16M|    {
 1464|  1.16M|        pb_uint64_t value, clamped;
  ------------------
  |  |   57|  1.16M|#define pb_uint64_t uint64_t
  ------------------
 1465|  1.16M|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1465:13): [True: 19, False: 1.16M]
  ------------------
 1466|     19|            return false;
 1467|       |
 1468|       |        /* Cast to the proper field size, while checking for overflows */
 1469|  1.16M|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1469:13): [True: 971k, False: 190k]
  ------------------
 1470|   971k|            clamped = *(pb_uint64_t*)field->pData = value;
 1471|   190k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1471:18): [True: 164k, False: 25.3k]
  ------------------
 1472|   164k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1473|  25.3k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1473:18): [True: 12.6k, False: 12.7k]
  ------------------
 1474|  12.6k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1475|  12.7k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1475:18): [True: 12.7k, False: 0]
  ------------------
 1476|  12.7k|            clamped = *(uint_least8_t*)field->pData = (uint_least8_t)value;
 1477|      0|        else
 1478|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  920|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1479|       |
 1480|  1.16M|        if (clamped != value)
  ------------------
  |  Branch (1480:13): [True: 111, False: 1.16M]
  ------------------
 1481|    111|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  920|    111|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|    111|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 111]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1482|       |
 1483|  1.16M|        return true;
 1484|  1.16M|    }
 1485|  4.43M|    else
 1486|  4.43M|    {
 1487|  4.43M|        pb_uint64_t value;
  ------------------
  |  |   57|  4.43M|#define pb_uint64_t uint64_t
  ------------------
 1488|  4.43M|        pb_int64_t svalue;
  ------------------
  |  |   56|  4.43M|#define pb_int64_t int64_t
  ------------------
 1489|  4.43M|        pb_int64_t clamped;
  ------------------
  |  |   56|  4.43M|#define pb_int64_t int64_t
  ------------------
 1490|       |
 1491|  4.43M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  325|  4.43M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  4.43M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  268|  4.43M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1491:13): [True: 179k, False: 4.25M]
  ------------------
 1492|   179k|        {
 1493|   179k|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1493:17): [True: 29, False: 179k]
  ------------------
 1494|     29|                return false;
 1495|   179k|        }
 1496|  4.25M|        else
 1497|  4.25M|        {
 1498|  4.25M|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1498:17): [True: 30, False: 4.25M]
  ------------------
 1499|     30|                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.25M|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1507:17): [True: 146k, False: 4.11M]
  ------------------
 1508|   146k|                svalue = (pb_int64_t)value;
 1509|  4.11M|            else
 1510|  4.11M|                svalue = (int32_t)value;
 1511|  4.25M|        }
 1512|       |
 1513|       |        /* Cast to the proper field size, while checking for overflows */
 1514|  4.43M|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1514:13): [True: 230k, False: 4.20M]
  ------------------
 1515|   230k|            clamped = *(pb_int64_t*)field->pData = svalue;
 1516|  4.20M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1516:18): [True: 4.15M, False: 50.3k]
  ------------------
 1517|  4.15M|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1518|  50.3k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1518:18): [True: 25.1k, False: 25.1k]
  ------------------
 1519|  25.1k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1520|  25.1k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1520:18): [True: 25.1k, False: 0]
  ------------------
 1521|  25.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|  4.43M|        if (clamped != svalue)
  ------------------
  |  Branch (1525:13): [True: 94, False: 4.43M]
  ------------------
 1526|     94|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  920|     94|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     94|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 94]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1527|       |
 1528|  4.43M|        return true;
 1529|  4.43M|    }
 1530|  5.59M|}
pb_decode.c:pb_dec_bytes:
 1533|  48.1k|{
 1534|  48.1k|    uint32_t size;
 1535|  48.1k|    size_t alloc_size;
 1536|  48.1k|    pb_bytes_array_t *dest;
 1537|       |    
 1538|  48.1k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1538:9): [True: 7, False: 48.1k]
  ------------------
 1539|      7|        return false;
 1540|       |    
 1541|  48.1k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  339|  48.1k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1541:9): [True: 29, False: 48.1k]
  ------------------
 1542|     29|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  920|     29|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     29|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 29]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1543|       |    
 1544|  48.1k|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  403|  48.1k|#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes))
  ------------------
 1545|  48.1k|    if (size > alloc_size)
  ------------------
  |  Branch (1545:9): [True: 0, False: 48.1k]
  ------------------
 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|  48.1k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|  48.1k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  48.1k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|  48.1k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1548:9): [True: 0, False: 48.1k]
  ------------------
 1549|      0|    {
 1550|      0|#ifndef PB_ENABLE_MALLOC
 1551|      0|        PB_RETURN_ERROR(stream, "no malloc support");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1552|       |#else
 1553|       |        if (stream->bytes_left < size)
 1554|       |            PB_RETURN_ERROR(stream, "end-of-stream");
 1555|       |
 1556|       |        if (!allocate_field(stream, field->pData, alloc_size, 1))
 1557|       |            return false;
 1558|       |        dest = *(pb_bytes_array_t**)field->pData;
 1559|       |#endif
 1560|      0|    }
 1561|  48.1k|    else
 1562|  48.1k|    {
 1563|  48.1k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1563:13): [True: 50, False: 48.0k]
  ------------------
 1564|     50|            PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  920|     50|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     50|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 50]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1565|  48.0k|        dest = (pb_bytes_array_t*)field->pData;
 1566|  48.0k|    }
 1567|       |
 1568|  48.0k|    dest->size = (pb_size_t)size;
 1569|  48.0k|    return pb_read(stream, dest->bytes, (size_t)size);
 1570|  48.1k|}
pb_decode.c:pb_dec_string:
 1573|   186k|{
 1574|   186k|    uint32_t size;
 1575|   186k|    size_t alloc_size;
 1576|   186k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1577|       |
 1578|   186k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1578:9): [True: 4, False: 186k]
  ------------------
 1579|      4|        return false;
 1580|       |
 1581|   186k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1581:9): [True: 2, False: 186k]
  ------------------
 1582|      2|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  920|      2|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|      2|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1583|       |
 1584|       |    /* Space for null terminator */
 1585|   186k|    alloc_size = (size_t)(size + 1);
 1586|       |
 1587|   186k|    if (alloc_size < size)
  ------------------
  |  Branch (1587:9): [True: 0, False: 186k]
  ------------------
 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|   186k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|   186k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   186k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|   186k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1590:9): [True: 0, False: 186k]
  ------------------
 1591|      0|    {
 1592|      0|#ifndef PB_ENABLE_MALLOC
 1593|      0|        PB_RETURN_ERROR(stream, "no malloc support");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1594|       |#else
 1595|       |        if (stream->bytes_left < size)
 1596|       |            PB_RETURN_ERROR(stream, "end-of-stream");
 1597|       |
 1598|       |        if (!allocate_field(stream, field->pData, alloc_size, 1))
 1599|       |            return false;
 1600|       |        dest = *(pb_byte_t**)field->pData;
 1601|       |#endif
 1602|      0|    }
 1603|   186k|    else
 1604|   186k|    {
 1605|   186k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1605:13): [True: 88, False: 186k]
  ------------------
 1606|     88|            PB_RETURN_ERROR(stream, "string overflow");
  ------------------
  |  |  920|     88|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     88|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 88]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1607|   186k|    }
 1608|       |    
 1609|   186k|    dest[size] = 0;
 1610|       |
 1611|   186k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1611:9): [True: 6, False: 186k]
  ------------------
 1612|      6|        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|   186k|    return true;
 1620|   186k|}
pb_decode.c:pb_dec_submessage:
 1623|   276k|{
 1624|   276k|    bool status = true;
 1625|   276k|    bool submsg_consumed = false;
 1626|   276k|    pb_istream_t substream;
 1627|       |
 1628|   276k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1628:9): [True: 94, False: 275k]
  ------------------
 1629|     94|        return false;
 1630|       |    
 1631|   275k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1631:9): [True: 0, False: 275k]
  ------------------
 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|   275k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  325|   275k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   275k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  290|   551k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1637:9): [True: 36.8k, False: 239k]
  |  Branch (1637:58): [True: 36.8k, False: 0]
  ------------------
 1638|  36.8k|    {
 1639|       |        /* Message callback is stored right before pSize. */
 1640|  36.8k|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
 1641|  36.8k|        if (callback->funcs.decode)
  ------------------
  |  Branch (1641:13): [True: 36.8k, False: 0]
  ------------------
 1642|  36.8k|        {
 1643|  36.8k|            status = callback->funcs.decode(&substream, field, &callback->arg);
 1644|       |
 1645|  36.8k|            if (substream.bytes_left == 0)
  ------------------
  |  Branch (1645:17): [True: 21.4k, False: 15.4k]
  ------------------
 1646|  21.4k|            {
 1647|  21.4k|                submsg_consumed = true;
 1648|  21.4k|            }
 1649|  36.8k|        }
 1650|  36.8k|    }
 1651|       |
 1652|       |    /* Now decode the submessage contents */
 1653|   275k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1653:9): [True: 275k, False: 0]
  |  Branch (1653:19): [True: 254k, False: 21.4k]
  ------------------
 1654|   254k|    {
 1655|   254k|        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|   254k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  323|   254k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   254k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  318|   508k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1659:13): [True: 254k, False: 0]
  ------------------
 1660|   254k|            PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  324|   254k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   254k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  311|   254k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1660:13): [True: 249k, False: 5.38k]
  ------------------
 1661|   249k|        {
 1662|   249k|            flags = PB_DECODE_NOINIT;
  ------------------
  |  |  110|   249k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1663|   249k|        }
 1664|       |
 1665|   254k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1666|   254k|    }
 1667|       |    
 1668|   275k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1668:9): [True: 0, False: 275k]
  ------------------
 1669|      0|        return false;
 1670|       |
 1671|   275k|    return status;
 1672|   275k|}
pb_decode.c:pb_dec_fixed_length_bytes:
 1675|  27.7k|{
 1676|  27.7k|    uint32_t size;
 1677|       |
 1678|  27.7k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1678:9): [True: 4, False: 27.7k]
  ------------------
 1679|      4|        return false;
 1680|       |
 1681|  27.7k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  339|  27.7k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1681:9): [True: 29, False: 27.6k]
  ------------------
 1682|     29|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  920|     29|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     29|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 29]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1683|       |
 1684|  27.6k|    if (size == 0)
  ------------------
  |  Branch (1684:9): [True: 14.6k, False: 13.0k]
  ------------------
 1685|  14.6k|    {
 1686|       |        /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */
 1687|  14.6k|        memset(field->pData, 0, (size_t)field->data_size);
 1688|  14.6k|        return true;
 1689|  14.6k|    }
 1690|       |
 1691|  13.0k|    if (size != field->data_size)
  ------------------
  |  Branch (1691:9): [True: 47, False: 12.9k]
  ------------------
 1692|     47|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  920|     47|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  916|     47|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (916:53): [True: 0, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1693|       |
 1694|  12.9k|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1695|  13.0k|}
pb_decode.c:decode_callback_field:
  774|  61.6k|{
  775|  61.6k|    if (!field->descriptor->field_callback)
  ------------------
  |  Branch (775:9): [True: 0, False: 61.6k]
  ------------------
  776|      0|        return pb_skip_field(stream, wire_type);
  777|       |
  778|  61.6k|    if (wire_type == PB_WT_STRING)
  ------------------
  |  Branch (778:9): [True: 53.5k, False: 8.14k]
  ------------------
  779|  53.5k|    {
  780|  53.5k|        pb_istream_t substream;
  781|  53.5k|        size_t prev_bytes_left;
  782|       |        
  783|  53.5k|        if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (783:13): [True: 0, False: 53.5k]
  ------------------
  784|      0|            return false;
  785|       |
  786|       |        /* If the callback field is inside a submsg, first call the submsg_callback which
  787|       |         * should set the decoder for the callback field. */
  788|  53.5k|        if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  325|  53.5k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|  53.5k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  290|   107k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (788:13): [True: 0, False: 53.5k]
  |  Branch (788:62): [True: 0, False: 0]
  ------------------
  789|      0|            pb_callback_t* callback;
  790|      0|            *(pb_size_t*)field->pSize = field->tag;
  791|      0|            callback = (pb_callback_t*)field->pSize - 1;
  792|       |
  793|      0|            if (callback->funcs.decode)
  ------------------
  |  Branch (793:17): [True: 0, False: 0]
  ------------------
  794|      0|            {
  795|      0|                if (!callback->funcs.decode(&substream, field, &callback->arg)) {
  ------------------
  |  Branch (795:21): [True: 0, False: 0]
  ------------------
  796|      0|                    PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "submsg callback failed");
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  797|      0|                    return false;
  798|      0|                }
  799|      0|            }
  800|      0|        }
  801|       |        
  802|  53.5k|        do
  803|  53.5k|        {
  804|  53.5k|            prev_bytes_left = substream.bytes_left;
  805|  53.5k|            if (!field->descriptor->field_callback(&substream, NULL, field))
  ------------------
  |  Branch (805:17): [True: 0, False: 53.5k]
  ------------------
  806|      0|            {
  807|      0|                PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "callback failed");
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  808|      0|                return false;
  809|      0|            }
  810|  53.5k|        } while (substream.bytes_left > 0 && substream.bytes_left < prev_bytes_left);
  ------------------
  |  Branch (810:18): [True: 20.6k, False: 32.9k]
  |  Branch (810:46): [True: 0, False: 20.6k]
  ------------------
  811|       |        
  812|  53.5k|        if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (812:13): [True: 0, False: 53.5k]
  ------------------
  813|      0|            return false;
  814|       |
  815|  53.5k|        return true;
  816|  53.5k|    }
  817|  8.14k|    else
  818|  8.14k|    {
  819|       |        /* Copy the single scalar value to stack.
  820|       |         * This is required so that we can limit the stream length,
  821|       |         * which in turn allows to use same callback for packed and
  822|       |         * not-packed fields. */
  823|  8.14k|        pb_istream_t substream;
  824|  8.14k|        pb_byte_t buffer[10];
  825|  8.14k|        size_t size = sizeof(buffer);
  826|       |        
  827|  8.14k|        if (!read_raw_value(stream, wire_type, buffer, &size))
  ------------------
  |  Branch (827:13): [True: 0, False: 8.14k]
  ------------------
  828|      0|            return false;
  829|  8.14k|        substream = pb_istream_from_buffer(buffer, size);
  830|       |        
  831|       |        return field->descriptor->field_callback(&substream, NULL, field);
  832|  8.14k|    }
  833|  61.6k|}
pb_decode.c:read_raw_value:
  339|  8.14k|{
  340|  8.14k|    size_t max_size = *size;
  341|  8.14k|    switch (wire_type)
  342|  8.14k|    {
  343|  6.73k|        case PB_WT_VARINT:
  ------------------
  |  Branch (343:9): [True: 6.73k, False: 1.41k]
  ------------------
  344|  6.73k|            *size = 0;
  345|  6.73k|            do
  346|  20.9k|            {
  347|  20.9k|                (*size)++;
  348|  20.9k|                if (*size > max_size)
  ------------------
  |  Branch (348:21): [True: 0, False: 20.9k]
  ------------------
  349|      0|                    PB_RETURN_ERROR(stream, "varint 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  350|       |
  351|  20.9k|                if (!pb_read(stream, buf, 1))
  ------------------
  |  Branch (351:21): [True: 0, False: 20.9k]
  ------------------
  352|      0|                    return false;
  353|  20.9k|            } while (*buf++ & 0x80);
  ------------------
  |  Branch (353:22): [True: 14.2k, False: 6.73k]
  ------------------
  354|  6.73k|            return true;
  355|       |            
  356|    502|        case PB_WT_64BIT:
  ------------------
  |  Branch (356:9): [True: 502, False: 7.64k]
  ------------------
  357|    502|            *size = 8;
  358|    502|            return pb_read(stream, buf, 8);
  359|       |        
  360|    910|        case PB_WT_32BIT:
  ------------------
  |  Branch (360:9): [True: 910, False: 7.23k]
  ------------------
  361|    910|            *size = 4;
  362|    910|            return pb_read(stream, buf, 4);
  363|       |        
  364|      0|        case PB_WT_STRING:
  ------------------
  |  Branch (364:9): [True: 0, False: 8.14k]
  ------------------
  365|       |            /* Calling read_raw_value with a PB_WT_STRING is an error.
  366|       |             * Explicitly handle this case and fallthrough to default to avoid
  367|       |             * compiler warnings.
  368|       |             */
  369|       |
  370|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (370:2): [True: 0, False: 8.14k]
  ------------------
  371|       |            /* Calling read_raw_value with a PB_WT_PACKED is an error.
  372|       |             * Explicitly handle this case and fallthrough to default to avoid
  373|       |             * compiler warnings.
  374|       |             */
  375|       |
  376|      0|        default: PB_RETURN_ERROR(stream, "invalid wire_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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (376:9): [True: 0, False: 8.14k]
  ------------------
  377|  8.14k|    }
  378|  8.14k|}

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

malloc_with_check:
   58|  11.2k|{
   59|  11.2k|    const size_t check2 = CHECK2;
  ------------------
  |  |   18|  11.2k|#define CHECK2 ((size_t)0x600DCAFE)
  ------------------
   60|  11.2k|    char *buf = NULL;
   61|       |
   62|  11.2k|    if (size <= g_max_alloc_bytes - g_alloc_bytes)
  ------------------
  |  Branch (62:9): [True: 11.2k, False: 0]
  ------------------
   63|  11.2k|    {
   64|  11.2k|        buf = malloc(round_blocksize(size + GUARD_SIZE));
  ------------------
  |  |   15|  11.2k|#define GUARD_SIZE (sizeof(size_t)*3)
  ------------------
   65|  11.2k|    }
   66|       |
   67|  11.2k|    if (buf)
  ------------------
  |  Branch (67:9): [True: 11.2k, False: 0]
  ------------------
   68|  11.2k|    {
   69|  11.2k|        ((size_t*)buf)[0] = size;
   70|  11.2k|        ((size_t*)buf)[1] = CHECK1;
  ------------------
  |  |   17|  11.2k|#define CHECK1 ((size_t)0xDEADBEEF)
  ------------------
   71|  11.2k|        memcpy(buf + PREFIX_SIZE + size, &check2, sizeof(check2));
  ------------------
  |  |   16|  11.2k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   72|       |
   73|  11.2k|        g_alloc_count++;
   74|  11.2k|        g_alloc_bytes += size;
   75|  11.2k|        if (DEBUG_MALLOC) fprintf(stderr, "Alloc 0x%04x/%u\n", (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   25|  11.2k|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (25:22): [Folded, False: 11.2k]
  |  |  ------------------
  ------------------
                      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|  11.2k|        return buf + PREFIX_SIZE;
  ------------------
  |  |   16|  11.2k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   77|  11.2k|    }
   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|  11.2k|}
free_with_check:
   87|  11.2k|{
   88|  11.2k|    if (mem)
  ------------------
  |  Branch (88:9): [True: 11.2k, False: 0]
  ------------------
   89|  11.2k|    {
   90|  11.2k|        char *buf = (char*)mem - PREFIX_SIZE;
  ------------------
  |  |   16|  11.2k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   91|  11.2k|        size_t check2 = 0;
   92|  11.2k|        size_t size = ((size_t*)buf)[0];
   93|  11.2k|        if (DEBUG_MALLOC) fprintf(stderr, "Release 0x%04x/%u\n", (unsigned)(uintptr_t)mem, (unsigned)size);
  ------------------
  |  |   25|  11.2k|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (25:22): [Folded, False: 11.2k]
  |  |  ------------------
  ------------------
   94|  11.2k|        assert(((size_t*)buf)[1] == CHECK1);
  ------------------
  |  Branch (94:9): [True: 0, False: 11.2k]
  |  Branch (94:9): [True: 11.2k, False: 0]
  ------------------
   95|  11.2k|        memcpy(&check2, buf + PREFIX_SIZE + size, sizeof(check2));
  ------------------
  |  |   16|  11.2k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   96|  11.2k|        assert(check2 == CHECK2);
  ------------------
  |  Branch (96:9): [True: 0, False: 11.2k]
  |  Branch (96:9): [True: 11.2k, False: 0]
  ------------------
   97|  11.2k|        assert(g_alloc_count > 0);
  ------------------
  |  Branch (97:9): [True: 0, False: 11.2k]
  |  Branch (97:9): [True: 11.2k, False: 0]
  ------------------
   98|  11.2k|        assert(g_alloc_bytes >= size);
  ------------------
  |  Branch (98:9): [True: 0, False: 11.2k]
  |  Branch (98:9): [True: 11.2k, False: 0]
  ------------------
   99|  11.2k|        ((size_t*)buf)[1] = 0;
  100|  11.2k|        memset(buf + PREFIX_SIZE + size, 0, sizeof(check2));
  ------------------
  |  |   16|  11.2k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  101|  11.2k|        g_alloc_count--;
  102|  11.2k|        g_alloc_bytes -= size;
  103|  11.2k|        free(buf);
  104|  11.2k|    }
  105|  11.2k|}
get_alloc_count:
  172|  17.2k|{
  173|  17.2k|    return g_alloc_count;
  174|  17.2k|}
malloc_wrappers.c:round_blocksize:
   39|  11.2k|{
   40|  11.2k|    if (size < 256)
  ------------------
  |  Branch (40:9): [True: 0, False: 11.2k]
  ------------------
   41|      0|    {
   42|      0|        return size;
   43|      0|    }
   44|  11.2k|    else
   45|  11.2k|    {
   46|  11.2k|        return (size + 1023) / 1024 * 1024;
   47|  11.2k|    }
   48|  11.2k|}

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

do_callback_decode:
  171|  1.30k|{
  172|  1.30k|    bool status;
  173|  1.30k|    pb_istream_t stream;
  174|  1.30k|    size_t initial_alloc_count = get_alloc_count();
  175|  1.30k|    alltypes_callback_AllTypes *msg = malloc_with_check(sizeof(alltypes_callback_AllTypes));
  176|  1.30k|    assert(msg);
  ------------------
  |  Branch (176:5): [True: 0, False: 1.30k]
  |  Branch (176:5): [True: 1.30k, False: 0]
  ------------------
  177|       |
  178|  1.30k|    memset(msg, 0, sizeof(alltypes_callback_AllTypes));
  179|  1.30k|    stream = pb_istream_from_buffer(buffer, msglen);
  180|       |
  181|  1.30k|    msg->rep_int32.funcs.decode = &field_callback;
  182|  1.30k|    msg->rep_int32.arg = &g_sentinel;
  183|  1.30k|    msg->rep_string.funcs.decode = &field_callback;
  184|  1.30k|    msg->rep_string.arg = &g_sentinel;
  185|  1.30k|    msg->rep_farray.funcs.decode = &field_callback;
  186|  1.30k|    msg->rep_farray.arg = &g_sentinel;
  187|  1.30k|    msg->req_limits.int64_min.funcs.decode = &field_callback;
  188|  1.30k|    msg->req_limits.int64_min.arg = &g_sentinel;
  189|  1.30k|    msg->cb_oneof.funcs.decode = &submsg_callback;
  190|  1.30k|    msg->cb_oneof.arg = &g_sentinel;
  191|       |
  192|  1.30k|    status = pb_decode(&stream, alltypes_callback_AllTypes_fields, msg);
  ------------------
  |  |  465|  1.30k|#define alltypes_callback_AllTypes_fields &alltypes_callback_AllTypes_msg
  ------------------
  193|       |
  194|  1.30k|    if (assert_success)
  ------------------
  |  Branch (194:9): [True: 1.30k, False: 0]
  ------------------
  195|  1.30k|    {
  196|  1.30k|        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 (196:13): [True: 0, False: 1.30k]
  ------------------
  197|  1.30k|        assert(status);
  ------------------
  |  Branch (197:9): [True: 0, False: 1.30k]
  |  Branch (197:9): [True: 1.30k, False: 0]
  ------------------
  198|  1.30k|    }
  199|       |
  200|  1.30k|    pb_release(alltypes_callback_AllTypes_fields, msg);
  ------------------
  |  |  465|  1.30k|#define alltypes_callback_AllTypes_fields &alltypes_callback_AllTypes_msg
  ------------------
  201|  1.30k|    free_with_check(msg);
  202|  1.30k|    assert(get_alloc_count() == initial_alloc_count);
  ------------------
  |  Branch (202:5): [True: 0, False: 1.30k]
  |  Branch (202:5): [True: 1.30k, False: 0]
  ------------------
  203|       |
  204|  1.30k|    return status;
  205|  1.30k|}
do_roundtrip:
  209|  1.30k|{
  210|  1.30k|    bool status;
  211|  1.30k|    uint32_t checksum2, checksum3;
  212|  1.30k|    size_t msglen2, msglen3;
  213|  1.30k|    uint8_t *buf2 = malloc_with_check(g_bufsize);
  214|  1.30k|    void *msg = malloc_with_check(structsize);
  215|       |
  216|       |    /* For proto2 types, we also test extension fields */
  217|  1.30k|    alltypes_static_TestExtension extmsg = alltypes_static_TestExtension_init_zero;
  ------------------
  |  |  248|  1.30k|#define alltypes_static_TestExtension_init_zero  {false, ""}
  ------------------
  218|  1.30k|    pb_extension_t ext = pb_extension_init_zero;
  ------------------
  |  |  503|  1.30k|#define pb_extension_init_zero {NULL,NULL,NULL,false}
  ------------------
  219|  1.30k|    pb_extension_t **ext_field = NULL;
  220|  1.30k|    ext.type = &alltypes_static_TestExtension_testextension;
  221|  1.30k|    ext.dest = &extmsg;
  222|  1.30k|    ext.next = NULL;
  223|       |
  224|  1.30k|    assert(buf2 && msg);
  ------------------
  |  Branch (224:5): [True: 0, False: 1.30k]
  |  Branch (224:5): [True: 0, False: 0]
  |  Branch (224:5): [True: 1.30k, False: 0]
  |  Branch (224:5): [True: 1.30k, False: 0]
  ------------------
  225|       |
  226|  1.30k|    if (msgtype == alltypes_static_AllTypes_fields)
  ------------------
  |  |  490|  1.30k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (226:9): [True: 1.30k, False: 0]
  ------------------
  227|  1.30k|    {
  228|  1.30k|        ext_field = &((alltypes_static_AllTypes*)msg)->extensions;
  229|  1.30k|    }
  230|      0|    else if (msgtype == alltypes_pointer_AllTypes_fields)
  ------------------
  |  |  465|      0|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  |  Branch (230:14): [True: 0, False: 0]
  ------------------
  231|      0|    {
  232|      0|        ext_field = &((alltypes_pointer_AllTypes*)msg)->extensions;
  233|      0|    }
  234|       |    
  235|       |    /* Decode and encode the input data.
  236|       |     * This will bring it into canonical format.
  237|       |     */
  238|  1.30k|    {
  239|  1.30k|        pb_istream_t stream = pb_istream_from_buffer(buffer, msglen);
  240|  1.30k|        memset(msg, 0, structsize);
  241|  1.30k|        if (ext_field) *ext_field = &ext;
  ------------------
  |  Branch (241:13): [True: 1.30k, False: 0]
  ------------------
  242|  1.30k|        status = pb_decode(&stream, msgtype, msg);
  243|  1.30k|        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.30k]
  ------------------
  244|  1.30k|        assert(status);
  ------------------
  |  Branch (244:9): [True: 0, False: 1.30k]
  |  Branch (244:9): [True: 1.30k, False: 0]
  ------------------
  245|       |
  246|  1.30k|        validate_message(msg, structsize, msgtype);
  247|  1.30k|    }
  248|       |    
  249|  1.30k|    {
  250|  1.30k|        pb_ostream_t stream = pb_ostream_from_buffer(buf2, g_bufsize);
  251|  1.30k|        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.30k|        if (!status && strcmp(PB_GET_ERROR(&stream), "stream full") != 0)
  ------------------
  |  |  917|      0|#define PB_GET_ERROR(stream) ((stream)->errmsg ? (stream)->errmsg : "(none)")
  |  |  ------------------
  |  |  |  Branch (917:31): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (255:13): [True: 0, False: 1.30k]
  |  Branch (255:24): [True: 0, False: 0]
  ------------------
  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.30k|        msglen2 = stream.bytes_written;
  262|  1.30k|        checksum2 = xor32_checksum(buf2, msglen2);
  263|  1.30k|    }
  264|       |    
  265|  1.30k|    pb_release(msgtype, msg);
  266|       |
  267|       |    /* Then decode from canonical format and re-encode. Result should remain the same. */
  268|  1.30k|    if (status)
  ------------------
  |  Branch (268:9): [True: 1.30k, False: 0]
  ------------------
  269|  1.30k|    {
  270|  1.30k|        pb_istream_t stream = pb_istream_from_buffer(buf2, msglen2);
  271|  1.30k|        memset(msg, 0, structsize);
  272|  1.30k|        if (ext_field) *ext_field = &ext;
  ------------------
  |  Branch (272:13): [True: 1.30k, False: 0]
  ------------------
  273|  1.30k|        status = pb_decode(&stream, msgtype, msg);
  274|  1.30k|        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.30k]
  ------------------
  275|  1.30k|        assert(status);
  ------------------
  |  Branch (275:9): [True: 0, False: 1.30k]
  |  Branch (275:9): [True: 1.30k, False: 0]
  ------------------
  276|       |
  277|  1.30k|        validate_message(msg, structsize, msgtype);
  278|  1.30k|    }
  279|       |    
  280|  1.30k|    if (status)
  ------------------
  |  Branch (280:9): [True: 1.30k, False: 0]
  ------------------
  281|  1.30k|    {
  282|  1.30k|        pb_ostream_t stream = pb_ostream_from_buffer(buf2, g_bufsize);
  283|  1.30k|        status = pb_encode(&stream, msgtype, msg);
  284|  1.30k|        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.30k]
  ------------------
  285|  1.30k|        assert(status);
  ------------------
  |  Branch (285:9): [True: 0, False: 1.30k]
  |  Branch (285:9): [True: 1.30k, False: 0]
  ------------------
  286|  1.30k|        msglen3 = stream.bytes_written;
  287|  1.30k|        checksum3 = xor32_checksum(buf2, msglen3);
  288|       |
  289|  1.30k|        assert(msglen2 == msglen3);
  ------------------
  |  Branch (289:9): [True: 0, False: 1.30k]
  |  Branch (289:9): [True: 1.30k, False: 0]
  ------------------
  290|  1.30k|        assert(checksum2 == checksum3);
  ------------------
  |  Branch (290:9): [True: 0, False: 1.30k]
  |  Branch (290:9): [True: 1.30k, False: 0]
  ------------------
  291|  1.30k|    }
  292|       |    
  293|  1.30k|    pb_release(msgtype, msg);
  294|  1.30k|    free_with_check(msg);
  295|  1.30k|    free_with_check(buf2);
  296|  1.30k|}
do_roundtrips:
  300|  3.01k|{
  301|  3.01k|    size_t initial_alloc_count = get_alloc_count();
  302|  3.01k|    PB_UNUSED(expect_valid); /* Potentially unused depending on configuration */
  ------------------
  |  |  169|  3.01k|#define PB_UNUSED(x) (void)(x)
  ------------------
  303|       |
  304|  3.01k|#ifdef FUZZTEST_PROTO2_STATIC
  305|  3.01k|    if (do_decode(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, 0, expect_valid))
  ------------------
  |  |  490|  3.01k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (305:9): [True: 1.30k, False: 1.70k]
  ------------------
  306|  1.30k|    {
  307|  1.30k|        do_roundtrip(data, size, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields);
  ------------------
  |  |  490|  1.30k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  308|  1.30k|        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_static_AllTypes), alltypes_static_AllTypes_fields, 0, true);
  ------------------
  |  |  490|  1.30k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  309|  1.30k|        do_callback_decode(data, size, true);
  310|  1.30k|    }
  311|  3.01k|#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|       |#ifdef FUZZTEST_PROTO2_POINTER
  322|       |    if (do_decode(data, size, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, 0, expect_valid))
  323|       |    {
  324|       |        do_roundtrip(data, size, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields);
  325|       |        do_stream_decode(data, size, SIZE_MAX, sizeof(alltypes_pointer_AllTypes), alltypes_pointer_AllTypes_fields, 0, true);
  326|       |    }
  327|       |#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.01k]
  |  Branch (359:5): [True: 3.01k, False: 0]
  ------------------
  360|  3.01k|}
LLVMFuzzerTestOneInput:
  364|  3.01k|{
  365|  3.01k|    if (size > g_bufsize)
  ------------------
  |  Branch (365:9): [True: 3, False: 3.01k]
  ------------------
  366|      3|        return 0;
  367|       |
  368|  3.01k|    do_roundtrips(data, size, false);
  369|       |
  370|  3.01k|    return 0;
  371|  3.01k|}
fuzztest.c:field_callback:
  155|  6.16k|{
  156|  6.16k|    assert(stream);
  ------------------
  |  Branch (156:5): [True: 0, False: 6.16k]
  |  Branch (156:5): [True: 6.16k, False: 0]
  ------------------
  157|  6.16k|    assert(field);
  ------------------
  |  Branch (157:5): [True: 0, False: 6.16k]
  |  Branch (157:5): [True: 6.16k, False: 0]
  ------------------
  158|  6.16k|    assert(*arg == &g_sentinel);
  ------------------
  |  Branch (158:5): [True: 0, False: 6.16k]
  |  Branch (158:5): [True: 6.16k, False: 0]
  ------------------
  159|  6.16k|    return pb_read(stream, NULL, stream->bytes_left);
  160|  6.16k|}
fuzztest.c:submsg_callback:
  163|  36.8k|{
  164|  36.8k|    assert(stream);
  ------------------
  |  Branch (164:5): [True: 0, False: 36.8k]
  |  Branch (164:5): [True: 36.8k, False: 0]
  ------------------
  165|  36.8k|    assert(field);
  ------------------
  |  Branch (165:5): [True: 0, False: 36.8k]
  |  Branch (165:5): [True: 36.8k, False: 0]
  ------------------
  166|  36.8k|    assert(*arg == &g_sentinel);
  ------------------
  |  Branch (166:5): [True: 0, False: 36.8k]
  |  Branch (166:5): [True: 36.8k, False: 0]
  ------------------
  167|  36.8k|    return true;
  168|  36.8k|}
fuzztest.c:xor32_checksum:
   52|  2.61k|{
   53|  2.61k|    const uint8_t *buf = (const uint8_t*)data;
   54|  2.61k|    uint32_t checksum = 1234;
   55|   652k|    for (; len > 0; len--)
  ------------------
  |  Branch (55:12): [True: 650k, False: 2.61k]
  ------------------
   56|   650k|    {
   57|   650k|        checksum ^= checksum << 13;
   58|   650k|        checksum ^= checksum >> 17;
   59|   650k|        checksum ^= checksum << 5;
   60|   650k|        checksum += *buf++;
   61|   650k|    }
   62|  2.61k|    return checksum;
   63|  2.61k|}
fuzztest.c:do_decode:
   66|  3.01k|{
   67|  3.01k|    bool status;
   68|  3.01k|    pb_istream_t stream;
   69|  3.01k|    size_t initial_alloc_count = get_alloc_count();
   70|  3.01k|    uint8_t *buf2 = malloc_with_check(g_bufsize); /* This is just to match the amount of memory allocations in do_roundtrips(). */
   71|  3.01k|    void *msg = malloc_with_check(structsize);
   72|  3.01k|    alltypes_static_TestExtension extmsg = alltypes_static_TestExtension_init_zero;
  ------------------
  |  |  248|  3.01k|#define alltypes_static_TestExtension_init_zero  {false, ""}
  ------------------
   73|  3.01k|    pb_extension_t ext = pb_extension_init_zero;
  ------------------
  |  |  503|  3.01k|#define pb_extension_init_zero {NULL,NULL,NULL,false}
  ------------------
   74|  3.01k|    assert(msg);
  ------------------
  |  Branch (74:5): [True: 0, False: 3.01k]
  |  Branch (74:5): [True: 3.01k, False: 0]
  ------------------
   75|       |
   76|  3.01k|    memset(msg, 0, structsize);
   77|  3.01k|    ext.type = &alltypes_static_TestExtension_testextension;
   78|  3.01k|    ext.dest = &extmsg;
   79|  3.01k|    ext.next = NULL;
   80|       |
   81|  3.01k|    if (msgtype == alltypes_static_AllTypes_fields)
  ------------------
  |  |  490|  3.01k|#define alltypes_static_AllTypes_fields &alltypes_static_AllTypes_msg
  ------------------
  |  Branch (81:9): [True: 3.01k, False: 0]
  ------------------
   82|  3.01k|    {
   83|  3.01k|        ((alltypes_static_AllTypes*)msg)->extensions = &ext;
   84|  3.01k|    }
   85|      0|    else if (msgtype == alltypes_pointer_AllTypes_fields)
  ------------------
  |  |  465|      0|#define alltypes_pointer_AllTypes_fields &alltypes_pointer_AllTypes_msg
  ------------------
  |  Branch (85:14): [True: 0, False: 0]
  ------------------
   86|      0|    {
   87|      0|        ((alltypes_pointer_AllTypes*)msg)->extensions = &ext;
   88|      0|    }
   89|       |
   90|  3.01k|    stream = pb_istream_from_buffer(buffer, msglen);
   91|  3.01k|    status = pb_decode_ex(&stream, msgtype, msg, flags);
   92|       |
   93|  3.01k|    if (status)
  ------------------
  |  Branch (93:9): [True: 1.30k, False: 1.70k]
  ------------------
   94|  1.30k|    {
   95|  1.30k|        validate_message(msg, structsize, msgtype);
   96|  1.30k|    }
   97|       |
   98|  3.01k|    if (assert_success)
  ------------------
  |  Branch (98:9): [True: 0, False: 3.01k]
  ------------------
   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.01k|    if (status)
  ------------------
  |  Branch (104:9): [True: 1.30k, False: 1.70k]
  ------------------
  105|  1.30k|    {
  106|       |        /* On error return, pb_release() should be called automatically. */
  107|  1.30k|        pb_release(msgtype, msg);
  108|  1.30k|    }
  109|       |
  110|  3.01k|    free_with_check(msg);
  111|  3.01k|    free_with_check(buf2);
  112|  3.01k|    assert(get_alloc_count() == initial_alloc_count);
  ------------------
  |  Branch (112:5): [True: 0, False: 3.01k]
  |  Branch (112:5): [True: 3.01k, False: 0]
  ------------------
  113|       |    
  114|  3.01k|    return status;
  115|  3.01k|}
fuzztest.c:do_stream_decode:
  118|  1.30k|{
  119|  1.30k|    bool status;
  120|  1.30k|    flakystream_t stream;
  121|  1.30k|    size_t initial_alloc_count = get_alloc_count();
  122|  1.30k|    void *msg = malloc_with_check(structsize);
  123|  1.30k|    assert(msg);
  ------------------
  |  Branch (123:5): [True: 0, False: 1.30k]
  |  Branch (123:5): [True: 1.30k, False: 0]
  ------------------
  124|       |
  125|  1.30k|    memset(msg, 0, structsize);
  126|  1.30k|    flakystream_init(&stream, buffer, msglen, fail_after);
  127|  1.30k|    status = pb_decode_ex(&stream.stream, msgtype, msg, flags);
  128|       |
  129|  1.30k|    if (status)
  ------------------
  |  Branch (129:9): [True: 1.30k, False: 0]
  ------------------
  130|  1.30k|    {
  131|  1.30k|        validate_message(msg, structsize, msgtype);
  132|  1.30k|    }
  133|       |
  134|  1.30k|    if (assert_success)
  ------------------
  |  Branch (134:9): [True: 1.30k, False: 0]
  ------------------
  135|  1.30k|    {
  136|  1.30k|        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.30k]
  ------------------
  137|  1.30k|        assert(status);
  ------------------
  |  Branch (137:9): [True: 0, False: 1.30k]
  |  Branch (137:9): [True: 1.30k, False: 0]
  ------------------
  138|  1.30k|    }
  139|       |
  140|  1.30k|    if (status)
  ------------------
  |  Branch (140:9): [True: 1.30k, False: 0]
  ------------------
  141|  1.30k|    {
  142|       |        /* On error return, pb_release() should be called automatically. */
  143|  1.30k|        pb_release(msgtype, msg);
  144|  1.30k|    }
  145|       |
  146|  1.30k|    free_with_check(msg);
  147|  1.30k|    assert(get_alloc_count() == initial_alloc_count);
  ------------------
  |  Branch (147:5): [True: 0, False: 1.30k]
  |  Branch (147:5): [True: 1.30k, False: 0]
  ------------------
  148|       |
  149|  1.30k|    return status;
  150|  1.30k|}

validate_static:
    7|   495k|{
    8|   495k|    pb_size_t count = 1;
    9|   495k|    pb_size_t i;
   10|   495k|    bool truebool = true;
   11|   495k|    bool falsebool = false;
   12|       |
   13|   495k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  324|   495k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   495k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  311|   990k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 109k, False: 385k]
  |  Branch (13:54): [True: 109k, False: 0]
  ------------------
   14|   109k|    {
   15|       |        /* Array count must be between 0 and statically allocated size */
   16|   109k|        count = *(pb_size_t*)iter->pSize;
   17|   109k|        assert(count <= iter->array_size);
  ------------------
  |  Branch (17:9): [True: 0, False: 109k]
  |  Branch (17:9): [True: 109k, False: 0]
  ------------------
   18|   109k|    }
   19|   385k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  324|   385k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   385k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  309|   770k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 119k, False: 265k]
  |  Branch (19:59): [True: 119k, False: 0]
  ------------------
   20|   119k|    {
   21|       |        /* Boolean has_ field must have a valid value */
   22|   119k|        assert(memcmp(iter->pSize, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (22:9): [True: 119k, False: 0]
  |  Branch (22:9): [True: 0, False: 0]
  |  Branch (22:9): [True: 10.4k, False: 109k]
  |  Branch (22:9): [True: 109k, False: 0]
  ------------------
   23|   119k|               memcmp(iter->pSize, &falsebool, sizeof(bool)) == 0);
   24|   119k|    }
   25|   265k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  324|   265k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   265k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  313|   265k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 15.6k, False: 249k]
  ------------------
   26|  15.6k|    {
   27|  15.6k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 14.0k, False: 1.63k]
  ------------------
   28|  14.0k|        {
   29|       |            /* Some different field in oneof */
   30|  14.0k|            return;
   31|  14.0k|        }
   32|  15.6k|    }
   33|       |
   34|   938k|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 457k, False: 481k]
  ------------------
   35|   457k|    {
   36|   457k|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|   457k|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  325|   457k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   457k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  281|   457k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 28.0k, False: 429k]
  ------------------
   39|  28.0k|        {
   40|       |            /* String length must be at most statically allocated size */
   41|  28.0k|            assert(strlen(pData) + 1 <= iter->data_size);
  ------------------
  |  Branch (41:13): [True: 0, False: 28.0k]
  |  Branch (41:13): [True: 28.0k, False: 0]
  ------------------
   42|  28.0k|        }
   43|   429k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  325|   429k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   429k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  277|   429k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 12.5k, False: 416k]
  ------------------
   44|  12.5k|        {
   45|       |            /* Bytes length must be at most statically allocated size */
   46|  12.5k|            pb_bytes_array_t *bytes = pData;
   47|  12.5k|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= iter->data_size);
  ------------------
  |  Branch (47:13): [True: 0, False: 12.5k]
  |  Branch (47:13): [True: 12.5k, False: 0]
  ------------------
   48|  12.5k|        }
   49|   416k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  325|   416k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  304|   416k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  265|   416k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 11.9k, False: 404k]
  ------------------
   50|  11.9k|        {
   51|       |            /* Bool fields must have valid value */
   52|  11.9k|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (52:13): [True: 11.9k, False: 0]
  |  Branch (52:13): [True: 0, False: 0]
  |  Branch (52:13): [True: 4.91k, False: 7.08k]
  |  Branch (52:13): [True: 7.08k, False: 0]
  ------------------
   53|  11.9k|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
   54|  11.9k|        }
   55|   404k|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  326|   404k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  325|   404k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|   404k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  285|   809k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (326:32): [True: 43.4k, False: 361k]
  |  |  ------------------
  |  |  327|   404k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  325|   361k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|   361k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  290|   361k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (327:32): [True: 0, False: 361k]
  |  |  ------------------
  ------------------
   56|  43.4k|        {
   57|  43.4k|            validate_message(pData, 0, iter->submsg_desc);
   58|  43.4k|        }
   59|   457k|    }
   60|   481k|}
validate_message:
  145|  48.7k|{
  146|  48.7k|    pb_field_iter_t iter;
  147|       |
  148|  48.7k|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 36.0k, False: 12.6k]
  ------------------
  149|  36.0k|    {
  150|  36.0k|        do
  151|   500k|        {
  152|   500k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  323|   500k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|   500k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  318|   500k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 495k, False: 5.23k]
  ------------------
  153|   495k|            {
  154|   495k|                validate_static(&iter);
  155|   495k|            }
  156|  5.23k|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  323|  5.23k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  321|  5.23k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  319|  5.23k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 0, False: 5.23k]
  ------------------
  157|      0|            {
  158|      0|                validate_pointer(&iter);
  159|      0|            }
  160|   500k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 464k, False: 36.0k]
  ------------------
  161|  36.0k|    }
  162|  48.7k|}

