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

pb_read:
   83|  2.65M|{
   84|  2.65M|    if (count == 0)
  ------------------
  |  Branch (84:9): [True: 194k, False: 2.46M]
  ------------------
   85|   194k|        return true;
   86|       |
   87|  2.46M|#ifndef PB_BUFFER_ONLY
   88|  2.46M|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (88:6): [True: 312k, False: 2.14M]
  |  Branch (88:21): [True: 69.9k, False: 242k]
  ------------------
   89|  69.9k|	{
   90|       |		/* Skip input bytes */
   91|  69.9k|		pb_byte_t tmp[16];
   92|   551k|		while (count > 16)
  ------------------
  |  Branch (92:10): [True: 481k, False: 69.9k]
  ------------------
   93|   481k|		{
   94|   481k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (94:8): [True: 0, False: 481k]
  ------------------
   95|      0|				return false;
   96|       |			
   97|   481k|			count -= 16;
   98|   481k|		}
   99|       |		
  100|  69.9k|		return pb_read(stream, tmp, count);
  101|  69.9k|	}
  102|  2.39M|#endif
  103|       |
  104|  2.39M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (104:9): [True: 242, False: 2.39M]
  ------------------
  105|    242|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  937|    242|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|    242|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 242]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  106|       |    
  107|  2.39M|#ifndef PB_BUFFER_ONLY
  108|  2.39M|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (108:9): [True: 0, False: 2.39M]
  ------------------
  109|      0|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  110|       |#else
  111|       |    if (!buf_read(stream, buf, count))
  112|       |        return false;
  113|       |#endif
  114|       |    
  115|  2.39M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (115:9): [True: 0, False: 2.39M]
  ------------------
  116|      0|        stream->bytes_left = 0;
  117|  2.39M|    else
  118|  2.39M|        stream->bytes_left -= count;
  119|       |
  120|       |    return true;
  121|  2.39M|}
pb_istream_from_buffer:
  144|   129k|{
  145|   129k|    pb_istream_t stream;
  146|       |    /* Cast away the const from buf without a compiler error.  We are
  147|       |     * careful to use it only in a const manner in the callbacks.
  148|       |     */
  149|   129k|    union {
  150|   129k|        void *state;
  151|   129k|        const void *c_state;
  152|   129k|    } state;
  153|       |#ifdef PB_BUFFER_ONLY
  154|       |    stream.callback = NULL;
  155|       |#else
  156|   129k|    stream.callback = &buf_read;
  157|   129k|#endif
  158|   129k|    state.c_state = buf;
  159|   129k|    stream.state = state.state;
  160|   129k|    stream.bytes_left = msglen;
  161|   129k|#ifndef PB_NO_ERRMSG
  162|   129k|    stream.errmsg = NULL;
  163|   129k|#endif
  164|       |#ifdef PB_MESSAGE_NESTING_MAX
  165|       |    stream.depth = 0;
  166|       |#endif
  167|   129k|    return stream;
  168|   129k|}
pb_decode_varint32:
  250|  1.22M|{
  251|       |    return pb_decode_varint32_eof(stream, dest, NULL);
  252|  1.22M|}
pb_decode_varint:
  256|  5.57M|{
  257|  5.57M|    pb_byte_t byte;
  258|  5.57M|    uint_fast8_t bitpos = 0;
  259|  5.57M|    uint64_t result = 0;
  260|       |    
  261|  5.57M|    do
  262|  6.76M|    {
  263|  6.76M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (263:13): [True: 58, False: 6.76M]
  ------------------
  264|     58|            return false;
  265|       |
  266|  6.76M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (266:13): [True: 50.8k, False: 6.71M]
  |  Branch (266:29): [True: 24, False: 50.8k]
  ------------------
  267|     24|            PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  937|     24|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     24|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  268|       |
  269|  6.76M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  270|  6.76M|        bitpos = (uint_fast8_t)(bitpos + 7);
  271|  6.76M|    } while (byte & 0x80);
  ------------------
  |  Branch (271:14): [True: 1.18M, False: 5.57M]
  ------------------
  272|       |    
  273|  5.57M|    *dest = result;
  274|       |    return true;
  275|  5.57M|}
pb_decode_tag:
  304|  8.59M|{
  305|  8.59M|    uint32_t temp;
  306|  8.59M|    *eof = false;
  307|  8.59M|    *wire_type = (pb_wire_type_t) 0;
  308|  8.59M|    *tag = 0;
  309|       |
  310|  8.59M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (310:9): [True: 303k, False: 8.28M]
  ------------------
  311|   303k|    {
  312|   303k|        *eof = true;
  313|   303k|        return false;
  314|   303k|    }
  315|       |
  316|  8.28M|    if (!pb_decode_varint32_eof(stream, &temp, eof))
  ------------------
  |  Branch (316:9): [True: 1.44k, False: 8.28M]
  ------------------
  317|  1.44k|    {
  318|  1.44k|        return false;
  319|  1.44k|    }
  320|       |    
  321|  8.28M|    *tag = temp >> 3;
  322|  8.28M|    *wire_type = (pb_wire_type_t)(temp & 7);
  323|       |    return true;
  324|  8.28M|}
pb_skip_field:
  327|   993k|{
  328|   993k|    switch (wire_type)
  329|   993k|    {
  330|   632k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (330:9): [True: 632k, False: 360k]
  ------------------
  331|  76.5k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (331:9): [True: 76.5k, False: 916k]
  ------------------
  332|   160k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (332:9): [True: 160k, False: 832k]
  ------------------
  333|   123k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (333:9): [True: 123k, False: 869k]
  ------------------
  334|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (334:2): [True: 0, False: 993k]
  ------------------
  335|       |            /* Calling pb_skip_field with a PB_WT_PACKED is an error.
  336|       |             * Explicitly handle this case and fallthrough to default to avoid
  337|       |             * compiler warnings.
  338|       |             */
  339|     97|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  937|     97|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     97|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 97]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (339:9): [True: 97, False: 993k]
  ------------------
  340|   993k|    }
  341|   993k|}
pb_make_string_substream:
  392|   405k|{
  393|   405k|    uint32_t size;
  394|   405k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (394:9): [True: 75, False: 405k]
  ------------------
  395|     75|        return false;
  396|       |    
  397|   405k|    *substream = *stream;
  398|   405k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (398:9): [True: 122, False: 405k]
  ------------------
  399|    122|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  937|    122|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|    122|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 122]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  400|       |    
  401|       |#ifdef PB_MESSAGE_NESTING_MAX
  402|       |    substream->depth++;
  403|       |    if (substream->depth > PB_MESSAGE_NESTING_MAX)
  404|       |        PB_RETURN_ERROR(stream, "max depth");
  405|       |#endif
  406|       |
  407|   405k|    substream->bytes_left = (size_t)size;
  408|   405k|    stream->bytes_left -= (size_t)size;
  409|       |    return true;
  410|   405k|}
pb_close_string_substream:
  413|   405k|{
  414|   405k|    if (substream->bytes_left) {
  ------------------
  |  Branch (414:9): [True: 26.6k, False: 378k]
  ------------------
  415|  26.6k|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (415:13): [True: 0, False: 26.6k]
  ------------------
  416|      0|            return false;
  417|  26.6k|    }
  418|       |
  419|   405k|    stream->state = substream->state;
  420|       |
  421|   405k|#ifndef PB_NO_ERRMSG
  422|   405k|    stream->errmsg = substream->errmsg;
  423|   405k|#endif
  424|       |    return true;
  425|   405k|}
pb_decode_ex:
 1332|  8.52k|{
 1333|  8.52k|    bool status;
 1334|       |
 1335|  8.52k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  123|  8.52k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1335:9): [True: 8.52k, False: 0]
  ------------------
 1336|  8.52k|    {
 1337|  8.52k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1338|  8.52k|    }
 1339|      0|    else
 1340|      0|    {
 1341|      0|      pb_istream_t substream;
 1342|      0|      if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1342:11): [True: 0, False: 0]
  ------------------
 1343|      0|        return false;
 1344|       |
 1345|      0|      status = pb_decode_inner(&substream, fields, dest_struct, flags);
 1346|       |
 1347|      0|      if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1347:11): [True: 0, False: 0]
  ------------------
 1348|      0|        status = false;
 1349|      0|    }
 1350|       |    
 1351|       |#ifdef PB_ENABLE_MALLOC
 1352|       |    if (!status)
 1353|       |        pb_release(fields, dest_struct);
 1354|       |#endif
 1355|       |    
 1356|  8.52k|    return status;
 1357|  8.52k|}
pb_decode:
 1360|  3.99k|{
 1361|  3.99k|    return pb_decode_ex(stream, fields, dest_struct, 0);
 1362|  3.99k|}
pb_release:
 1511|  6.66k|{
 1512|       |    /* Nothing to release without PB_ENABLE_MALLOC. */
 1513|  6.66k|    PB_UNUSED(fields);
  ------------------
  |  |  179|  6.66k|#define PB_UNUSED(x) (void)(x)
  ------------------
 1514|  6.66k|    PB_UNUSED(dest_struct);
  ------------------
  |  |  179|  6.66k|#define PB_UNUSED(x) (void)(x)
  ------------------
 1515|  6.66k|}
pb_decode_bool:
 1521|   354k|{
 1522|   354k|    uint32_t value;
 1523|   354k|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1523:9): [True: 19, False: 354k]
  ------------------
 1524|     19|        return false;
 1525|       |
 1526|   354k|    *(bool*)dest = (value != 0);
 1527|       |    return true;
 1528|   354k|}
pb_decode_svarint:
 1531|   175k|{
 1532|   175k|    pb_uint64_t value;
  ------------------
  |  |   58|   175k|#define pb_uint64_t uint64_t
  ------------------
 1533|   175k|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1533:9): [True: 24, False: 175k]
  ------------------
 1534|     24|        return false;
 1535|       |    
 1536|   175k|    if (value & 1)
  ------------------
  |  Branch (1536:9): [True: 31.5k, False: 143k]
  ------------------
 1537|  31.5k|        *dest = (pb_int64_t)(~(value >> 1));
 1538|   143k|    else
 1539|   143k|        *dest = (pb_int64_t)(value >> 1);
 1540|       |    
 1541|       |    return true;
 1542|   175k|}
pb_decode_fixed32:
 1545|   306k|{
 1546|   306k|    union {
 1547|   306k|        uint32_t fixed32;
 1548|   306k|        pb_byte_t bytes[4];
 1549|   306k|    } u;
 1550|       |
 1551|   306k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1551:9): [True: 16, False: 306k]
  ------------------
 1552|     16|        return false;
 1553|       |
 1554|   306k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1555|       |    /* fast path - if we know that we're on little endian, assign directly */
 1556|   306k|    *(uint32_t*)dest = u.fixed32;
 1557|       |#else
 1558|       |    *(uint32_t*)dest = ((uint32_t)u.bytes[0] << 0) |
 1559|       |                       ((uint32_t)u.bytes[1] << 8) |
 1560|       |                       ((uint32_t)u.bytes[2] << 16) |
 1561|       |                       ((uint32_t)u.bytes[3] << 24);
 1562|       |#endif
 1563|       |    return true;
 1564|   306k|}
pb_decode_fixed64:
 1568|   256k|{
 1569|   256k|    union {
 1570|   256k|        uint64_t fixed64;
 1571|   256k|        pb_byte_t bytes[8];
 1572|   256k|    } u;
 1573|       |
 1574|   256k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1574:9): [True: 15, False: 256k]
  ------------------
 1575|     15|        return false;
 1576|       |
 1577|   256k|#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1578|       |    /* fast path - if we know that we're on little endian, assign directly */
 1579|   256k|    *(uint64_t*)dest = u.fixed64;
 1580|       |#else
 1581|       |    *(uint64_t*)dest = ((uint64_t)u.bytes[0] << 0) |
 1582|       |                       ((uint64_t)u.bytes[1] << 8) |
 1583|       |                       ((uint64_t)u.bytes[2] << 16) |
 1584|       |                       ((uint64_t)u.bytes[3] << 24) |
 1585|       |                       ((uint64_t)u.bytes[4] << 32) |
 1586|       |                       ((uint64_t)u.bytes[5] << 40) |
 1587|       |                       ((uint64_t)u.bytes[6] << 48) |
 1588|       |                       ((uint64_t)u.bytes[7] << 56);
 1589|       |#endif
 1590|       |    return true;
 1591|   256k|}
pb_decode.c:buf_read:
   70|  15.4M|{
   71|  15.4M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   72|  15.4M|    stream->state = (pb_byte_t*)stream->state + count;
   73|       |    
   74|  15.4M|    if (buf != NULL)
  ------------------
  |  Branch (74:9): [True: 15.2M, False: 242k]
  ------------------
   75|  15.2M|    {
   76|  15.2M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   77|  15.2M|    }
   78|       |    
   79|       |    return true;
   80|  15.4M|}
pb_decode.c:pb_decode_varint32_eof:
  178|  9.51M|{
  179|  9.51M|    pb_byte_t byte;
  180|  9.51M|    uint32_t result;
  181|       |
  182|       |#ifdef PB_BUFFER_ONLY
  183|       |    (void)eof;
  184|       |#endif
  185|       |    
  186|  9.51M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (186:9): [True: 1.48k, False: 9.51M]
  ------------------
  187|  1.48k|    {
  188|  1.48k|#ifndef PB_BUFFER_ONLY
  189|  1.48k|        if (eof != NULL && stream->callback != buf_read && stream->bytes_left == 0)
  ------------------
  |  Branch (189:13): [True: 1.33k, False: 154]
  |  Branch (189:28): [True: 1.33k, False: 0]
  |  Branch (189:60): [True: 1.33k, False: 0]
  ------------------
  190|  1.33k|        {
  191|  1.33k|#ifndef PB_NO_ERRMSG
  192|  1.33k|            if (strcmp(stream->errmsg, "io error") == 0)
  ------------------
  |  Branch (192:17): [True: 1.33k, False: 0]
  ------------------
  193|  1.33k|                stream->errmsg = NULL;
  194|  1.33k|#endif
  195|  1.33k|            *eof = true;
  196|  1.33k|        }
  197|  1.48k|#endif
  198|  1.48k|        return false;
  199|  1.48k|    }
  200|       |    
  201|  9.51M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (201:9): [True: 8.20M, False: 1.30M]
  ------------------
  202|  8.20M|    {
  203|       |        /* Quick case, 1 byte value */
  204|  8.20M|        result = byte;
  205|  8.20M|    }
  206|  1.30M|    else
  207|  1.30M|    {
  208|       |        /* Multibyte case */
  209|  1.30M|        uint_fast8_t bitpos = 7;
  210|  1.30M|        result = byte & 0x7F;
  211|       |        
  212|  1.30M|        do
  213|  1.64M|        {
  214|  1.64M|            if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (214:17): [True: 48, False: 1.64M]
  ------------------
  215|     48|                return false;
  216|       |            
  217|  1.64M|            if (bitpos >= 32)
  ------------------
  |  Branch (217:17): [True: 22.4k, False: 1.62M]
  ------------------
  218|  22.4k|            {
  219|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  220|  22.4k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (220:44): [True: 21.9k, False: 543]
  ------------------
  221|  22.4k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (221:41): [True: 5.87k, False: 16.5k]
  ------------------
  222|  16.5k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (222:27): [True: 16.5k, False: 13]
  |  Branch (222:50): [True: 16.5k, False: 52]
  ------------------
  223|       |
  224|  22.4k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (224:21): [True: 3, False: 22.4k]
  |  Branch (224:37): [True: 63, False: 22.3k]
  ------------------
  225|     66|                {
  226|     66|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  937|     66|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     66|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 66]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  227|     66|                }
  228|  22.4k|            }
  229|  1.62M|            else if (bitpos == 28)
  ------------------
  |  Branch (229:22): [True: 13.4k, False: 1.60M]
  ------------------
  230|  13.4k|            {
  231|  13.4k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (231:21): [True: 5.77k, False: 7.64k]
  |  Branch (231:43): [True: 20, False: 5.75k]
  ------------------
  232|     20|                {
  233|     20|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  937|     20|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     20|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  234|     20|                }
  235|  13.3k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  236|  13.3k|            }
  237|  1.60M|            else
  238|  1.60M|            {
  239|  1.60M|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  240|  1.60M|            }
  241|  1.64M|            bitpos = (uint_fast8_t)(bitpos + 7);
  242|  1.64M|        } while (byte & 0x80);
  ------------------
  |  Branch (242:18): [True: 333k, False: 1.30M]
  ------------------
  243|  1.30M|   }
  244|       |   
  245|  9.51M|   *dest = result;
  246|       |   return true;
  247|  9.51M|}
pb_decode.c:pb_readbyte:
  126|  17.9M|{
  127|  17.9M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (127:9): [True: 260, False: 17.9M]
  ------------------
  128|    260|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  937|    260|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|    260|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 260]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  129|       |
  130|  17.9M|#ifndef PB_BUFFER_ONLY
  131|  17.9M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (131:9): [True: 1.33k, False: 17.9M]
  ------------------
  132|  1.33k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  937|  1.33k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|  1.33k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 1.33k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  133|       |#else
  134|       |    *buf = *(const pb_byte_t*)stream->state;
  135|       |    stream->state = (pb_byte_t*)stream->state + 1;
  136|       |#endif
  137|       |
  138|  17.9M|    stream->bytes_left--;
  139|       |    
  140|       |    return true;    
  141|  17.9M|}
pb_decode.c:pb_skip_varint:
  279|   632k|{
  280|   632k|    pb_byte_t byte;
  281|   632k|    do
  282|   832k|    {
  283|   832k|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (283:13): [True: 50, False: 832k]
  ------------------
  284|     50|            return false;
  285|   832k|    } while (byte & 0x80);
  ------------------
  |  Branch (285:14): [True: 200k, False: 632k]
  ------------------
  286|   632k|    return true;
  287|   632k|}
pb_decode.c:pb_skip_string:
  290|   160k|{
  291|   160k|    uint32_t length;
  292|   160k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (292:9): [True: 73, False: 160k]
  ------------------
  293|     73|        return false;
  294|       |    
  295|   160k|    if ((size_t)length != length)
  ------------------
  |  Branch (295:9): [True: 0, False: 160k]
  ------------------
  296|      0|    {
  297|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  298|      0|    }
  299|       |
  300|   160k|    return pb_read(stream, NULL, (size_t)length);
  301|   160k|}
pb_decode.c:pb_decode_inner:
 1149|   306k|{
 1150|       |    /* If the message contains extension fields, the extension handlers
 1151|       |     * are called when tag number is >= extension_range_start. This precheck
 1152|       |     * is just for speed, and the handlers will check for precise match.
 1153|       |     */
 1154|   306k|    uint32_t extension_range_start = 0;
 1155|   306k|    pb_extension_t *extensions = NULL;
 1156|       |
 1157|       |    /* 'fixed_count_field' and 'fixed_count_size' track position of a repeated fixed
 1158|       |     * count field. This can only handle _one_ repeated fixed count field that
 1159|       |     * is unpacked and unordered among other (non repeated fixed count) fields.
 1160|       |     */
 1161|   306k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  349|   306k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
 1162|   306k|    pb_size_t fixed_count_size = 0;
 1163|   306k|    pb_size_t fixed_count_total_size = 0;
 1164|       |
 1165|       |    /* Tag and wire type of next field from the input stream */
 1166|   306k|    uint32_t tag;
 1167|   306k|    pb_wire_type_t wire_type;
 1168|   306k|    bool eof;
 1169|       |
 1170|       |    /* Track presence of required fields */
 1171|   306k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1172|   306k|    const uint32_t allbits = ~(uint32_t)0;
 1173|       |
 1174|       |    /* Descriptor for the structure field matching the tag decoded from stream */
 1175|   306k|    pb_field_iter_t iter;
 1176|       |
 1177|   306k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1177:9): [True: 165k, False: 141k]
  ------------------
 1178|   165k|    {
 1179|   165k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |  122|   165k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1179:13): [True: 8.52k, False: 157k]
  ------------------
 1180|  8.52k|        {
 1181|  8.52k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1181:17): [True: 0, False: 8.52k]
  ------------------
 1182|      0|                PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1183|  8.52k|        }
 1184|   165k|    }
 1185|       |
 1186|  7.99M|    while (decode_next_tag(stream, flags, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1186:12): [True: 7.68M, False: 305k]
  ------------------
 1187|  7.68M|    {
 1188|  7.68M|        if (tag == 0)
  ------------------
  |  Branch (1188:13): [True: 63, False: 7.68M]
  ------------------
 1189|     63|        {
 1190|     63|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  124|     63|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1190:15): [True: 0, False: 63]
  ------------------
 1191|      0|          {
 1192|      0|            eof = true;
 1193|      0|            break;
 1194|      0|          }
 1195|     63|          else
 1196|     63|          {
 1197|     63|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  937|     63|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     63|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 63]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1198|     63|          }
 1199|     63|        }
 1200|       |
 1201|  7.68M|        if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  335|  6.68M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  6.68M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  304|  6.68M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1201:13): [True: 998k, False: 6.68M]
  |  Branch (1201:48): [True: 400, False: 6.68M]
  ------------------
 1202|   998k|        {
 1203|       |            /* No match found, check if it matches an extension. */
 1204|   998k|            if (extension_range_start == 0)
  ------------------
  |  Branch (1204:17): [True: 30.9k, False: 967k]
  ------------------
 1205|  30.9k|            {
 1206|  30.9k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1206:21): [True: 3.49k, False: 27.4k]
  ------------------
 1207|  3.49k|                {
 1208|  3.49k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1209|  3.49k|                    extension_range_start = iter.tag;
 1210|  3.49k|                }
 1211|       |
 1212|  30.9k|                if (!extensions)
  ------------------
  |  Branch (1212:21): [True: 28.2k, False: 2.64k]
  ------------------
 1213|  28.2k|                {
 1214|  28.2k|                    extension_range_start = (uint32_t)-1;
 1215|  28.2k|                }
 1216|  30.9k|            }
 1217|       |
 1218|   998k|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1218:17): [True: 131k, False: 867k]
  ------------------
 1219|   131k|            {
 1220|   131k|                size_t pos = stream->bytes_left;
 1221|       |
 1222|   131k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1222:21): [True: 29, False: 130k]
  ------------------
 1223|     29|                    return false;
 1224|       |
 1225|   130k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1225:21): [True: 5.31k, False: 125k]
  ------------------
 1226|  5.31k|                {
 1227|       |                    /* The field was handled */
 1228|  5.31k|                    continue;
 1229|  5.31k|                }
 1230|   130k|            }
 1231|       |
 1232|       |            /* No match found, skip data */
 1233|   993k|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1233:17): [True: 335, False: 992k]
  ------------------
 1234|    335|                return false;
 1235|   992k|            continue;
 1236|   993k|        }
 1237|       |
 1238|       |        /* If a repeated fixed count field was found, get size from
 1239|       |         * 'fixed_count_field' as there is no counter contained in the struct.
 1240|       |         */
 1241|  6.68M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  334|  6.68M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  6.68M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  321|  13.3M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1241:13): [True: 38.7k, False: 6.65M]
  |  Branch (1241:57): [True: 3.87k, False: 34.8k]
  ------------------
 1242|  3.87k|        {
 1243|  3.87k|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1243:17): [True: 3.47k, False: 393]
  ------------------
 1244|       |                /* If the new fixed count field does not match the previous one,
 1245|       |                 * check that the previous one is NULL or that it finished
 1246|       |                 * receiving all the expected data.
 1247|       |                 */
 1248|  3.47k|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  349|  6.95k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1248:21): [True: 1.86k, False: 1.61k]
  ------------------
 1249|  1.86k|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1249:21): [True: 3, False: 1.86k]
  ------------------
 1250|      3|                {
 1251|      3|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  937|      3|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      3|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1252|      3|                }
 1253|       |
 1254|  3.47k|                fixed_count_field = iter.index;
 1255|  3.47k|                fixed_count_size = 0;
 1256|  3.47k|                fixed_count_total_size = iter.array_size;
 1257|       |
 1258|       |#ifdef PB_ENABLE_MALLOC
 1259|       |                /* Decoding restarts from the first entry. If the field was
 1260|       |                 * already decoded (it appeared before another fixed count
 1261|       |                 * field, or the message is being merged), release the old
 1262|       |                 * entries so that overwriting them does not leak memory. */
 1263|       |                {
 1264|       |                    pb_field_iter_t old_field = iter;
 1265|       |                    old_field.pSize = &old_field.array_size;
 1266|       |                    pb_release_single_field(&old_field);
 1267|       |                }
 1268|       |#endif
 1269|  3.47k|            }
 1270|       |
 1271|  3.86k|            iter.pSize = &fixed_count_size;
 1272|  3.86k|        }
 1273|       |
 1274|  6.68M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  334|  6.68M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  6.68M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  318|  13.3M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1274:13): [True: 6.13M, False: 553k]
  ------------------
 1275|  6.13M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  240|  6.13M|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1275:16): [True: 6.13M, False: 0]
  ------------------
 1276|  6.13M|        {
 1277|  6.13M|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1278|  6.13M|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1279|  6.13M|        }
 1280|       |
 1281|  6.68M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1281:13): [True: 1.21k, False: 6.68M]
  ------------------
 1282|  1.21k|            return false;
 1283|  6.68M|    }
 1284|       |
 1285|   305k|    if (!eof)
  ------------------
  |  Branch (1285:9): [True: 113, False: 305k]
  ------------------
 1286|    113|    {
 1287|       |        /* pb_decode_tag() returned error before end of stream */
 1288|    113|        return false;
 1289|    113|    }
 1290|       |
 1291|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1292|   305k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  349|   610k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1292:9): [True: 1.55k, False: 303k]
  ------------------
 1293|  1.55k|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1293:9): [True: 7, False: 1.54k]
  ------------------
 1294|      7|    {
 1295|      7|        PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  937|      7|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      7|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1296|      7|    }
 1297|       |
 1298|       |    /* Check that all required fields were present. */
 1299|   305k|    {
 1300|   305k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1301|       |
 1302|   305k|        if (req_field_count > 0)
  ------------------
  |  Branch (1302:13): [True: 158k, False: 147k]
  ------------------
 1303|   158k|        {
 1304|   158k|            pb_size_t i;
 1305|       |
 1306|   158k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  240|   158k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1306:17): [True: 0, False: 158k]
  ------------------
 1307|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  240|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1308|       |
 1309|       |            /* Check the whole words */
 1310|   158k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1310:25): [True: 0, False: 158k]
  ------------------
 1311|      0|            {
 1312|      0|                if (fields_seen.bitfield[i] != allbits)
  ------------------
  |  Branch (1312:21): [True: 0, False: 0]
  ------------------
 1313|      0|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1314|      0|            }
 1315|       |
 1316|       |            /* Check the remaining bits (if any) */
 1317|   158k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1317:17): [True: 158k, False: 0]
  ------------------
 1318|   158k|            {
 1319|   158k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1319:21): [True: 337, False: 157k]
  ------------------
 1320|   158k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1321|    337|                {
 1322|    337|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  937|    337|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|    337|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 337]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1323|    337|                }
 1324|   158k|            }
 1325|   158k|        }
 1326|   305k|    }
 1327|       |
 1328|   304k|    return true;
 1329|   305k|}
pb_decode.c:pb_message_set_to_defaults:
 1092|   112k|{
 1093|   112k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   71|   112k|#  define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
 1094|   112k|    uint32_t tag = 0;
 1095|   112k|    pb_wire_type_t wire_type = PB_WT_VARINT;
 1096|   112k|    bool eof;
 1097|       |
 1098|   112k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (1098:9): [True: 106k, False: 5.85k]
  ------------------
 1099|   106k|    {
 1100|   106k|        defstream = pb_istream_from_buffer(iter->descriptor->default_value, (size_t)-1);
 1101|   106k|        if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1101:13): [True: 0, False: 106k]
  ------------------
 1102|      0|            return false;
 1103|   106k|    }
 1104|       |
 1105|   112k|    do
 1106|   982k|    {
 1107|   982k|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (1107:13): [True: 0, False: 982k]
  ------------------
 1108|      0|            return false;
 1109|       |
 1110|   982k|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (1110:13): [True: 882k, False: 99.5k]
  |  Branch (1110:25): [True: 492k, False: 390k]
  ------------------
 1111|   492k|        {
 1112|       |            /* We have a default value for this field in the defstream */
 1113|   492k|            if (!decode_field(&defstream, wire_type, iter))
  ------------------
  |  Branch (1113:17): [True: 0, False: 492k]
  ------------------
 1114|      0|                return false;
 1115|   492k|            if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1115:17): [True: 0, False: 492k]
  ------------------
 1116|      0|                return false;
 1117|       |
 1118|   492k|            if (iter->pSize)
  ------------------
  |  Branch (1118:17): [True: 239k, False: 252k]
  ------------------
 1119|   239k|                *(bool*)iter->pSize = false;
 1120|   492k|        }
 1121|   982k|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (1121:14): [True: 869k, False: 112k]
  ------------------
 1122|       |
 1123|   112k|    return true;
 1124|   112k|}
pb_decode.c:pb_field_set_to_default:
  988|   982k|{
  989|   982k|    pb_type_t type;
  990|   982k|    type = field->type;
  991|       |
  992|   982k|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  335|   982k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   982k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  304|   982k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (992:9): [True: 8.52k, False: 973k]
  ------------------
  993|  8.52k|    {
  994|  8.52k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  995|  14.3k|        while (ext != NULL)
  ------------------
  |  Branch (995:16): [True: 5.85k, False: 8.52k]
  ------------------
  996|  5.85k|        {
  997|  5.85k|            pb_field_iter_t ext_iter;
  998|  5.85k|            if (ext->type->decode != NULL)
  ------------------
  |  Branch (998:17): [True: 0, False: 5.85k]
  ------------------
  999|      0|                ext->found = false; /* Custom type: arg is not a message descriptor */
 1000|  5.85k|            else if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (1000:22): [True: 5.85k, False: 0]
  ------------------
 1001|  5.85k|            {
 1002|  5.85k|                ext->found = false;
 1003|  5.85k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (1003:21): [True: 0, False: 5.85k]
  ------------------
 1004|      0|                    return false;
 1005|  5.85k|            }
 1006|  5.85k|            ext = ext->next;
 1007|  5.85k|        }
 1008|  8.52k|    }
 1009|   973k|    else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  333|   973k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   973k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  328|   973k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1009:14): [True: 900k, False: 73.2k]
  ------------------
 1010|   900k|    {
 1011|   900k|        bool init_data = true;
 1012|   900k|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  334|   900k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   900k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  319|  1.80M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (1012:13): [True: 256k, False: 644k]
  |  Branch (1012:52): [True: 256k, False: 0]
  ------------------
 1013|   256k|        {
 1014|       |            /* Set has_field to false. Still initialize the optional field
 1015|       |             * itself also. */
 1016|   256k|            *(bool*)field->pSize = false;
 1017|   256k|        }
 1018|   644k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  334|   644k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   644k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  321|  1.28M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1018:18): [True: 150k, False: 493k]
  ------------------
 1019|   150k|                 field->pSize == &field->array_size &&
  ------------------
  |  Branch (1019:18): [True: 14.3k, False: 136k]
  ------------------
 1020|  14.3k|                 PB_LTYPE_IS_SUBMSG(type))
  ------------------
  |  |  336|  14.3k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|  14.3k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  14.3k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|  28.7k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 0, False: 14.3k]
  |  |  ------------------
  |  |  337|  14.3k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|  14.3k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  14.3k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|  14.3k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 0, False: 14.3k]
  |  |  ------------------
  ------------------
 1021|      0|        {
 1022|       |            /* Fixed count array: there is no count field, so pb_release()
 1023|       |             * walks all array_size entries even if they were not decoded.
 1024|       |             * Initialize all submessages so that their pointers are valid. */
 1025|      0|            pb_size_t i;
 1026|      0|            for (i = 0; i < field->array_size; i++)
  ------------------
  |  Branch (1026:25): [True: 0, False: 0]
  ------------------
 1027|      0|            {
 1028|      0|                pb_field_iter_t submsg_iter;
 1029|      0|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc,
  ------------------
  |  Branch (1029:21): [True: 0, False: 0]
  ------------------
 1030|      0|                                        (char*)field->pData + field->data_size * i))
 1031|      0|                {
 1032|      0|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (1032:25): [True: 0, False: 0]
  ------------------
 1033|      0|                        return false;
 1034|      0|                }
 1035|      0|            }
 1036|      0|            init_data = false;
 1037|      0|        }
 1038|   644k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  334|   644k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   644k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  321|  1.28M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1038:18): [True: 150k, False: 493k]
  ------------------
 1039|   493k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  334|   493k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   493k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  323|   493k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (1039:18): [True: 42.6k, False: 450k]
  ------------------
 1040|   193k|        {
 1041|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
 1042|       |               ONEOF: Set which_field to 0. */
 1043|   193k|            *(pb_size_t*)field->pSize = 0;
 1044|   193k|            init_data = false;
 1045|   193k|        }
 1046|       |
 1047|   900k|        if (init_data)
  ------------------
  |  Branch (1047:13): [True: 706k, False: 193k]
  ------------------
 1048|   706k|        {
 1049|   706k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  336|  1.41M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|   706k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|   706k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|  1.41M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 65.5k, False: 641k]
  |  |  ------------------
  |  |  337|  1.41M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|   641k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|   641k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|   641k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 0, False: 641k]
  |  |  ------------------
  ------------------
 1050|  65.5k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (1050:18): [True: 25.5k, False: 39.9k]
  ------------------
 1051|  39.9k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (1051:18): [True: 0, False: 39.9k]
  ------------------
 1052|  39.9k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (1052:18): [True: 0, False: 39.9k]
  ------------------
 1053|  25.5k|            {
 1054|       |                /* Initialize submessage to defaults.
 1055|       |                 * Only needed if it has default values
 1056|       |                 * or callback/submessage fields. */
 1057|  25.5k|                pb_field_iter_t submsg_iter;
 1058|  25.5k|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (1058:21): [True: 25.5k, False: 0]
  ------------------
 1059|  25.5k|                {
 1060|  25.5k|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (1060:25): [True: 0, False: 25.5k]
  ------------------
 1061|      0|                        return false;
 1062|  25.5k|                }
 1063|  25.5k|            }
 1064|   681k|            else
 1065|   681k|            {
 1066|       |                /* Initialize to zeros */
 1067|   681k|                memset(field->pData, 0, (size_t)field->data_size);
 1068|   681k|            }
 1069|   706k|        }
 1070|   900k|    }
 1071|  73.2k|    else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  333|  73.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  73.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  329|  73.2k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1071:14): [True: 0, False: 73.2k]
  ------------------
 1072|      0|    {
 1073|       |        /* Initialize the pointer to NULL. */
 1074|      0|        *(void**)field->pField = NULL;
 1075|       |
 1076|       |        /* Initialize array count to 0. */
 1077|      0|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  334|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  321|      0|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1077:13): [True: 0, False: 0]
  ------------------
 1078|      0|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  334|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  323|      0|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (1078:13): [True: 0, False: 0]
  ------------------
 1079|      0|        {
 1080|      0|            *(pb_size_t*)field->pSize = 0;
 1081|      0|        }
 1082|      0|    }
 1083|  73.2k|    else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  333|  73.2k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  73.2k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  330|  73.2k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1083:14): [True: 73.2k, False: 0]
  ------------------
 1084|  73.2k|    {
 1085|       |        /* Don't overwrite callback */
 1086|  73.2k|    }
 1087|       |
 1088|   982k|    return true;
 1089|   982k|}
pb_decode.c:decode_next_tag:
 1132|  7.99M|{
 1133|       |    /* Length-delimited messages must consume their full advertised size. */
 1134|  7.99M|    bool delimited_not_done = (flags & PB_DECODE_DELIMITED) != 0 && stream->bytes_left > 0;
  ------------------
  |  |  123|  7.99M|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1134:31): [True: 1.55M, False: 6.43M]
  |  Branch (1134:69): [True: 1.25M, False: 298k]
  ------------------
 1135|       |
 1136|  7.99M|    if (pb_decode_tag(stream, wire_type, tag, eof))
  ------------------
  |  Branch (1136:9): [True: 7.68M, False: 305k]
  ------------------
 1137|  7.68M|        return true;
 1138|       |
 1139|   305k|    if (*eof && delimited_not_done)
  ------------------
  |  Branch (1139:9): [True: 305k, False: 113]
  |  Branch (1139:17): [True: 0, False: 305k]
  ------------------
 1140|      0|    {
 1141|      0|        *eof = false;
 1142|      0|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1143|      0|    }
 1144|       |
 1145|   305k|    return false;
 1146|   305k|}
pb_decode.c:decode_extension:
  966|   131k|{
  967|   131k|    size_t pos = stream->bytes_left;
  968|       |    
  969|   261k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (969:12): [True: 131k, False: 130k]
  |  Branch (969:33): [True: 131k, False: 0]
  ------------------
  970|   131k|    {
  971|   131k|        bool status;
  972|   131k|        if (extension->type->decode)
  ------------------
  |  Branch (972:13): [True: 0, False: 131k]
  ------------------
  973|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  974|   131k|        else
  975|   131k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  976|       |
  977|   131k|        if (!status)
  ------------------
  |  Branch (977:13): [True: 29, False: 130k]
  ------------------
  978|     29|            return false;
  979|       |        
  980|   130k|        extension = extension->next;
  981|   130k|    }
  982|       |    
  983|   130k|    return true;
  984|   131k|}
pb_decode.c:default_extension_decoder:
  949|   131k|{
  950|   131k|    pb_field_iter_t iter;
  951|       |
  952|   131k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (952:9): [True: 0, False: 131k]
  ------------------
  953|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  954|       |
  955|   131k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (955:9): [True: 125k, False: 5.34k]
  |  Branch (955:28): [True: 0, False: 5.34k]
  ------------------
  956|   125k|        return true;
  957|       |
  958|  5.34k|    extension->found = true;
  959|  5.34k|    return decode_field(stream, wire_type, &iter);
  960|   131k|}
pb_decode.c:decode_field:
  917|  7.18M|{
  918|       |#ifdef PB_ENABLE_MALLOC
  919|       |    /* When decoding an oneof field, check if there is old data that must be
  920|       |     * released first. */
  921|       |    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  922|       |    {
  923|       |        if (!pb_release_union_field(stream, field))
  924|       |            return false;
  925|       |    }
  926|       |#endif
  927|       |
  928|  7.18M|    switch (PB_ATYPE(field->type))
  ------------------
  |  |  333|  7.18M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  7.18M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
  929|  7.18M|    {
  930|  7.10M|        case PB_ATYPE_STATIC:
  ------------------
  |  |  328|  7.10M|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (930:9): [True: 7.10M, False: 84.6k]
  ------------------
  931|  7.10M|            return decode_static_field(stream, wire_type, field);
  932|       |        
  933|      0|        case PB_ATYPE_POINTER:
  ------------------
  |  |  329|      0|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (933:9): [True: 0, False: 7.18M]
  ------------------
  934|      0|            return decode_pointer_field(stream, wire_type, field);
  935|       |        
  936|  84.6k|        case PB_ATYPE_CALLBACK:
  ------------------
  |  |  330|  84.6k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (936:9): [True: 84.6k, False: 7.10M]
  ------------------
  937|  84.6k|            return decode_callback_field(stream, wire_type, field);
  938|       |        
  939|      0|        default:
  ------------------
  |  Branch (939:9): [True: 0, False: 7.18M]
  ------------------
  940|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  941|  7.18M|    }
  942|  7.18M|}
pb_decode.c:decode_static_field:
  503|  7.10M|{
  504|  7.10M|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  334|  7.10M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  7.10M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  505|  7.10M|    {
  506|  6.34M|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  318|  6.34M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (506:9): [True: 6.34M, False: 760k]
  ------------------
  507|  6.34M|            return decode_basic_field(stream, wire_type, field);
  508|       |            
  509|   519k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  319|   519k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (509:9): [True: 519k, False: 6.58M]
  ------------------
  510|   519k|            if (field->pSize != NULL)
  ------------------
  |  Branch (510:17): [True: 519k, False: 0]
  ------------------
  511|   519k|                *(bool*)field->pSize = true;
  512|   519k|            return decode_basic_field(stream, wire_type, field);
  513|       |    
  514|  31.2k|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  321|  31.2k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (514:9): [True: 31.2k, False: 7.07M]
  ------------------
  515|  31.2k|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (515:17): [True: 23.5k, False: 7.69k]
  ------------------
  516|  23.5k|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  335|  23.5k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  23.5k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  283|  23.5k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (516:20): [True: 11.0k, False: 12.4k]
  ------------------
  517|  11.0k|            {
  518|       |                /* Packed array */
  519|  11.0k|                bool status = true;
  520|  11.0k|                pb_istream_t substream;
  521|  11.0k|                pb_size_t *size = (pb_size_t*)field->pSize;
  522|  11.0k|                field->pData = (char*)field->pField + field->data_size * (*size);
  523|       |
  524|  11.0k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (524:21): [True: 61, False: 11.0k]
  ------------------
  525|     61|                    return false;
  526|       |
  527|  46.5k|                while (substream.bytes_left > 0 && *size < field->array_size)
  ------------------
  |  Branch (527:24): [True: 35.5k, False: 10.9k]
  |  Branch (527:52): [True: 35.5k, False: 17]
  ------------------
  528|  35.5k|                {
  529|  35.5k|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (529:25): [True: 29, False: 35.5k]
  ------------------
  530|     29|                    {
  531|     29|                        status = false;
  532|     29|                        break;
  533|     29|                    }
  534|  35.5k|                    (*size)++;
  535|  35.5k|                    field->pData = (char*)field->pData + field->data_size;
  536|  35.5k|                }
  537|       |
  538|  11.0k|                if (substream.bytes_left != 0)
  ------------------
  |  Branch (538:21): [True: 38, False: 10.9k]
  ------------------
  539|     38|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  937|     38|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     38|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 38]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  540|  10.9k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (540:21): [True: 0, False: 10.9k]
  ------------------
  541|      0|                    return false;
  542|       |
  543|  10.9k|                return status;
  544|  10.9k|            }
  545|  20.1k|            else
  546|  20.1k|            {
  547|       |                /* Repeated field */
  548|  20.1k|                pb_size_t *size = (pb_size_t*)field->pSize;
  549|  20.1k|                field->pData = (char*)field->pField + field->data_size * (*size);
  550|       |
  551|  20.1k|                if ((*size)++ >= field->array_size)
  ------------------
  |  Branch (551:21): [True: 2, False: 20.1k]
  ------------------
  552|      2|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  937|      2|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      2|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  553|       |
  554|  20.1k|                if (PB_LTYPE_IS_SUBMSG(field->type))
  ------------------
  |  |  336|  20.1k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|  20.1k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  20.1k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|  40.2k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 5.52k, False: 14.5k]
  |  |  ------------------
  |  |  337|  20.1k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|  14.5k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  14.5k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|  14.5k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 0, False: 14.5k]
  |  |  ------------------
  ------------------
  555|  5.52k|                {
  556|       |                    /* The entry is now counted, so pb_release() will walk it
  557|       |                     * even if decoding fails before pb_dec_submessage().
  558|       |                     * Set defaults here so that its pointers are valid. */
  559|  5.52k|                    pb_field_iter_t submsg_iter;
  560|  5.52k|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (560:25): [True: 4.12k, False: 1.40k]
  ------------------
  561|  4.12k|                    {
  562|  4.12k|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (562:29): [True: 0, False: 4.12k]
  ------------------
  563|      0|                            PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  564|  4.12k|                    }
  565|  5.52k|                }
  566|       |
  567|  20.1k|                return decode_basic_field(stream, wire_type, field);
  568|  20.1k|            }
  569|       |
  570|   208k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  323|   208k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (570:9): [True: 208k, False: 6.89M]
  ------------------
  571|   208k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  336|   417k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|   208k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|   208k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|   417k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 160k, False: 48.4k]
  |  |  ------------------
  |  |  337|   417k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|  48.4k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|  48.4k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|  48.4k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 48.0k, False: 442]
  |  |  ------------------
  ------------------
  572|   208k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (572:17): [True: 118k, False: 89.8k]
  ------------------
  573|   118k|            {
  574|       |                /* We memset to zero so that any callbacks are set to NULL.
  575|       |                 * This is because the callbacks might otherwise have values
  576|       |                 * from some other union field.
  577|       |                 * If callbacks are needed inside oneof field, use .proto
  578|       |                 * option submsg_callback to have a separate callback function
  579|       |                 * that can set the fields before submessage is decoded.
  580|       |                 * pb_dec_submessage() will set any default values. */
  581|   118k|                memset(field->pData, 0, (size_t)field->data_size);
  582|       |
  583|       |                /* Set default values for the submessage fields. */
  584|   118k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (584:21): [True: 68.5k, False: 49.9k]
  ------------------
  585|  49.9k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (585:21): [True: 0, False: 49.9k]
  ------------------
  586|  49.9k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (586:21): [True: 0, False: 49.9k]
  ------------------
  587|  68.5k|                {
  588|  68.5k|                    pb_field_iter_t submsg_iter;
  589|  68.5k|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (589:25): [True: 68.5k, False: 0]
  ------------------
  590|  68.5k|                    {
  591|  68.5k|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (591:29): [True: 0, False: 68.5k]
  ------------------
  592|      0|                            PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  593|  68.5k|                    }
  594|  68.5k|                }
  595|   118k|            }
  596|   208k|            *(pb_size_t*)field->pSize = field->tag;
  597|       |
  598|   208k|            return decode_basic_field(stream, wire_type, field);
  599|       |
  600|      0|        default:
  ------------------
  |  Branch (600:9): [True: 0, False: 7.10M]
  ------------------
  601|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  602|  7.10M|    }
  603|  7.10M|}
pb_decode.c:decode_basic_field:
  432|  7.12M|{
  433|  7.12M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  335|  7.12M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  7.12M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  434|  7.12M|    {
  435|   354k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  275|   354k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (435:9): [True: 354k, False: 6.77M]
  ------------------
  436|   354k|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (436:17): [True: 1.38k, False: 353k]
  |  Branch (436:46): [True: 12, False: 1.37k]
  ------------------
  437|     12|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  937|     12|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     12|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  438|       |
  439|   354k|            return pb_dec_bool(stream, field);
  440|       |
  441|  5.02M|        case PB_LTYPE_VARINT:
  ------------------
  |  |  276|  5.02M|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (441:9): [True: 5.02M, False: 2.10M]
  ------------------
  442|  5.40M|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  277|  5.40M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (442:9): [True: 378k, False: 6.74M]
  ------------------
  443|  5.57M|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  278|  5.57M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (443:9): [True: 175k, False: 6.95M]
  ------------------
  444|  5.57M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (444:17): [True: 24.0k, False: 5.55M]
  |  Branch (444:46): [True: 49, False: 24.0k]
  ------------------
  445|     49|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  937|     49|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     49|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 49]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  446|       |
  447|  5.57M|            return pb_dec_varint(stream, field);
  448|       |
  449|   306k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  279|   306k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (449:9): [True: 306k, False: 6.81M]
  ------------------
  450|   306k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (450:17): [True: 5.98k, False: 300k]
  |  Branch (450:45): [True: 16, False: 5.97k]
  ------------------
  451|     16|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  937|     16|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     16|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  452|       |
  453|   306k|            return pb_decode_fixed32(stream, field->pData);
  454|       |
  455|   256k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  280|   256k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (455:9): [True: 256k, False: 6.87M]
  ------------------
  456|   256k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (456:17): [True: 4.18k, False: 252k]
  |  Branch (456:45): [True: 6, False: 4.17k]
  ------------------
  457|      6|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  937|      6|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      6|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  458|       |
  459|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  460|       |            if (field->data_size == sizeof(float))
  461|       |            {
  462|       |                return pb_decode_double_as_float(stream, (float*)field->pData);
  463|       |            }
  464|       |#endif
  465|       |
  466|       |#ifdef PB_WITHOUT_64BIT
  467|       |            PB_RETURN_ERROR(stream, "invalid data_size");
  468|       |#else
  469|   256k|            return pb_decode_fixed64(stream, field->pData);
  470|      0|#endif
  471|       |
  472|  51.7k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  287|  51.7k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (472:9): [True: 51.7k, False: 7.07M]
  ------------------
  473|  51.7k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (473:17): [True: 17, False: 51.7k]
  ------------------
  474|     17|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  937|     17|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     17|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  475|       |
  476|  51.7k|            return pb_dec_bytes(stream, field);
  477|       |
  478|   222k|        case PB_LTYPE_STRING:
  ------------------
  |  |  291|   222k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (478:9): [True: 222k, False: 6.90M]
  ------------------
  479|   222k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (479:17): [True: 8, False: 222k]
  ------------------
  480|      8|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  937|      8|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      8|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  481|       |
  482|   222k|            return pb_dec_string(stream, field);
  483|       |
  484|   277k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  295|   277k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (484:9): [True: 277k, False: 6.84M]
  ------------------
  485|   325k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  300|   325k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (485:9): [True: 48.0k, False: 7.07M]
  ------------------
  486|   325k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (486:17): [True: 18, False: 325k]
  ------------------
  487|     18|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  937|     18|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     18|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  488|       |
  489|   325k|            return pb_dec_submessage(stream, field);
  490|       |
  491|  30.7k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  310|  30.7k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (491:9): [True: 30.7k, False: 7.09M]
  ------------------
  492|  30.7k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (492:17): [True: 4, False: 30.7k]
  ------------------
  493|      4|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  937|      4|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      4|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  494|       |
  495|  30.7k|            return pb_dec_fixed_length_bytes(stream, field);
  496|       |
  497|      0|        default:
  ------------------
  |  Branch (497:9): [True: 0, False: 7.12M]
  ------------------
  498|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  499|  7.12M|    }
  500|  7.12M|}
pb_decode.c:pb_dec_bool:
 1595|   354k|{
 1596|   354k|    return pb_decode_bool(stream, (bool*)field->pData);
 1597|   354k|}
pb_decode.c:pb_dec_varint:
 1600|  5.57M|{
 1601|  5.57M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  335|  5.57M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  5.57M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  277|  5.57M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1601:9): [True: 378k, False: 5.19M]
  ------------------
 1602|   378k|    {
 1603|   378k|        pb_uint64_t value, clamped;
  ------------------
  |  |   58|   378k|#define pb_uint64_t uint64_t
  ------------------
 1604|   378k|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1604:13): [True: 15, False: 378k]
  ------------------
 1605|     15|            return false;
 1606|       |
 1607|       |        /* Cast to the proper field size, while checking for overflows */
 1608|   378k|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1608:13): [True: 160k, False: 218k]
  ------------------
 1609|   160k|            clamped = *(pb_uint64_t*)field->pData = value;
 1610|   218k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1610:18): [True: 191k, False: 26.8k]
  ------------------
 1611|   191k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1612|  26.8k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1612:18): [True: 13.4k, False: 13.4k]
  ------------------
 1613|  13.4k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1614|  13.4k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1614:18): [True: 13.4k, False: 0]
  ------------------
 1615|  13.4k|            clamped = *(uint_least8_t*)field->pData = (uint_least8_t)value;
 1616|      0|        else
 1617|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1618|       |
 1619|   378k|        if (clamped != value)
  ------------------
  |  Branch (1619:13): [True: 113, False: 378k]
  ------------------
 1620|    113|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  937|    113|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|    113|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 113]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1621|       |
 1622|   378k|        return true;
 1623|   378k|    }
 1624|  5.19M|    else
 1625|  5.19M|    {
 1626|  5.19M|        pb_uint64_t value;
  ------------------
  |  |   58|  5.19M|#define pb_uint64_t uint64_t
  ------------------
 1627|  5.19M|        pb_int64_t svalue;
  ------------------
  |  |   57|  5.19M|#define pb_int64_t int64_t
  ------------------
 1628|  5.19M|        pb_int64_t clamped;
  ------------------
  |  |   57|  5.19M|#define pb_int64_t int64_t
  ------------------
 1629|       |
 1630|  5.19M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  335|  5.19M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  5.19M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  278|  5.19M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1630:13): [True: 175k, False: 5.02M]
  ------------------
 1631|   175k|        {
 1632|   175k|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1632:17): [True: 24, False: 175k]
  ------------------
 1633|     24|                return false;
 1634|   175k|        }
 1635|  5.02M|        else
 1636|  5.02M|        {
 1637|  5.02M|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1637:17): [True: 43, False: 5.02M]
  ------------------
 1638|     43|                return false;
 1639|       |
 1640|       |            /* See issue 97: Google's C++ protobuf allows negative varint values to
 1641|       |            * be cast as int32_t, instead of the int64_t that should be used when
 1642|       |            * encoding. Nanopb versions before 0.2.5 had a bug in encoding. In order to
 1643|       |            * not break decoding of such messages, we cast <=32 bit fields to
 1644|       |            * int32_t first to get the sign correct.
 1645|       |            */
 1646|  5.02M|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1646:17): [True: 164k, False: 4.85M]
  ------------------
 1647|   164k|                svalue = (pb_int64_t)value;
 1648|  4.85M|            else
 1649|  4.85M|                svalue = (int32_t)value;
 1650|  5.02M|        }
 1651|       |
 1652|       |        /* Cast to the proper field size, while checking for overflows */
 1653|  5.19M|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1653:13): [True: 236k, False: 4.96M]
  ------------------
 1654|   236k|            clamped = *(pb_int64_t*)field->pData = svalue;
 1655|  4.96M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1655:18): [True: 4.91M, False: 53.3k]
  ------------------
 1656|  4.91M|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1657|  53.3k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1657:18): [True: 26.6k, False: 26.6k]
  ------------------
 1658|  26.6k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1659|  26.6k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1659:18): [True: 26.6k, False: 0]
  ------------------
 1660|  26.6k|            clamped = *(int_least8_t*)field->pData = (int_least8_t)svalue;
 1661|      0|        else
 1662|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1663|       |
 1664|  5.19M|        if (clamped != svalue)
  ------------------
  |  Branch (1664:13): [True: 88, False: 5.19M]
  ------------------
 1665|     88|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  937|     88|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     88|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 88]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1666|       |
 1667|  5.19M|        return true;
 1668|  5.19M|    }
 1669|  5.57M|}
pb_decode.c:pb_dec_bytes:
 1672|  51.7k|{
 1673|  51.7k|    uint32_t size;
 1674|  51.7k|    size_t alloc_size;
 1675|  51.7k|    pb_bytes_array_t *dest;
 1676|       |    
 1677|  51.7k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1677:9): [True: 2, False: 51.7k]
  ------------------
 1678|      2|        return false;
 1679|       |    
 1680|  51.7k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  349|  51.7k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1680:9): [True: 31, False: 51.7k]
  ------------------
 1681|     31|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  937|     31|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     31|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1682|       |    
 1683|  51.7k|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  418|  51.7k|    (((size_t)(n) + offsetof(pb_bytes_array_t, bytes)) < sizeof(pb_bytes_array_t) \
  |  |  ------------------
  |  |  |  Branch (418:6): [True: 26.0k, False: 25.6k]
  |  |  ------------------
  |  |  419|  51.7k|        ? sizeof(pb_bytes_array_t) \
  |  |  420|  51.7k|        : ((size_t)(n) + offsetof(pb_bytes_array_t, bytes)))
  ------------------
 1684|  51.7k|    if (size > alloc_size)
  ------------------
  |  Branch (1684:9): [True: 0, False: 51.7k]
  ------------------
 1685|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1686|       |    
 1687|  51.7k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  333|  51.7k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  51.7k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  329|  51.7k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1687:9): [True: 0, False: 51.7k]
  ------------------
 1688|      0|    {
 1689|      0|#ifndef PB_ENABLE_MALLOC
 1690|      0|        PB_RETURN_ERROR(stream, "no malloc support");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1691|       |#else
 1692|       |        if (stream->bytes_left < size)
 1693|       |            PB_RETURN_ERROR(stream, "end-of-stream");
 1694|       |
 1695|       |        if (!allocate_field(stream, field->pData, alloc_size, 1))
 1696|       |            return false;
 1697|       |        dest = *(pb_bytes_array_t**)field->pData;
 1698|       |#endif
 1699|      0|    }
 1700|  51.7k|    else
 1701|  51.7k|    {
 1702|  51.7k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1702:13): [True: 59, False: 51.6k]
  ------------------
 1703|     59|            PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  937|     59|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     59|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 59]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1704|  51.6k|        dest = (pb_bytes_array_t*)field->pData;
 1705|  51.6k|    }
 1706|       |
 1707|  51.6k|    dest->size = (pb_size_t)size;
 1708|  51.6k|    return pb_read(stream, dest->bytes, (size_t)size);
 1709|  51.7k|}
pb_decode.c:pb_dec_string:
 1712|   222k|{
 1713|   222k|    uint32_t size;
 1714|   222k|    size_t alloc_size;
 1715|   222k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1716|       |
 1717|   222k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1717:9): [True: 3, False: 222k]
  ------------------
 1718|      3|        return false;
 1719|       |
 1720|   222k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1720:9): [True: 2, False: 222k]
  ------------------
 1721|      2|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  937|      2|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      2|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1722|       |
 1723|       |    /* Space for null terminator */
 1724|   222k|    alloc_size = (size_t)(size + 1);
 1725|       |
 1726|   222k|    if (alloc_size < size)
  ------------------
  |  Branch (1726:9): [True: 0, False: 222k]
  ------------------
 1727|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1728|       |
 1729|   222k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  333|   222k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   222k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  329|   222k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1729:9): [True: 0, False: 222k]
  ------------------
 1730|      0|    {
 1731|      0|#ifndef PB_ENABLE_MALLOC
 1732|      0|        PB_RETURN_ERROR(stream, "no malloc support");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1733|       |#else
 1734|       |        if (stream->bytes_left < size)
 1735|       |            PB_RETURN_ERROR(stream, "end-of-stream");
 1736|       |
 1737|       |        if (!allocate_field(stream, field->pData, alloc_size, 1))
 1738|       |            return false;
 1739|       |        dest = *(pb_byte_t**)field->pData;
 1740|       |#endif
 1741|      0|    }
 1742|   222k|    else
 1743|   222k|    {
 1744|   222k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1744:13): [True: 90, False: 222k]
  ------------------
 1745|     90|            PB_RETURN_ERROR(stream, "string overflow");
  ------------------
  |  |  937|     90|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     90|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 90]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1746|   222k|    }
 1747|       |    
 1748|   222k|    dest[size] = 0;
 1749|       |
 1750|   222k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1750:9): [True: 7, False: 222k]
  ------------------
 1751|      7|        return false;
 1752|       |
 1753|       |#ifdef PB_VALIDATE_UTF8
 1754|       |    if (!pb_validate_utf8((const char*)dest))
 1755|       |        PB_RETURN_ERROR(stream, "invalid utf8");
 1756|       |#endif
 1757|       |
 1758|   222k|    return true;
 1759|   222k|}
pb_decode.c:pb_dec_submessage:
 1762|   325k|{
 1763|   325k|    bool status = true;
 1764|   325k|    bool submsg_consumed = false;
 1765|   325k|    pb_istream_t substream;
 1766|       |
 1767|   325k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1767:9): [True: 96, False: 325k]
  ------------------
 1768|     96|        return false;
 1769|       |    
 1770|   325k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1770:9): [True: 0, False: 325k]
  ------------------
 1771|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1772|       |    
 1773|       |    /* Submessages can have a separate message-level callback that is called
 1774|       |     * before decoding the message. Typically it is used to set callback fields
 1775|       |     * inside oneofs. Required fields have no callback slot. Extension fields
 1776|       |     * are always required, and for them pSize points to extension->found. */
 1777|   325k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL &&
  ------------------
  |  |  335|   325k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   325k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL &&
  ------------------
  |  |  300|   651k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1777:9): [True: 48.0k, False: 277k]
  |  Branch (1777:58): [True: 48.0k, False: 0]
  ------------------
 1778|  48.0k|        PB_HTYPE(field->type) != PB_HTYPE_REQUIRED)
  ------------------
  |  |  334|  48.0k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  48.0k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      PB_HTYPE(field->type) != PB_HTYPE_REQUIRED)
  ------------------
  |  |  318|  48.0k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1778:9): [True: 48.0k, False: 0]
  ------------------
 1779|  48.0k|    {
 1780|       |        /* Message callback is stored right before pSize. */
 1781|  48.0k|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
 1782|  48.0k|        if (callback->funcs.decode)
  ------------------
  |  Branch (1782:13): [True: 48.0k, False: 0]
  ------------------
 1783|  48.0k|        {
 1784|  48.0k|            status = callback->funcs.decode(&substream, field, &callback->arg);
 1785|       |
 1786|  48.0k|            if (substream.bytes_left == 0)
  ------------------
  |  Branch (1786:17): [True: 27.1k, False: 20.8k]
  ------------------
 1787|  27.1k|            {
 1788|  27.1k|                submsg_consumed = true;
 1789|  27.1k|            }
 1790|  48.0k|        }
 1791|  48.0k|    }
 1792|       |
 1793|       |    /* Now decode the submessage contents */
 1794|   325k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1794:9): [True: 325k, False: 0]
  |  Branch (1794:19): [True: 298k, False: 27.1k]
  ------------------
 1795|   298k|    {
 1796|   298k|        unsigned int flags = PB_DECODE_DELIMITED;
  ------------------
  |  |  123|   298k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
 1797|       |
 1798|       |        /* Static required/optional fields are already initialized by top-level
 1799|       |         * pb_decode() and repeated/oneof fields by decode_static_field(), no
 1800|       |         * need to initialize them again. Single pointer submessages are
 1801|       |         * initialized by decode_pointer_field() when they are allocated, and
 1802|       |         * must not be cleared when the field occurs again and is merged. */
 1803|   298k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  333|   298k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   298k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  328|   596k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1803:13): [True: 298k, False: 0]
  ------------------
 1804|      0|            (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  333|      0|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|      0|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  329|      0|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1804:14): [True: 0, False: 0]
  ------------------
 1805|      0|             PB_HTYPE(field->type) != PB_HTYPE_REPEATED))
  ------------------
  |  |  334|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                           PB_HTYPE(field->type) != PB_HTYPE_REPEATED))
  ------------------
  |  |  321|      0|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1805:14): [True: 0, False: 0]
  ------------------
 1806|   298k|        {
 1807|   298k|            flags |= PB_DECODE_NOINIT;
  ------------------
  |  |  122|   298k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1808|   298k|        }
 1809|       |
 1810|   298k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1811|   298k|    }
 1812|       |    
 1813|   325k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1813:9): [True: 0, False: 325k]
  ------------------
 1814|      0|        return false;
 1815|       |
 1816|   325k|    return status;
 1817|   325k|}
pb_decode.c:pb_dec_fixed_length_bytes:
 1820|  30.7k|{
 1821|  30.7k|    uint32_t size;
 1822|       |
 1823|  30.7k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1823:9): [True: 3, False: 30.7k]
  ------------------
 1824|      3|        return false;
 1825|       |
 1826|  30.7k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  349|  30.7k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1826:9): [True: 30, False: 30.7k]
  ------------------
 1827|     30|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  937|     30|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     30|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 30]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1828|       |
 1829|  30.7k|    if (size == 0)
  ------------------
  |  Branch (1829:9): [True: 18.5k, False: 12.1k]
  ------------------
 1830|  18.5k|    {
 1831|       |        /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */
 1832|  18.5k|        memset(field->pData, 0, (size_t)field->data_size);
 1833|  18.5k|        return true;
 1834|  18.5k|    }
 1835|       |
 1836|  12.1k|    if (size != field->data_size)
  ------------------
  |  Branch (1836:9): [True: 44, False: 12.1k]
  ------------------
 1837|     44|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  937|     44|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|     44|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 44]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1838|       |
 1839|  12.1k|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1840|  12.1k|}
pb_decode.c:decode_callback_field:
  837|  84.6k|{
  838|       |    /* Clear any data that may have been decoded for another oneof field
  839|       |     * that has come before this callback field.
  840|       |     */
  841|  84.6k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  334|  84.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|  84.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  323|  84.6k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (841:9): [True: 11.0k, False: 73.6k]
  ------------------
  842|  11.0k|    {
  843|  11.0k|        bool clear_data = (*(pb_size_t*)field->pSize != field->tag);
  844|       |
  845|       |#ifdef PB_ENABLE_UNSAFE_DECODE_ONEOF_CALLBACKS
  846|       |        if (*(pb_size_t*)field->pSize == 0) clear_data = false;
  847|       |#endif
  848|       |
  849|  11.0k|        if (clear_data)
  ------------------
  |  Branch (849:13): [True: 2.50k, False: 8.51k]
  ------------------
  850|  2.50k|        {
  851|  2.50k|            memset(field->pData, 0, (size_t)field->data_size);
  852|  2.50k|        }
  853|  11.0k|        *(pb_size_t*)field->pSize = field->tag;
  854|  11.0k|    }
  855|       |
  856|  84.6k|    if (!field->descriptor->field_callback)
  ------------------
  |  Branch (856:9): [True: 0, False: 84.6k]
  ------------------
  857|      0|        return pb_skip_field(stream, wire_type);
  858|       |
  859|  84.6k|    if (wire_type == PB_WT_STRING)
  ------------------
  |  Branch (859:9): [True: 68.8k, False: 15.7k]
  ------------------
  860|  68.8k|    {
  861|  68.8k|        pb_istream_t substream;
  862|  68.8k|        size_t prev_bytes_left;
  863|       |        
  864|  68.8k|        if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (864:13): [True: 40, False: 68.8k]
  ------------------
  865|     40|            return false;
  866|       |
  867|       |        /* If the callback field is inside a submsg, first call the submsg_callback which
  868|       |         * should set the decoder for the callback field. */
  869|  68.8k|        if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  335|  68.8k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  68.8k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL) {
  ------------------
  |  |  300|   137k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (869:13): [True: 0, False: 68.8k]
  |  Branch (869:62): [True: 0, False: 0]
  ------------------
  870|      0|            pb_callback_t* callback;
  871|      0|            *(pb_size_t*)field->pSize = field->tag;
  872|      0|            callback = (pb_callback_t*)field->pSize - 1;
  873|       |
  874|      0|            if (callback->funcs.decode)
  ------------------
  |  Branch (874:17): [True: 0, False: 0]
  ------------------
  875|      0|            {
  876|      0|                if (!callback->funcs.decode(&substream, field, &callback->arg)) {
  ------------------
  |  Branch (876:21): [True: 0, False: 0]
  ------------------
  877|      0|                    PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "submsg callback failed");
  ------------------
  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  Branch (933:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  878|      0|                    return false;
  879|      0|                }
  880|      0|            }
  881|      0|        }
  882|       |        
  883|  68.8k|        do
  884|  68.8k|        {
  885|  68.8k|            prev_bytes_left = substream.bytes_left;
  886|  68.8k|            if (!field->descriptor->field_callback(&substream, NULL, field))
  ------------------
  |  Branch (886:17): [True: 0, False: 68.8k]
  ------------------
  887|      0|            {
  888|      0|                PB_SET_ERROR(stream, substream.errmsg ? substream.errmsg : "callback failed");
  ------------------
  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  ------------------
  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  Branch (933:92): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  889|      0|                return false;
  890|      0|            }
  891|  68.8k|        } while (substream.bytes_left > 0 && substream.bytes_left < prev_bytes_left);
  ------------------
  |  Branch (891:18): [True: 26.5k, False: 42.2k]
  |  Branch (891:46): [True: 0, False: 26.5k]
  ------------------
  892|       |        
  893|  68.8k|        if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (893:13): [True: 0, False: 68.8k]
  ------------------
  894|      0|            return false;
  895|       |
  896|  68.8k|        return true;
  897|  68.8k|    }
  898|  15.7k|    else
  899|  15.7k|    {
  900|       |        /* Copy the single scalar value to stack.
  901|       |         * This is required so that we can limit the stream length,
  902|       |         * which in turn allows to use same callback for packed and
  903|       |         * not-packed fields. */
  904|  15.7k|        pb_istream_t substream;
  905|  15.7k|        pb_byte_t buffer[10];
  906|  15.7k|        size_t size = sizeof(buffer);
  907|       |        
  908|  15.7k|        if (!read_raw_value(stream, wire_type, buffer, &size))
  ------------------
  |  Branch (908:13): [True: 34, False: 15.7k]
  ------------------
  909|     34|            return false;
  910|  15.7k|        substream = pb_istream_from_buffer(buffer, size);
  911|       |        
  912|       |        return field->descriptor->field_callback(&substream, NULL, field);
  913|  15.7k|    }
  914|  84.6k|}
pb_decode.c:read_raw_value:
  347|  15.7k|{
  348|  15.7k|    size_t max_size = *size;
  349|  15.7k|    switch (wire_type)
  350|  15.7k|    {
  351|  10.6k|        case PB_WT_VARINT:
  ------------------
  |  Branch (351:9): [True: 10.6k, False: 5.16k]
  ------------------
  352|  10.6k|            *size = 0;
  353|  10.6k|            do
  354|  23.1k|            {
  355|  23.1k|                (*size)++;
  356|  23.1k|                if (*size > max_size)
  ------------------
  |  Branch (356:21): [True: 5, False: 23.1k]
  ------------------
  357|      5|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  937|      5|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      5|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  358|       |
  359|  23.1k|                if (!pb_read(stream, buf, 1))
  ------------------
  |  Branch (359:21): [True: 17, False: 23.1k]
  ------------------
  360|     17|                    return false;
  361|  23.1k|            } while (*buf++ & 0x80);
  ------------------
  |  Branch (361:22): [True: 12.5k, False: 10.6k]
  ------------------
  362|  10.6k|            return true;
  363|       |            
  364|  3.91k|        case PB_WT_64BIT:
  ------------------
  |  Branch (364:9): [True: 3.91k, False: 11.8k]
  ------------------
  365|  3.91k|            *size = 8;
  366|  3.91k|            return pb_read(stream, buf, 8);
  367|       |        
  368|  1.24k|        case PB_WT_32BIT:
  ------------------
  |  Branch (368:9): [True: 1.24k, False: 14.5k]
  ------------------
  369|  1.24k|            *size = 4;
  370|  1.24k|            return pb_read(stream, buf, 4);
  371|       |        
  372|      0|        case PB_WT_STRING:
  ------------------
  |  Branch (372:9): [True: 0, False: 15.7k]
  ------------------
  373|       |            /* Calling read_raw_value with a PB_WT_STRING is an error.
  374|       |             * Explicitly handle this case and fallthrough to default to avoid
  375|       |             * compiler warnings.
  376|       |             */
  377|       |
  378|      0|	case PB_WT_PACKED: 
  ------------------
  |  Branch (378:2): [True: 0, False: 15.7k]
  ------------------
  379|       |            /* Calling read_raw_value with a PB_WT_PACKED is an error.
  380|       |             * Explicitly handle this case and fallthrough to default to avoid
  381|       |             * compiler warnings.
  382|       |             */
  383|       |
  384|      4|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  937|      4|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      4|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (384:9): [True: 4, False: 15.7k]
  ------------------
  385|  15.7k|    }
  386|  15.7k|}

pb_ostream_from_buffer:
   73|  2.66k|{
   74|  2.66k|    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.66k|    stream.callback = &buf_write;
   83|  2.66k|#endif
   84|  2.66k|    stream.state = buf;
   85|  2.66k|    stream.max_size = bufsize;
   86|  2.66k|    stream.bytes_written = 0;
   87|  2.66k|#ifndef PB_NO_ERRMSG
   88|       |    stream.errmsg = NULL;
   89|  2.66k|#endif
   90|  2.66k|    return stream;
   91|  2.66k|}
pb_write:
   94|   498k|{
   95|   498k|    if (count > 0 && stream->callback != NULL)
  ------------------
  |  Branch (95:9): [True: 485k, False: 13.8k]
  |  Branch (95:22): [True: 335k, False: 150k]
  ------------------
   96|   335k|    {
   97|   335k|        if (stream->bytes_written + count < stream->bytes_written ||
  ------------------
  |  Branch (97:13): [True: 0, False: 335k]
  ------------------
   98|   335k|            stream->bytes_written + count > stream->max_size)
  ------------------
  |  Branch (98:13): [True: 0, False: 335k]
  ------------------
   99|      0|        {
  100|      0|            PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933: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|   335k|        if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (107:13): [True: 0, False: 335k]
  ------------------
  108|      0|            PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|   335k|#endif
  110|   335k|    }
  111|       |    
  112|   498k|    stream->bytes_written += count;
  113|       |    return true;
  114|   498k|}
pb_encode:
  522|  42.3k|{
  523|  42.3k|    pb_field_iter_t iter;
  524|  42.3k|    if (!pb_field_iter_begin_const(&iter, fields, src_struct))
  ------------------
  |  Branch (524:9): [True: 7.90k, False: 34.4k]
  ------------------
  525|  7.90k|        return true; /* Empty message type */
  526|       |    
  527|   329k|    do {
  528|   329k|        if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  335|   329k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   329k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  304|   329k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (528:13): [True: 2.66k, False: 327k]
  ------------------
  529|  2.66k|        {
  530|       |            /* Special case for the extension field placeholder */
  531|  2.66k|            if (!encode_extension_field(stream, &iter))
  ------------------
  |  Branch (531:17): [True: 0, False: 2.66k]
  ------------------
  532|      0|                return false;
  533|  2.66k|        }
  534|   327k|        else
  535|   327k|        {
  536|       |            /* Regular field */
  537|   327k|            if (!encode_field(stream, &iter))
  ------------------
  |  Branch (537:17): [True: 0, False: 327k]
  ------------------
  538|      0|                return false;
  539|   327k|        }
  540|   329k|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (540:14): [True: 295k, False: 34.4k]
  ------------------
  541|       |    
  542|  34.4k|    return true;
  543|  34.4k|}
pb_encode_varint:
  617|   444k|{
  618|   444k|    if (value <= 0x7F)
  ------------------
  |  Branch (618:9): [True: 368k, False: 75.5k]
  ------------------
  619|   368k|    {
  620|       |        /* Fast path: single byte */
  621|   368k|        pb_byte_t byte = (pb_byte_t)value;
  622|   368k|        return pb_write(stream, &byte, 1);
  623|   368k|    }
  624|  75.5k|    else
  625|  75.5k|    {
  626|       |#ifdef PB_WITHOUT_64BIT
  627|       |        return pb_encode_varint_32(stream, value, 0);
  628|       |#else
  629|  75.5k|        return pb_encode_varint_32(stream, (uint32_t)value, (uint32_t)(value >> 32));
  630|  75.5k|#endif
  631|  75.5k|    }
  632|   444k|}
pb_encode_svarint:
  635|  22.6k|{
  636|  22.6k|    pb_uint64_t zigzagged;
  ------------------
  |  |   46|  22.6k|#define pb_uint64_t uint64_t
  ------------------
  637|  22.6k|    pb_uint64_t mask = ((pb_uint64_t)-1) >> 1; /* Satisfy clang -fsanitize=integer */
  ------------------
  |  |   46|  22.6k|#define pb_uint64_t uint64_t
  ------------------
  638|  22.6k|    if (value < 0)
  ------------------
  |  Branch (638:9): [True: 9.88k, False: 12.7k]
  ------------------
  639|  9.88k|        zigzagged = ~(((pb_uint64_t)value & mask) << 1);
  640|  12.7k|    else
  641|  12.7k|        zigzagged = (pb_uint64_t)value << 1;
  642|       |    
  643|  22.6k|    return pb_encode_varint(stream, zigzagged);
  644|  22.6k|}
pb_encode_fixed32:
  647|  20.1k|{
  648|  20.1k|#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.1k|    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.1k|}
pb_encode_fixed64:
  664|  11.4k|{
  665|  11.4k|#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.4k|    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.4k|}
pb_encode_tag:
  685|   208k|{
  686|   208k|    pb_uint64_t tag = ((pb_uint64_t)field_number << 3) | wiretype;
  ------------------
  |  |   46|   208k|#define pb_uint64_t uint64_t
  ------------------
  687|   208k|    return pb_encode_varint(stream, tag);
  688|   208k|}
pb_encode_tag_for_field:
  691|   199k|{
  692|   199k|    pb_wire_type_t wiretype;
  693|   199k|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  335|   199k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   199k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  694|   199k|    {
  695|  2.78k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  275|  2.78k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (695:9): [True: 2.78k, False: 196k]
  ------------------
  696|  80.0k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  276|  80.0k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (696:9): [True: 77.2k, False: 122k]
  ------------------
  697|   120k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  277|   120k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (697:9): [True: 40.7k, False: 158k]
  ------------------
  698|   136k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  278|   136k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (698:9): [True: 16.2k, False: 183k]
  ------------------
  699|   136k|            wiretype = PB_WT_VARINT;
  700|   136k|            break;
  701|       |        
  702|  11.0k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  279|  11.0k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (702:9): [True: 11.0k, False: 188k]
  ------------------
  703|  11.0k|            wiretype = PB_WT_32BIT;
  704|  11.0k|            break;
  705|       |        
  706|  8.89k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  280|  8.89k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (706:9): [True: 8.89k, False: 190k]
  ------------------
  707|  8.89k|            wiretype = PB_WT_64BIT;
  708|  8.89k|            break;
  709|       |        
  710|  3.81k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  287|  3.81k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (710:9): [True: 3.81k, False: 195k]
  ------------------
  711|  18.7k|        case PB_LTYPE_STRING:
  ------------------
  |  |  291|  18.7k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (711:9): [True: 14.9k, False: 184k]
  ------------------
  712|  38.5k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  295|  38.5k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (712:9): [True: 19.8k, False: 179k]
  ------------------
  713|  38.5k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  300|  38.5k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (713:9): [True: 0, False: 199k]
  ------------------
  714|  42.7k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  310|  42.7k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (714:9): [True: 4.21k, False: 195k]
  ------------------
  715|  42.7k|            wiretype = PB_WT_STRING;
  716|  42.7k|            break;
  717|       |        
  718|      0|        default:
  ------------------
  |  Branch (718:9): [True: 0, False: 199k]
  ------------------
  719|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  720|   199k|    }
  721|       |    
  722|   199k|    return pb_encode_tag(stream, wiretype, field->tag);
  723|   199k|}
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.8k|{
  735|       |    /* First calculate the message size using a non-writing substream. */
  736|  19.8k|    pb_ostream_t substream = PB_OSTREAM_SIZING;
  ------------------
  |  |  126|  19.8k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  737|  19.8k|#if !defined(PB_NO_ENCODE_SIZE_CHECK) || PB_NO_ENCODE_SIZE_CHECK == 0
  738|  19.8k|    bool status;
  739|  19.8k|    size_t size;
  740|  19.8k|#endif
  741|       |    
  742|  19.8k|    if (!pb_encode(&substream, fields, src_struct))
  ------------------
  |  Branch (742:9): [True: 0, False: 19.8k]
  ------------------
  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.8k|    if (!pb_encode_varint(stream, (pb_uint64_t)substream.bytes_written))
  ------------------
  |  Branch (750:9): [True: 0, False: 19.8k]
  ------------------
  751|      0|        return false;
  752|       |    
  753|  19.8k|    if (stream->callback == NULL)
  ------------------
  |  Branch (753:9): [True: 0, False: 19.8k]
  ------------------
  754|      0|        return pb_write(stream, NULL, substream.bytes_written); /* Just sizing */
  755|       |    
  756|  19.8k|    if (stream->bytes_written + substream.bytes_written > stream->max_size)
  ------------------
  |  Branch (756:9): [True: 0, False: 19.8k]
  ------------------
  757|      0|        PB_RETURN_ERROR(stream, "stream full");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933: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.8k|    size = substream.bytes_written;
  763|       |    /* Use a substream to verify that a callback doesn't write more than
  764|       |     * what it did the first time. */
  765|  19.8k|    substream.callback = stream->callback;
  766|  19.8k|    substream.state = stream->state;
  767|  19.8k|    substream.max_size = size;
  768|  19.8k|    substream.bytes_written = 0;
  769|  19.8k|#ifndef PB_NO_ERRMSG
  770|  19.8k|    substream.errmsg = NULL;
  771|  19.8k|#endif
  772|       |    
  773|  19.8k|    status = pb_encode(&substream, fields, src_struct);
  774|       |    
  775|  19.8k|    stream->bytes_written += substream.bytes_written;
  776|  19.8k|    stream->state = substream.state;
  777|  19.8k|#ifndef PB_NO_ERRMSG
  778|  19.8k|    stream->errmsg = substream.errmsg;
  779|  19.8k|#endif
  780|       |    
  781|  19.8k|    if (substream.bytes_written != size)
  ------------------
  |  Branch (781:9): [True: 0, False: 19.8k]
  ------------------
  782|      0|        PB_RETURN_ERROR(stream, "submsg size changed");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  783|       |
  784|  19.8k|    return status;
  785|  19.8k|#endif
  786|  19.8k|}
pb_encode.c:buf_write:
   54|   335k|{
   55|   335k|    pb_byte_t *dest = (pb_byte_t*)stream->state;
   56|   335k|    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|   335k|    if (buf != NULL)
  ------------------
  |  Branch (64:9): [True: 335k, False: 0]
  ------------------
   65|   335k|    {
   66|   335k|        memcpy(dest, buf, count * sizeof(pb_byte_t));
   67|   335k|    }
   68|       |
   69|       |    return true;
   70|   335k|}
pb_encode.c:encode_extension_field:
  497|  2.66k|{
  498|  2.66k|    const pb_extension_t *extension = *(const pb_extension_t* const *)field->pData;
  499|       |
  500|  5.33k|    while (extension)
  ------------------
  |  Branch (500:12): [True: 2.66k, False: 2.66k]
  ------------------
  501|  2.66k|    {
  502|  2.66k|        bool status;
  503|  2.66k|        if (extension->type->encode)
  ------------------
  |  Branch (503:13): [True: 0, False: 2.66k]
  ------------------
  504|      0|            status = extension->type->encode(stream, extension);
  505|  2.66k|        else
  506|  2.66k|            status = default_extension_encoder(stream, extension);
  507|       |
  508|  2.66k|        if (!status)
  ------------------
  |  Branch (508:13): [True: 0, False: 2.66k]
  ------------------
  509|      0|            return false;
  510|       |        
  511|  2.66k|        extension = extension->next;
  512|  2.66k|    }
  513|       |    
  514|  2.66k|    return true;
  515|  2.66k|}
pb_encode.c:default_extension_encoder:
  484|  2.66k|{
  485|  2.66k|    pb_field_iter_t iter;
  486|       |
  487|  2.66k|    if (!pb_field_iter_begin_extension_const(&iter, extension))
  ------------------
  |  Branch (487:9): [True: 0, False: 2.66k]
  ------------------
  488|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|  2.66k|    return encode_field(stream, &iter);
  491|  2.66k|}
pb_encode.c:encode_field:
  428|   329k|{
  429|       |    /* Check field presence */
  430|   329k|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  334|   329k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   329k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  323|   329k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (430:9): [True: 18.6k, False: 311k]
  ------------------
  431|  18.6k|    {
  432|  18.6k|        if (*(const pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (432:13): [True: 17.8k, False: 840]
  ------------------
  433|  17.8k|        {
  434|       |            /* Different type oneof field */
  435|  17.8k|            return true;
  436|  17.8k|        }
  437|  18.6k|    }
  438|   311k|    else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  334|   311k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   311k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_OPTIONAL)
  ------------------
  |  |  319|   311k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (438:14): [True: 69.0k, False: 241k]
  ------------------
  439|  69.0k|    {
  440|  69.0k|        if (field->pSize)
  ------------------
  |  Branch (440:13): [True: 69.0k, False: 0]
  ------------------
  441|  69.0k|        {
  442|  69.0k|            if (safe_read_bool(field->pSize) == false)
  ------------------
  |  Branch (442:17): [True: 62.1k, False: 6.91k]
  ------------------
  443|  62.1k|            {
  444|       |                /* Missing optional field */
  445|  62.1k|                return true;
  446|  62.1k|            }
  447|  69.0k|        }
  448|      0|        else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  333|      0|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|      0|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      else if (PB_ATYPE(field->type) == PB_ATYPE_STATIC)
  ------------------
  |  |  328|      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|  69.0k|    }
  455|       |
  456|   249k|    if (!field->pData)
  ------------------
  |  Branch (456:9): [True: 0, False: 249k]
  ------------------
  457|      0|    {
  458|      0|        if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  334|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(field->type) == PB_HTYPE_REQUIRED)
  ------------------
  |  |  318|      0|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (458:13): [True: 0, False: 0]
  ------------------
  459|      0|            PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933: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|   249k|    if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  333|   249k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   249k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  330|   249k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (466:9): [True: 120, False: 249k]
  ------------------
  467|    120|    {
  468|    120|        return encode_callback_field(stream, field);
  469|    120|    }
  470|   249k|    else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  334|   249k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   249k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(field->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  321|   249k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (470:14): [True: 55.9k, False: 193k]
  ------------------
  471|  55.9k|    {
  472|  55.9k|        return encode_array(stream, field);
  473|  55.9k|    }
  474|   193k|    else
  475|   193k|    {
  476|   193k|        return encode_basic_field(stream, field);
  477|   193k|    }
  478|   249k|}
pb_encode.c:safe_read_bool:
  125|  71.8k|{
  126|  71.8k|    const char *p = (const char *)pSize;
  127|  71.8k|    size_t i;
  128|   134k|    for (i = 0; i < sizeof(bool); i++)
  ------------------
  |  Branch (128:17): [True: 71.8k, False: 62.9k]
  ------------------
  129|  71.8k|    {
  130|  71.8k|        if (p[i] != 0)
  ------------------
  |  Branch (130:13): [True: 8.92k, False: 62.9k]
  ------------------
  131|  8.92k|            return true;
  132|  71.8k|    }
  133|  62.9k|    return false;
  134|  71.8k|}
pb_encode.c:encode_callback_field:
  417|    120|{
  418|    120|    if (field->descriptor->field_callback != NULL)
  ------------------
  |  Branch (418:9): [True: 120, False: 0]
  ------------------
  419|    120|    {
  420|    120|        if (!field->descriptor->field_callback(NULL, stream, field))
  ------------------
  |  Branch (420:13): [True: 0, False: 120]
  ------------------
  421|      0|            PB_RETURN_ERROR(stream, "callback error");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  422|    120|    }
  423|    120|    return true;
  424|    120|}
pb_encode.c:encode_array:
  138|  55.9k|{
  139|  55.9k|    pb_size_t i;
  140|  55.9k|    pb_size_t count;
  141|  55.9k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  142|  55.9k|    size_t size;
  143|  55.9k|#endif
  144|       |
  145|  55.9k|    count = *(pb_size_t*)field->pSize;
  146|       |
  147|  55.9k|    if (count == 0)
  ------------------
  |  Branch (147:9): [True: 45.6k, False: 10.3k]
  ------------------
  148|  45.6k|        return true;
  149|       |
  150|  10.3k|    if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  333|  10.3k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  10.3k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) != PB_ATYPE_POINTER && count > field->array_size)
  ------------------
  |  |  329|  20.7k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (150:9): [True: 10.3k, False: 0]
  |  Branch (150:54): [True: 0, False: 10.3k]
  ------------------
  151|      0|        PB_RETURN_ERROR(stream, "array max size exceeded");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  152|       |    
  153|  10.3k|#ifndef PB_ENCODE_ARRAYS_UNPACKED
  154|       |    /* We always pack arrays if the datatype allows it. */
  155|  10.3k|    if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  335|  10.3k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  10.3k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  283|  10.3k|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (155:9): [True: 8.77k, False: 1.58k]
  ------------------
  156|  8.77k|    {
  157|  8.77k|        if (!pb_encode_tag(stream, PB_WT_STRING, field->tag))
  ------------------
  |  Branch (157:13): [True: 0, False: 8.77k]
  ------------------
  158|      0|            return false;
  159|       |        
  160|       |        /* Determine the total size of packed array. */
  161|  8.77k|        if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  335|  8.77k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  8.77k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32)
  ------------------
  |  |  279|  8.77k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (161:13): [True: 3.09k, False: 5.67k]
  ------------------
  162|  3.09k|        {
  163|  3.09k|            size = 4 * (size_t)count;
  164|  3.09k|        }
  165|  5.67k|        else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  335|  5.67k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  5.67k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  280|  5.67k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (165:18): [True: 652, False: 5.02k]
  ------------------
  166|    652|        {
  167|    652|            size = 8 * (size_t)count;
  168|    652|        }
  169|  5.02k|        else
  170|  5.02k|        { 
  171|  5.02k|            pb_ostream_t sizestream = PB_OSTREAM_SIZING;
  ------------------
  |  |  126|  5.02k|#define PB_OSTREAM_SIZING {0,0,0,0,0}
  ------------------
  172|  5.02k|            void *pData_orig = field->pData;
  173|  28.7k|            for (i = 0; i < count; i++)
  ------------------
  |  Branch (173:25): [True: 23.6k, False: 5.02k]
  ------------------
  174|  23.6k|            {
  175|  23.6k|                if (!pb_enc_varint(&sizestream, field))
  ------------------
  |  Branch (175:21): [True: 0, False: 23.6k]
  ------------------
  176|      0|                    PB_RETURN_ERROR(stream, PB_GET_ERROR(&sizestream));
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  |  Branch (933:92): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  177|  23.6k|                field->pData = (char*)field->pData + field->data_size;
  178|  23.6k|            }
  179|  5.02k|            field->pData = pData_orig;
  180|  5.02k|            size = sizestream.bytes_written;
  181|  5.02k|        }
  182|       |        
  183|  8.77k|        if (!pb_encode_varint(stream, (pb_uint64_t)size))
  ------------------
  |  Branch (183:13): [True: 0, False: 8.77k]
  ------------------
  184|      0|            return false;
  185|       |        
  186|  8.77k|        if (stream->callback == NULL)
  ------------------
  |  Branch (186:13): [True: 0, False: 8.77k]
  ------------------
  187|      0|            return pb_write(stream, NULL, size); /* Just sizing.. */
  188|       |        
  189|       |        /* Write the data */
  190|  44.2k|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (190:21): [True: 35.4k, False: 8.77k]
  ------------------
  191|  35.4k|        {
  192|  35.4k|            if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  335|  35.4k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  35.4k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  279|  70.8k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  335|  26.2k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  26.2k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_FIXED32 || PB_LTYPE(field->type) == PB_LTYPE_FIXED64)
  ------------------
  |  |  280|  26.2k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (192:17): [True: 9.15k, False: 26.2k]
  |  Branch (192:62): [True: 2.57k, False: 23.6k]
  ------------------
  193|  11.7k|            {
  194|  11.7k|                if (!pb_enc_fixed(stream, field))
  ------------------
  |  Branch (194:21): [True: 0, False: 11.7k]
  ------------------
  195|      0|                    return false;
  196|  11.7k|            }
  197|  23.6k|            else
  198|  23.6k|            {
  199|  23.6k|                if (!pb_enc_varint(stream, field))
  ------------------
  |  Branch (199:21): [True: 0, False: 23.6k]
  ------------------
  200|      0|                    return false;
  201|  23.6k|            }
  202|       |
  203|  35.4k|            field->pData = (char*)field->pData + field->data_size;
  204|  35.4k|        }
  205|  8.77k|    }
  206|  1.58k|    else /* Unpacked fields */
  207|  1.58k|#endif
  208|  1.58k|    {
  209|  7.64k|        for (i = 0; i < count; i++)
  ------------------
  |  Branch (209:21): [True: 6.06k, False: 1.58k]
  ------------------
  210|  6.06k|        {
  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.06k|            if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  333|  6.06k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  6.06k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(field->type) == PB_ATYPE_POINTER &&
  ------------------
  |  |  329|  12.1k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (215:17): [True: 0, False: 6.06k]
  ------------------
  216|      0|                (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  335|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  291|      0|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (216:18): [True: 0, False: 0]
  ------------------
  217|      0|                 PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  335|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                               PB_LTYPE(field->type) == PB_LTYPE_BYTES))
  ------------------
  |  |  287|      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.06k|            else
  240|  6.06k|            {
  241|  6.06k|                if (!encode_basic_field(stream, field))
  ------------------
  |  Branch (241:21): [True: 0, False: 6.06k]
  ------------------
  242|      0|                    return false;
  243|  6.06k|            }
  244|  6.06k|            field->pData = (char*)field->pData + field->data_size;
  245|  6.06k|        }
  246|  1.58k|    }
  247|       |    
  248|  10.3k|    return true;
  249|  10.3k|}
pb_encode.c:pb_enc_varint:
  798|   181k|{
  799|   181k|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  335|   181k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   181k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  277|   181k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (799:9): [True: 46.7k, False: 134k]
  ------------------
  800|  46.7k|    {
  801|       |        /* Perform unsigned integer extension */
  802|  46.7k|        pb_uint64_t value = 0;
  ------------------
  |  |   46|  46.7k|#define pb_uint64_t uint64_t
  ------------------
  803|       |
  804|  46.7k|        if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (804:13): [True: 5.33k, False: 41.4k]
  ------------------
  805|  5.33k|            value = *(const uint_least8_t*)field->pData;
  806|  41.4k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (806:18): [True: 5.33k, False: 36.0k]
  ------------------
  807|  5.33k|            value = *(const uint_least16_t*)field->pData;
  808|  36.0k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (808:18): [True: 19.8k, False: 16.2k]
  ------------------
  809|  19.8k|            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");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  814|       |
  815|  46.7k|        return pb_encode_varint(stream, value);
  816|  46.7k|    }
  817|   134k|    else
  818|   134k|    {
  819|       |        /* Perform signed integer extension */
  820|   134k|        pb_int64_t value = 0;
  ------------------
  |  |   45|   134k|#define pb_int64_t int64_t
  ------------------
  821|       |
  822|   134k|        if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (822:13): [True: 12.0k, False: 122k]
  ------------------
  823|  12.0k|            value = *(const int_least8_t*)field->pData;
  824|   122k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (824:18): [True: 10.6k, False: 112k]
  ------------------
  825|  10.6k|            value = *(const int_least16_t*)field->pData;
  826|   112k|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (826:18): [True: 89.4k, False: 22.5k]
  ------------------
  827|  89.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");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  832|       |
  833|   134k|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  335|   134k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   134k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  278|   134k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (833:13): [True: 22.6k, False: 112k]
  ------------------
  834|  22.6k|            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|   112k|        else
  840|   112k|            return pb_encode_varint(stream, (pb_uint64_t)value);
  841|       |
  842|   134k|    }
  843|   181k|}
pb_encode.c:pb_enc_fixed:
  846|  31.6k|{
  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|  31.6k|    if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (854:9): [True: 20.1k, False: 11.4k]
  ------------------
  855|  20.1k|    {
  856|  20.1k|        return pb_encode_fixed32(stream, field->pData);
  857|  20.1k|    }
  858|  11.4k|#ifndef PB_WITHOUT_64BIT
  859|  11.4k|    else if (field->data_size == sizeof(uint64_t))
  ------------------
  |  Branch (859:14): [True: 11.4k, False: 0]
  ------------------
  860|  11.4k|    {
  861|  11.4k|        return pb_encode_fixed64(stream, field->pData);
  862|  11.4k|    }
  863|      0|#endif
  864|      0|    else
  865|      0|    {
  866|       |        PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  867|      0|    }
  868|  31.6k|}
pb_encode.c:encode_basic_field:
  372|   199k|{
  373|   199k|    if (!field->pData)
  ------------------
  |  Branch (373:9): [True: 0, False: 199k]
  ------------------
  374|      0|    {
  375|       |        /* Missing pointer field */
  376|      0|        return true;
  377|      0|    }
  378|       |
  379|   199k|    if (!pb_encode_tag_for_field(stream, field))
  ------------------
  |  Branch (379:9): [True: 0, False: 199k]
  ------------------
  380|      0|        return false;
  381|       |
  382|   199k|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  335|   199k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   199k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  383|   199k|    {
  384|  2.78k|        case PB_LTYPE_BOOL:
  ------------------
  |  |  275|  2.78k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (384:9): [True: 2.78k, False: 196k]
  ------------------
  385|  2.78k|            return pb_enc_bool(stream, field);
  386|       |
  387|  77.2k|        case PB_LTYPE_VARINT:
  ------------------
  |  |  276|  77.2k|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (387:9): [True: 77.2k, False: 122k]
  ------------------
  388|   117k|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  277|   117k|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (388:9): [True: 40.7k, False: 158k]
  ------------------
  389|   134k|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  278|   134k|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (389:9): [True: 16.2k, False: 183k]
  ------------------
  390|   134k|            return pb_enc_varint(stream, field);
  391|       |
  392|  11.0k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  279|  11.0k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (392:9): [True: 11.0k, False: 188k]
  ------------------
  393|  19.9k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  280|  19.9k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (393:9): [True: 8.89k, False: 190k]
  ------------------
  394|  19.9k|            return pb_enc_fixed(stream, field);
  395|       |
  396|  3.81k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  287|  3.81k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (396:9): [True: 3.81k, False: 195k]
  ------------------
  397|  3.81k|            return pb_enc_bytes(stream, field);
  398|       |
  399|  14.9k|        case PB_LTYPE_STRING:
  ------------------
  |  |  291|  14.9k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (399:9): [True: 14.9k, False: 184k]
  ------------------
  400|  14.9k|            return pb_enc_string(stream, field);
  401|       |
  402|  19.8k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  295|  19.8k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (402:9): [True: 19.8k, False: 179k]
  ------------------
  403|  19.8k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  300|  19.8k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (403:9): [True: 0, False: 199k]
  ------------------
  404|  19.8k|            return pb_enc_submessage(stream, field);
  405|       |
  406|  4.21k|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  310|  4.21k|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (406:9): [True: 4.21k, False: 195k]
  ------------------
  407|  4.21k|            return pb_enc_fixed_length_bytes(stream, field);
  408|       |
  409|      0|        default:
  ------------------
  |  Branch (409:9): [True: 0, False: 199k]
  ------------------
  410|       |            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  411|   199k|    }
  412|   199k|}
pb_encode.c:pb_enc_bool:
  791|  2.78k|{
  792|  2.78k|    uint32_t value = safe_read_bool(field->pData) ? 1 : 0;
  ------------------
  |  Branch (792:22): [True: 2.01k, False: 774]
  ------------------
  793|  2.78k|    PB_UNUSED(field);
  ------------------
  |  |  179|  2.78k|#define PB_UNUSED(x) (void)(x)
  ------------------
  794|  2.78k|    return pb_encode_varint(stream, value);
  795|  2.78k|}
pb_encode.c:pb_enc_bytes:
  871|  3.81k|{
  872|  3.81k|    const pb_bytes_array_t *bytes = NULL;
  873|       |
  874|  3.81k|    bytes = (const pb_bytes_array_t*)field->pData;
  875|       |    
  876|  3.81k|    if (bytes == NULL)
  ------------------
  |  Branch (876:9): [True: 0, False: 3.81k]
  ------------------
  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.81k|    if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  333|  3.81k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  3.81k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  328|  7.63k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (882:9): [True: 3.81k, False: 0]
  ------------------
  883|  3.81k|        bytes->size > field->data_size - offsetof(pb_bytes_array_t, bytes))
  ------------------
  |  Branch (883:9): [True: 0, False: 3.81k]
  ------------------
  884|      0|    {
  885|      0|        PB_RETURN_ERROR(stream, "bytes size exceeded");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  886|      0|    }
  887|       |    
  888|  3.81k|    return pb_encode_string(stream, bytes->bytes, (size_t)bytes->size);
  889|  3.81k|}
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)
  ------------------
  |  |  333|  14.9k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  14.9k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  329|  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");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933: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|  64.6k|        while (size < max_size && *p != '\0')
  ------------------
  |  Branch (924:16): [True: 64.3k, False: 270]
  |  Branch (924:35): [True: 49.6k, False: 14.6k]
  ------------------
  925|  49.6k|        {
  926|  49.6k|            size++;
  927|  49.6k|            p++;
  928|  49.6k|        }
  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");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933: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.8k|{
  946|  19.8k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (946:9): [True: 0, False: 19.8k]
  ------------------
  947|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  937|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  933|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (933:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  948|       |
  949|       |    /* Required fields have no callback slot. Extension fields are always
  950|       |     * required, and for them pSize points to extension->found. */
  951|  19.8k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL &&
  ------------------
  |  |  335|  19.8k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|  19.8k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL &&
  ------------------
  |  |  300|  39.6k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (951:9): [True: 0, False: 19.8k]
  |  Branch (951:58): [True: 0, False: 0]
  ------------------
  952|      0|        PB_HTYPE(field->type) != PB_HTYPE_REQUIRED)
  ------------------
  |  |  334|      0|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|      0|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      PB_HTYPE(field->type) != PB_HTYPE_REQUIRED)
  ------------------
  |  |  318|      0|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (952:9): [True: 0, False: 0]
  ------------------
  953|      0|    {
  954|       |        /* Message callback is stored right before pSize. */
  955|      0|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
  956|      0|        if (callback->funcs.encode)
  ------------------
  |  Branch (956:13): [True: 0, False: 0]
  ------------------
  957|      0|        {
  958|      0|            if (!callback->funcs.encode(stream, field, &callback->arg))
  ------------------
  |  Branch (958:17): [True: 0, False: 0]
  ------------------
  959|      0|                return false;
  960|      0|        }
  961|      0|    }
  962|       |    
  963|  19.8k|    return pb_encode_submessage(stream, field->submsg_desc, field->pData);
  964|  19.8k|}
pb_encode.c:pb_enc_fixed_length_bytes:
  967|  4.21k|{
  968|  4.21k|    return pb_encode_string(stream, (const pb_byte_t*)field->pData, (size_t)field->data_size);
  969|  4.21k|}
pb_encode.c:pb_encode_varint_32:
  583|  75.5k|{
  584|  75.5k|    size_t i = 0;
  585|  75.5k|    pb_byte_t buffer[10];
  586|  75.5k|    pb_byte_t byte = (pb_byte_t)(low & 0x7F);
  587|  75.5k|    low >>= 7;
  588|       |
  589|   202k|    while (i < 4 && (low != 0 || high != 0))
  ------------------
  |  Branch (589:12): [True: 190k, False: 11.8k]
  |  Branch (589:22): [True: 126k, False: 64.0k]
  |  Branch (589:34): [True: 346, False: 63.7k]
  ------------------
  590|   126k|    {
  591|   126k|        byte |= 0x80;
  592|   126k|        buffer[i++] = byte;
  593|   126k|        byte = (pb_byte_t)(low & 0x7F);
  594|   126k|        low >>= 7;
  595|   126k|    }
  596|       |
  597|  75.5k|    if (high)
  ------------------
  |  Branch (597:9): [True: 10.3k, False: 65.2k]
  ------------------
  598|  10.3k|    {
  599|  10.3k|        byte = (pb_byte_t)(byte | ((high & 0x07) << 4));
  600|  10.3k|        high >>= 3;
  601|       |
  602|  52.7k|        while (high)
  ------------------
  |  Branch (602:16): [True: 42.4k, False: 10.3k]
  ------------------
  603|  42.4k|        {
  604|  42.4k|            byte |= 0x80;
  605|  42.4k|            buffer[i++] = byte;
  606|  42.4k|            byte = (pb_byte_t)(high & 0x7F);
  607|  42.4k|            high >>= 7;
  608|  42.4k|        }
  609|  10.3k|    }
  610|       |
  611|  75.5k|    buffer[i++] = byte;
  612|       |
  613|  75.5k|    return pb_write(stream, buffer, i);
  614|  75.5k|}

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

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

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

validate_static:
    7|   515k|{
    8|   515k|    pb_size_t count = 1;
    9|   515k|    pb_size_t i;
   10|   515k|    bool truebool = true;
   11|   515k|    bool falsebool = false;
   12|       |
   13|   515k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  334|   515k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   515k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  321|  1.03M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 111k, False: 403k]
  |  Branch (13:54): [True: 111k, False: 0]
  ------------------
   14|   111k|    {
   15|       |        /* Array count must be between 0 and statically allocated size */
   16|   111k|        count = *(pb_size_t*)iter->pSize;
   17|   111k|        assert(count <= iter->array_size);
  ------------------
  |  Branch (17:9): [True: 0, False: 111k]
  |  Branch (17:9): [True: 111k, False: 0]
  ------------------
   18|   111k|    }
   19|   403k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  334|   403k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   403k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  319|   806k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 121k, False: 281k]
  |  Branch (19:59): [True: 121k, False: 0]
  ------------------
   20|   121k|    {
   21|       |        /* Boolean has_ field must have a valid value */
   22|   121k|        assert(memcmp(iter->pSize, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (22:9): [True: 121k, False: 0]
  |  Branch (22:9): [True: 0, False: 0]
  |  Branch (22:9): [True: 10.4k, False: 111k]
  |  Branch (22:9): [True: 111k, False: 0]
  ------------------
   23|   121k|               memcmp(iter->pSize, &falsebool, sizeof(bool)) == 0);
   24|   121k|    }
   25|   281k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  334|   281k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  324|   281k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  323|   281k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 26.6k, False: 254k]
  ------------------
   26|  26.6k|    {
   27|  26.6k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 25.2k, False: 1.44k]
  ------------------
   28|  25.2k|        {
   29|       |            /* Some different field in oneof */
   30|  25.2k|            return;
   31|  25.2k|        }
   32|  26.6k|    }
   33|       |
   34|   950k|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 460k, False: 489k]
  ------------------
   35|   460k|    {
   36|   460k|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|   460k|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  335|   460k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   460k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  291|   460k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 28.1k, False: 432k]
  ------------------
   39|  28.1k|        {
   40|       |            /* String length must be at most statically allocated size */
   41|  28.1k|            assert(strlen(pData) + 1 <= iter->data_size);
  ------------------
  |  Branch (41:13): [True: 0, False: 28.1k]
  |  Branch (41:13): [True: 28.1k, False: 0]
  ------------------
   42|  28.1k|        }
   43|   432k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  335|   432k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   432k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  287|   432k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 12.5k, False: 420k]
  ------------------
   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: 0, False: 12.5k]
  |  Branch (47:13): [True: 6.11k, False: 6.40k]
  |  Branch (47:13): [True: 12.5k, False: 0]
  ------------------
   48|  12.5k|        }
   49|   420k|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  335|   420k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  314|   420k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  275|   420k|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 12.0k, False: 408k]
  ------------------
   50|  12.0k|        {
   51|       |            /* Bool fields must have valid value */
   52|  12.0k|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
  ------------------
  |  Branch (52:13): [True: 12.0k, False: 0]
  |  Branch (52:13): [True: 0, False: 0]
  |  Branch (52:13): [True: 5.11k, False: 6.97k]
  |  Branch (52:13): [True: 6.97k, False: 0]
  ------------------
   53|  12.0k|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
   54|  12.0k|        }
   55|   408k|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  336|   408k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  335|   408k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|   408k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  295|   816k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (336:32): [True: 44.0k, False: 363k]
  |  |  ------------------
  |  |  337|   408k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  335|   363k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  314|   363k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  300|   363k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (337:32): [True: 0, False: 363k]
  |  |  ------------------
  ------------------
   56|  44.0k|        {
   57|  44.0k|            validate_message(pData, 0, iter->submsg_desc);
   58|  44.0k|        }
   59|   460k|    }
   60|   489k|}
validate_message:
  145|  49.4k|{
  146|  49.4k|    pb_field_iter_t iter;
  147|       |
  148|  49.4k|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 36.6k, False: 12.7k]
  ------------------
  149|  36.6k|    {
  150|  36.6k|        do
  151|   531k|        {
  152|   531k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  333|   531k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|   531k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  328|   531k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 515k, False: 15.9k]
  ------------------
  153|   515k|            {
  154|   515k|                validate_static(&iter);
  155|   515k|            }
  156|  15.9k|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  333|  15.9k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  331|  15.9k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  329|  15.9k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 0, False: 15.9k]
  ------------------
  157|      0|            {
  158|      0|                validate_pointer(&iter);
  159|      0|            }
  160|   531k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 494k, False: 36.6k]
  ------------------
  161|  36.6k|    }
  162|  49.4k|}

