pb_field_iter_begin:
  157|   929k|{
  158|   929k|    memset(iter, 0, sizeof(*iter));
  159|       |
  160|   929k|    iter->descriptor = desc;
  161|   929k|    iter->message = message;
  162|       |
  163|   929k|    return load_descriptor_values(iter);
  164|   929k|}
pb_field_iter_begin_extension:
  167|  97.1k|{
  168|  97.1k|    const pb_msgdesc_t *msg = (const pb_msgdesc_t*)extension->type->arg;
  169|  97.1k|    bool status;
  170|       |
  171|  97.1k|    uint32_t word0 = PB_PROGMEM_READU32(msg->field_info[0]);
  ------------------
  |  |  155|  97.1k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  172|  97.1k|    if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  297|  97.1k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  97.1k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(word0 >> 8) == PB_ATYPE_POINTER)
  ------------------
  |  |  293|  97.1k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (172:9): [True: 0, False: 97.1k]
  ------------------
  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|  97.1k|    else
  180|  97.1k|    {
  181|  97.1k|        status = pb_field_iter_begin(iter, msg, extension->dest);
  182|  97.1k|    }
  183|       |
  184|  97.1k|    iter->pSize = &extension->found;
  185|  97.1k|    return status;
  186|  97.1k|}
pb_field_iter_next:
  189|  3.04M|{
  190|  3.04M|    advance_iterator(iter);
  191|  3.04M|    (void)load_descriptor_values(iter);
  192|  3.04M|    return iter->index != 0;
  193|  3.04M|}
pb_field_iter_find:
  196|  30.6M|{
  197|  30.6M|    if (iter->tag == tag)
  ------------------
  |  Branch (197:9): [True: 29.2M, False: 1.41M]
  ------------------
  198|  29.2M|    {
  199|  29.2M|        return true; /* Nothing to do, correct field already. */
  200|  29.2M|    }
  201|  1.41M|    else if (tag > iter->descriptor->largest_tag)
  ------------------
  |  Branch (201:14): [True: 379k, False: 1.03M]
  ------------------
  202|   379k|    {
  203|   379k|        return false;
  204|   379k|    }
  205|  1.03M|    else
  206|  1.03M|    {
  207|  1.03M|        pb_size_t start = iter->index;
  208|  1.03M|        uint32_t fieldinfo;
  209|       |
  210|  1.03M|        if (tag < iter->tag)
  ------------------
  |  Branch (210:13): [True: 235k, False: 798k]
  ------------------
  211|   235k|        {
  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|   235k|            iter->index = iter->descriptor->field_count;
  216|   235k|        }
  217|       |
  218|  1.03M|        do
  219|  10.6M|        {
  220|       |            /* Advance iterator but don't load values yet */
  221|  10.6M|            advance_iterator(iter);
  222|       |
  223|       |            /* Do fast check for tag number match */
  224|  10.6M|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  155|  10.6M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  225|       |
  226|  10.6M|            if (((fieldinfo >> 2) & 0x3F) == (tag & 0x3F))
  ------------------
  |  Branch (226:17): [True: 966k, False: 9.64M]
  ------------------
  227|   966k|            {
  228|       |                /* Good candidate, check further */
  229|   966k|                (void)load_descriptor_values(iter);
  230|       |
  231|   966k|                if (iter->tag == tag &&
  ------------------
  |  Branch (231:21): [True: 868k, False: 98.5k]
  ------------------
  232|   966k|                    PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  299|   868k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   868k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                                  PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
  ------------------
  |  |  268|   868k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (232:21): [True: 865k, False: 2.44k]
  ------------------
  233|   865k|                {
  234|       |                    /* Found it */
  235|   865k|                    return true;
  236|   865k|                }
  237|   966k|            }
  238|  10.6M|        } while (iter->index != start);
  ------------------
  |  Branch (238:18): [True: 9.57M, False: 168k]
  ------------------
  239|       |
  240|       |        /* Searched all the way back to start, and found nothing. */
  241|   168k|        (void)load_descriptor_values(iter);
  242|   168k|        return false;
  243|  1.03M|    }
  244|  30.6M|}
pb_field_iter_find_extension:
  247|  8.15k|{
  248|  8.15k|    if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  299|  8.15k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  8.15k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(iter->type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  268|  8.15k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (248:9): [True: 0, False: 8.15k]
  ------------------
  249|      0|    {
  250|      0|        return true;
  251|      0|    }
  252|  8.15k|    else
  253|  8.15k|    {
  254|  8.15k|        pb_size_t start = iter->index;
  255|  8.15k|        uint32_t fieldinfo;
  256|       |
  257|  8.15k|        do
  258|   110k|        {
  259|       |            /* Advance iterator but don't load values yet */
  260|   110k|            advance_iterator(iter);
  261|       |
  262|       |            /* Do fast check for field type */
  263|   110k|            fieldinfo = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  155|   110k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  264|       |
  265|   110k|            if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  299|   110k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   110k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE((fieldinfo >> 8) & 0xFF) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  268|   110k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (265:17): [True: 3.45k, False: 106k]
  ------------------
  266|  3.45k|            {
  267|  3.45k|                return load_descriptor_values(iter);
  268|  3.45k|            }
  269|   110k|        } while (iter->index != start);
  ------------------
  |  Branch (269:18): [True: 101k, False: 4.70k]
  ------------------
  270|       |
  271|       |        /* Searched all the way back to start, and found nothing. */
  272|  4.70k|        (void)load_descriptor_values(iter);
  273|  4.70k|        return false;
  274|  8.15k|    }
  275|  8.15k|}
pb_field_iter_begin_const:
  291|   211k|{
  292|   211k|    return pb_field_iter_begin(iter, desc, pb_const_cast(message));
  293|   211k|}
pb_field_iter_begin_extension_const:
  296|  2.80k|{
  297|  2.80k|    return pb_field_iter_begin_extension(iter, (pb_extension_t*)pb_const_cast(extension));
  298|  2.80k|}
pb_common.c:load_descriptor_values:
    9|  5.11M|{
   10|  5.11M|    uint32_t word0;
   11|  5.11M|    uint32_t data_offset;
   12|  5.11M|    int_least8_t size_offset;
   13|       |
   14|  5.11M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (14:9): [True: 499k, False: 4.61M]
  ------------------
   15|   499k|        return false;
   16|       |
   17|  4.61M|    word0 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  155|  4.61M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   18|  4.61M|    iter->type = (pb_type_t)((word0 >> 8) & 0xFF);
   19|       |
   20|  4.61M|    switch(word0 & 3)
   21|  4.61M|    {
   22|   675k|        case 0: {
  ------------------
  |  Branch (22:9): [True: 675k, False: 3.94M]
  ------------------
   23|       |            /* 1-word format */
   24|   675k|            iter->array_size = 1;
   25|   675k|            iter->tag = (pb_size_t)((word0 >> 2) & 0x3F);
   26|   675k|            size_offset = (int_least8_t)((word0 >> 24) & 0x0F);
   27|   675k|            data_offset = (word0 >> 16) & 0xFF;
   28|   675k|            iter->data_size = (pb_size_t)((word0 >> 28) & 0x0F);
   29|   675k|            break;
   30|      0|        }
   31|       |
   32|  3.17M|        case 1: {
  ------------------
  |  Branch (32:9): [True: 3.17M, False: 1.44M]
  ------------------
   33|       |            /* 2-word format */
   34|  3.17M|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  155|  3.17M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   35|       |
   36|  3.17M|            iter->array_size = (pb_size_t)((word0 >> 16) & 0x0FFF);
   37|  3.17M|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 28) << 6));
   38|  3.17M|            size_offset = (int_least8_t)((word0 >> 28) & 0x0F);
   39|  3.17M|            data_offset = word1 & 0xFFFF;
   40|  3.17M|            iter->data_size = (pb_size_t)((word1 >> 16) & 0x0FFF);
   41|  3.17M|            break;
   42|      0|        }
   43|       |
   44|   492k|        case 2: {
  ------------------
  |  Branch (44:9): [True: 492k, False: 4.12M]
  ------------------
   45|       |            /* 4-word format */
   46|   492k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  155|   492k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   47|   492k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  155|   492k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   48|   492k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  155|   492k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   49|       |
   50|   492k|            iter->array_size = (pb_size_t)(word0 >> 16);
   51|   492k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   52|   492k|            size_offset = (int_least8_t)(word1 & 0xFF);
   53|   492k|            data_offset = word2;
   54|   492k|            iter->data_size = (pb_size_t)word3;
   55|   492k|            break;
   56|      0|        }
   57|       |
   58|   275k|        default: {
  ------------------
  |  Branch (58:9): [True: 275k, False: 4.34M]
  ------------------
   59|       |            /* 8-word format */
   60|   275k|            uint32_t word1 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 1]);
  ------------------
  |  |  155|   275k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   61|   275k|            uint32_t word2 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 2]);
  ------------------
  |  |  155|   275k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   62|   275k|            uint32_t word3 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 3]);
  ------------------
  |  |  155|   275k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   63|   275k|            uint32_t word4 = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index + 4]);
  ------------------
  |  |  155|   275k|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
   64|       |
   65|   275k|            iter->array_size = (pb_size_t)word4;
   66|   275k|            iter->tag = (pb_size_t)(((word0 >> 2) & 0x3F) | ((word1 >> 8) << 6));
   67|   275k|            size_offset = (int_least8_t)(word1 & 0xFF);
   68|   275k|            data_offset = word2;
   69|   275k|            iter->data_size = (pb_size_t)word3;
   70|   275k|            break;
   71|      0|        }
   72|  4.61M|    }
   73|       |
   74|  4.61M|    if (!iter->message)
  ------------------
  |  Branch (74:9): [True: 0, False: 4.61M]
  ------------------
   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.61M|    else
   81|  4.61M|    {
   82|  4.61M|        iter->pField = (char*)iter->message + data_offset;
   83|       |
   84|  4.61M|        if (size_offset)
  ------------------
  |  Branch (84:13): [True: 797k, False: 3.81M]
  ------------------
   85|   797k|        {
   86|   797k|            iter->pSize = (char*)iter->pField - size_offset;
   87|   797k|        }
   88|  3.81M|        else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  298|  3.81M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  3.81M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  285|  7.63M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (88:18): [True: 61.6k, False: 3.75M]
  ------------------
   89|  3.81M|                 (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  297|  61.6k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  61.6k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                               (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
  ------------------
  |  |  292|   123k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (89:19): [True: 0, False: 61.6k]
  ------------------
   90|  61.6k|                  PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  297|  61.6k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  61.6k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                                PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
  ------------------
  |  |  293|  61.6k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (90:19): [True: 61.6k, False: 0]
  ------------------
   91|  61.6k|        {
   92|       |            /* Fixed count array */
   93|  61.6k|            iter->pSize = &iter->array_size;
   94|  61.6k|        }
   95|  3.75M|        else
   96|  3.75M|        {
   97|  3.75M|            iter->pSize = NULL;
   98|  3.75M|        }
   99|       |
  100|  4.61M|        if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  297|  4.61M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  4.61M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
  ------------------
  |  |  293|  9.23M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (100:13): [True: 4.39M, False: 218k]
  |  Branch (100:57): [True: 4.39M, False: 0]
  ------------------
  101|  4.39M|        {
  102|  4.39M|            iter->pData = *(void**)iter->pField;
  103|  4.39M|        }
  104|   218k|        else
  105|   218k|        {
  106|   218k|            iter->pData = iter->pField;
  107|   218k|        }
  108|  4.61M|    }
  109|       |
  110|  4.61M|    if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  300|  4.61M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|  4.61M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  4.61M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|  9.23M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 560k, False: 4.05M]
  |  |  ------------------
  |  |  301|  4.61M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|  4.05M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  4.05M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|  4.05M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 0, False: 4.05M]
  |  |  ------------------
  ------------------
  111|   560k|    {
  112|   560k|        iter->submsg_desc = iter->descriptor->submsg_info[iter->submessage_index];
  113|   560k|    }
  114|  4.05M|    else
  115|  4.05M|    {
  116|  4.05M|        iter->submsg_desc = NULL;
  117|  4.05M|    }
  118|       |
  119|  4.61M|    return true;
  120|  4.61M|}
pb_common.c:advance_iterator:
  123|  13.7M|{
  124|  13.7M|    iter->index++;
  125|       |
  126|  13.7M|    if (iter->index >= iter->descriptor->field_count)
  ------------------
  |  Branch (126:9): [True: 730k, False: 13.0M]
  ------------------
  127|   730k|    {
  128|       |        /* Restart */
  129|   730k|        iter->index = 0;
  130|   730k|        iter->field_info_index = 0;
  131|   730k|        iter->submessage_index = 0;
  132|   730k|        iter->required_field_index = 0;
  133|   730k|    }
  134|  13.0M|    else
  135|  13.0M|    {
  136|       |        /* Increment indexes based on previous field type.
  137|       |         * All field info formats have the following fields:
  138|       |         * - lowest 2 bits tell the amount of words in the descriptor (2^n words)
  139|       |         * - bits 2..7 give the lowest bits of tag number.
  140|       |         * - bits 8..15 give the field type.
  141|       |         */
  142|  13.0M|        uint32_t prev_descriptor = PB_PROGMEM_READU32(iter->descriptor->field_info[iter->field_info_index]);
  ------------------
  |  |  155|  13.0M|#define PB_PROGMEM_READU32(x)  (x)
  ------------------
  143|  13.0M|        pb_type_t prev_type = (prev_descriptor >> 8) & 0xFF;
  144|  13.0M|        pb_size_t descriptor_len = (pb_size_t)(1 << (prev_descriptor & 3));
  145|       |
  146|       |        /* Add to fields.
  147|       |         * The cast to pb_size_t is needed to avoid -Wconversion warning.
  148|       |         * Because the data is is constants from generator, there is no danger of overflow.
  149|       |         */
  150|  13.0M|        iter->field_info_index = (pb_size_t)(iter->field_info_index + descriptor_len);
  151|  13.0M|        iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  298|  13.0M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  13.0M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      iter->required_field_index = (pb_size_t)(iter->required_field_index + (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED));
  ------------------
  |  |  282|  13.0M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  152|  13.0M|        iter->submessage_index = (pb_size_t)(iter->submessage_index + PB_LTYPE_IS_SUBMSG(prev_type));
  ------------------
  |  |  300|  13.0M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|  13.0M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  13.0M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|  26.0M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 1.72M, False: 11.3M]
  |  |  ------------------
  |  |  301|  13.0M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|  11.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  11.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|  11.3M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 0, False: 11.3M]
  |  |  ------------------
  ------------------
  153|  13.0M|    }
  154|  13.7M|}
pb_common.c:pb_const_cast:
  278|   214k|{
  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|   214k|    union {
  283|   214k|        void *p1;
  284|   214k|        const void *p2;
  285|   214k|    } t;
  286|   214k|    t.p2 = p;
  287|   214k|    return t.p1;
  288|   214k|}

pb_read:
   83|  3.52M|{
   84|  3.52M|    if (count == 0)
  ------------------
  |  Branch (84:9): [True: 787k, False: 2.73M]
  ------------------
   85|   787k|        return true;
   86|       |
   87|  2.73M|#ifndef PB_BUFFER_ONLY
   88|  2.73M|	if (buf == NULL && stream->callback != buf_read)
  ------------------
  |  Branch (88:6): [True: 131k, False: 2.60M]
  |  Branch (88:21): [True: 44.3k, False: 87.0k]
  ------------------
   89|  44.3k|	{
   90|       |		/* Skip input bytes */
   91|  44.3k|		pb_byte_t tmp[16];
   92|   204k|		while (count > 16)
  ------------------
  |  Branch (92:10): [True: 159k, False: 44.3k]
  ------------------
   93|   159k|		{
   94|   159k|			if (!pb_read(stream, tmp, 16))
  ------------------
  |  Branch (94:8): [True: 0, False: 159k]
  ------------------
   95|      0|				return false;
   96|       |			
   97|   159k|			count -= 16;
   98|   159k|		}
   99|       |		
  100|  44.3k|		return pb_read(stream, tmp, count);
  101|  44.3k|	}
  102|  2.69M|#endif
  103|       |
  104|  2.69M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (104:9): [True: 206, False: 2.69M]
  ------------------
  105|    206|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  894|    206|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|    206|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 206]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  106|       |    
  107|  2.69M|#ifndef PB_BUFFER_ONLY
  108|  2.69M|    if (!stream->callback(stream, buf, count))
  ------------------
  |  Branch (108:9): [True: 0, False: 2.69M]
  ------------------
  109|      0|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  110|       |#else
  111|       |    if (!buf_read(stream, buf, count))
  112|       |        return false;
  113|       |#endif
  114|       |    
  115|  2.69M|    if (stream->bytes_left < count)
  ------------------
  |  Branch (115:9): [True: 0, False: 2.69M]
  ------------------
  116|      0|        stream->bytes_left = 0;
  117|  2.69M|    else
  118|  2.69M|        stream->bytes_left -= count;
  119|       |
  120|  2.69M|    return true;
  121|  2.69M|}
pb_istream_from_buffer:
  144|  6.55k|{
  145|  6.55k|    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|  6.55k|    union {
  150|  6.55k|        void *state;
  151|  6.55k|        const void *c_state;
  152|  6.55k|    } state;
  153|       |#ifdef PB_BUFFER_ONLY
  154|       |    stream.callback = NULL;
  155|       |#else
  156|  6.55k|    stream.callback = &buf_read;
  157|  6.55k|#endif
  158|  6.55k|    state.c_state = buf;
  159|  6.55k|    stream.state = state.state;
  160|  6.55k|    stream.bytes_left = msglen;
  161|  6.55k|#ifndef PB_NO_ERRMSG
  162|  6.55k|    stream.errmsg = NULL;
  163|  6.55k|#endif
  164|  6.55k|    return stream;
  165|  6.55k|}
pb_decode_varint32:
  238|  32.7M|{
  239|  32.7M|    return pb_decode_varint32_eof(stream, dest, NULL);
  240|  32.7M|}
pb_decode_varint:
  244|  6.34M|{
  245|  6.34M|    pb_byte_t byte;
  246|  6.34M|    uint_fast8_t bitpos = 0;
  247|  6.34M|    uint64_t result = 0;
  248|       |    
  249|  6.34M|    do
  250|  9.39M|    {
  251|  9.39M|        if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (251:13): [True: 84, False: 9.39M]
  ------------------
  252|     84|            return false;
  253|       |
  254|  9.39M|        if (bitpos >= 63 && (byte & 0xFE) != 0)
  ------------------
  |  Branch (254:13): [True: 73.1k, False: 9.32M]
  |  Branch (254:29): [True: 29, False: 73.1k]
  ------------------
  255|     29|            PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  894|     29|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     29|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 29]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  256|       |
  257|  9.39M|        result |= (uint64_t)(byte & 0x7F) << bitpos;
  258|  9.39M|        bitpos = (uint_fast8_t)(bitpos + 7);
  259|  9.39M|    } while (byte & 0x80);
  ------------------
  |  Branch (259:14): [True: 3.04M, False: 6.34M]
  ------------------
  260|       |    
  261|  6.34M|    *dest = result;
  262|  6.34M|    return true;
  263|  6.34M|}
pb_decode_tag:
  292|  30.6M|{
  293|  30.6M|    uint32_t temp;
  294|  30.6M|    *eof = false;
  295|  30.6M|    *wire_type = (pb_wire_type_t) 0;
  296|  30.6M|    *tag = 0;
  297|       |    
  298|  30.6M|    if (!pb_decode_varint32_eof(stream, &temp, eof))
  ------------------
  |  Branch (298:9): [True: 1.63k, False: 30.6M]
  ------------------
  299|  1.63k|    {
  300|  1.63k|        return false;
  301|  1.63k|    }
  302|       |    
  303|  30.6M|    *tag = temp >> 3;
  304|  30.6M|    *wire_type = (pb_wire_type_t)(temp & 7);
  305|  30.6M|    return true;
  306|  30.6M|}
pb_skip_field:
  309|   542k|{
  310|   542k|    switch (wire_type)
  311|   542k|    {
  312|   241k|        case PB_WT_VARINT: return pb_skip_varint(stream);
  ------------------
  |  Branch (312:9): [True: 241k, False: 300k]
  ------------------
  313|  23.8k|        case PB_WT_64BIT: return pb_read(stream, NULL, 8);
  ------------------
  |  Branch (313:9): [True: 23.8k, False: 519k]
  ------------------
  314|   207k|        case PB_WT_STRING: return pb_skip_string(stream);
  ------------------
  |  Branch (314:9): [True: 207k, False: 335k]
  ------------------
  315|  69.8k|        case PB_WT_32BIT: return pb_read(stream, NULL, 4);
  ------------------
  |  Branch (315:9): [True: 69.8k, False: 473k]
  ------------------
  316|     94|        default: PB_RETURN_ERROR(stream, "invalid wire_type");
  ------------------
  |  |  894|     94|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     94|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 94]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (316:9): [True: 94, False: 542k]
  ------------------
  317|   542k|    }
  318|   542k|}
pb_make_string_substream:
  363|   358k|{
  364|   358k|    uint32_t size;
  365|   358k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (365:9): [True: 127, False: 358k]
  ------------------
  366|    127|        return false;
  367|       |    
  368|   358k|    *substream = *stream;
  369|   358k|    if (substream->bytes_left < size)
  ------------------
  |  Branch (369:9): [True: 73, False: 358k]
  ------------------
  370|     73|        PB_RETURN_ERROR(stream, "parent stream too short");
  ------------------
  |  |  894|     73|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     73|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 73]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  371|       |    
  372|   358k|    substream->bytes_left = (size_t)size;
  373|   358k|    stream->bytes_left -= (size_t)size;
  374|   358k|    return true;
  375|   358k|}
pb_close_string_substream:
  378|   358k|{
  379|   358k|    if (substream->bytes_left) {
  ------------------
  |  Branch (379:9): [True: 93, False: 358k]
  ------------------
  380|     93|        if (!pb_read(substream, NULL, substream->bytes_left))
  ------------------
  |  Branch (380:13): [True: 0, False: 93]
  ------------------
  381|      0|            return false;
  382|     93|    }
  383|       |
  384|   358k|    stream->state = substream->state;
  385|       |
  386|   358k|#ifndef PB_NO_ERRMSG
  387|   358k|    stream->errmsg = substream->errmsg;
  388|   358k|#endif
  389|   358k|    return true;
  390|   358k|}
pb_decode_ex:
 1155|  3.66k|{
 1156|  3.66k|    bool status;
 1157|       |
 1158|  3.66k|    if ((flags & PB_DECODE_DELIMITED) == 0)
  ------------------
  |  |  100|  3.66k|#define PB_DECODE_DELIMITED       0x02U
  ------------------
  |  Branch (1158:9): [True: 3.66k, False: 0]
  ------------------
 1159|  3.66k|    {
 1160|  3.66k|      status = pb_decode_inner(stream, fields, dest_struct, flags);
 1161|  3.66k|    }
 1162|      0|    else
 1163|      0|    {
 1164|      0|      pb_istream_t substream;
 1165|      0|      if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1165:11): [True: 0, False: 0]
  ------------------
 1166|      0|        return false;
 1167|       |
 1168|      0|      status = pb_decode_inner(&substream, fields, dest_struct, flags);
 1169|       |
 1170|      0|      if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1170:11): [True: 0, False: 0]
  ------------------
 1171|      0|        return false;
 1172|      0|    }
 1173|       |    
 1174|  3.66k|#ifdef PB_ENABLE_MALLOC
 1175|  3.66k|    if (!status)
  ------------------
  |  Branch (1175:9): [True: 2.11k, False: 1.54k]
  ------------------
 1176|  2.11k|        pb_release(fields, dest_struct);
 1177|  3.66k|#endif
 1178|       |    
 1179|  3.66k|    return status;
 1180|  3.66k|}
pb_decode:
 1183|  4.44k|{
 1184|  4.44k|    bool status;
 1185|       |
 1186|  4.44k|    status = pb_decode_inner(stream, fields, dest_struct, 0);
 1187|       |
 1188|  4.44k|#ifdef PB_ENABLE_MALLOC
 1189|  4.44k|    if (!status)
  ------------------
  |  Branch (1189:9): [True: 0, False: 4.44k]
  ------------------
 1190|      0|        pb_release(fields, dest_struct);
 1191|  4.44k|#endif
 1192|       |
 1193|  4.44k|    return status;
 1194|  4.44k|}
pb_release:
 1321|   313k|{
 1322|   313k|    pb_field_iter_t iter;
 1323|       |    
 1324|   313k|    if (!dest_struct)
  ------------------
  |  Branch (1324:9): [True: 0, False: 313k]
  ------------------
 1325|      0|        return; /* Ignore NULL pointers, similar to free() */
 1326|       |
 1327|   313k|    if (!pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1327:9): [True: 203k, False: 109k]
  ------------------
 1328|   203k|        return; /* Empty message type */
 1329|       |    
 1330|   109k|    do
 1331|  1.08M|    {
 1332|  1.08M|        pb_release_single_field(&iter);
 1333|  1.08M|    } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (1333:14): [True: 972k, False: 109k]
  ------------------
 1334|   109k|}
pb_decode_bool:
 1347|  4.41M|{
 1348|  4.41M|    uint32_t value;
 1349|  4.41M|    if (!pb_decode_varint32(stream, &value))
  ------------------
  |  Branch (1349:9): [True: 60, False: 4.41M]
  ------------------
 1350|     60|        return false;
 1351|       |
 1352|  4.41M|    *(bool*)dest = (value != 0);
 1353|  4.41M|    return true;
 1354|  4.41M|}
pb_decode_svarint:
 1357|  2.93M|{
 1358|  2.93M|    pb_uint64_t value;
  ------------------
  |  |   58|  2.93M|#define pb_uint64_t uint64_t
  ------------------
 1359|  2.93M|    if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1359:9): [True: 32, False: 2.93M]
  ------------------
 1360|     32|        return false;
 1361|       |    
 1362|  2.93M|    if (value & 1)
  ------------------
  |  Branch (1362:9): [True: 416k, False: 2.51M]
  ------------------
 1363|   416k|        *dest = (pb_int64_t)(~(value >> 1));
 1364|  2.51M|    else
 1365|  2.51M|        *dest = (pb_int64_t)(value >> 1);
 1366|       |    
 1367|  2.93M|    return true;
 1368|  2.93M|}
pb_decode_fixed32:
 1371|   116k|{
 1372|   116k|    union {
 1373|   116k|        uint32_t fixed32;
 1374|   116k|        pb_byte_t bytes[4];
 1375|   116k|    } u;
 1376|       |
 1377|   116k|    if (!pb_read(stream, u.bytes, 4))
  ------------------
  |  Branch (1377:9): [True: 15, False: 116k]
  ------------------
 1378|     15|        return false;
 1379|       |
 1380|       |#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1381|       |    /* fast path - if we know that we're on little endian, assign directly */
 1382|       |    *(uint32_t*)dest = u.fixed32;
 1383|       |#else
 1384|   116k|    *(uint32_t*)dest = ((uint32_t)u.bytes[0] << 0) |
 1385|   116k|                       ((uint32_t)u.bytes[1] << 8) |
 1386|   116k|                       ((uint32_t)u.bytes[2] << 16) |
 1387|   116k|                       ((uint32_t)u.bytes[3] << 24);
 1388|   116k|#endif
 1389|   116k|    return true;
 1390|   116k|}
pb_decode_fixed64:
 1394|  51.6k|{
 1395|  51.6k|    union {
 1396|  51.6k|        uint64_t fixed64;
 1397|  51.6k|        pb_byte_t bytes[8];
 1398|  51.6k|    } u;
 1399|       |
 1400|  51.6k|    if (!pb_read(stream, u.bytes, 8))
  ------------------
  |  Branch (1400:9): [True: 19, False: 51.6k]
  ------------------
 1401|     19|        return false;
 1402|       |
 1403|       |#if defined(PB_LITTLE_ENDIAN_8BIT) && PB_LITTLE_ENDIAN_8BIT == 1
 1404|       |    /* fast path - if we know that we're on little endian, assign directly */
 1405|       |    *(uint64_t*)dest = u.fixed64;
 1406|       |#else
 1407|  51.6k|    *(uint64_t*)dest = ((uint64_t)u.bytes[0] << 0) |
 1408|  51.6k|                       ((uint64_t)u.bytes[1] << 8) |
 1409|  51.6k|                       ((uint64_t)u.bytes[2] << 16) |
 1410|  51.6k|                       ((uint64_t)u.bytes[3] << 24) |
 1411|  51.6k|                       ((uint64_t)u.bytes[4] << 32) |
 1412|  51.6k|                       ((uint64_t)u.bytes[5] << 40) |
 1413|  51.6k|                       ((uint64_t)u.bytes[6] << 48) |
 1414|  51.6k|                       ((uint64_t)u.bytes[7] << 56);
 1415|  51.6k|#endif
 1416|  51.6k|    return true;
 1417|  51.6k|}
pb_decode.c:buf_read:
   70|  73.2M|{
   71|  73.2M|    const pb_byte_t *source = (const pb_byte_t*)stream->state;
   72|  73.2M|    stream->state = (pb_byte_t*)stream->state + count;
   73|       |    
   74|  73.2M|    if (buf != NULL)
  ------------------
  |  Branch (74:9): [True: 73.1M, False: 86.9k]
  ------------------
   75|  73.1M|    {
   76|  73.1M|        memcpy(buf, source, count * sizeof(pb_byte_t));
   77|  73.1M|    }
   78|       |    
   79|  73.2M|    return true;
   80|  73.2M|}
pb_decode.c:pb_decode_varint32_eof:
  172|  63.3M|{
  173|  63.3M|    pb_byte_t byte;
  174|  63.3M|    uint32_t result;
  175|       |    
  176|  63.3M|    if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (176:9): [True: 1.78k, False: 63.3M]
  ------------------
  177|  1.78k|    {
  178|  1.78k|        if (stream->bytes_left == 0)
  ------------------
  |  Branch (178:13): [True: 1.78k, False: 0]
  ------------------
  179|  1.78k|        {
  180|  1.78k|            if (eof)
  ------------------
  |  Branch (180:17): [True: 1.54k, False: 236]
  ------------------
  181|  1.54k|            {
  182|  1.54k|                *eof = true;
  183|  1.54k|            }
  184|  1.78k|        }
  185|       |
  186|  1.78k|        return false;
  187|  1.78k|    }
  188|       |    
  189|  63.3M|    if ((byte & 0x80) == 0)
  ------------------
  |  Branch (189:9): [True: 34.6M, False: 28.7M]
  ------------------
  190|  34.6M|    {
  191|       |        /* Quick case, 1 byte value */
  192|  34.6M|        result = byte;
  193|  34.6M|    }
  194|  28.7M|    else
  195|  28.7M|    {
  196|       |        /* Multibyte case */
  197|  28.7M|        uint_fast8_t bitpos = 7;
  198|  28.7M|        result = byte & 0x7F;
  199|       |        
  200|  28.7M|        do
  201|  28.8M|        {
  202|  28.8M|            if (!pb_readbyte(stream, &byte))
  ------------------
  |  Branch (202:17): [True: 53, False: 28.8M]
  ------------------
  203|     53|                return false;
  204|       |            
  205|  28.8M|            if (bitpos >= 32)
  ------------------
  |  Branch (205:17): [True: 12.0k, False: 28.8M]
  ------------------
  206|  12.0k|            {
  207|       |                /* Note: The varint could have trailing 0x80 bytes, or 0xFF for negative. */
  208|  12.0k|                pb_byte_t sign_extension = (bitpos < 63) ? 0xFF : 0x01;
  ------------------
  |  Branch (208:44): [True: 10.2k, False: 1.82k]
  ------------------
  209|  12.0k|                bool valid_extension = ((byte & 0x7F) == 0x00 ||
  ------------------
  |  Branch (209:41): [True: 1.95k, False: 10.0k]
  ------------------
  210|  12.0k|                         ((result >> 31) != 0 && byte == sign_extension));
  ------------------
  |  Branch (210:27): [True: 10.0k, False: 7]
  |  Branch (210:50): [True: 10.0k, False: 55]
  ------------------
  211|       |
  212|  12.0k|                if (bitpos >= 64 || !valid_extension)
  ------------------
  |  Branch (212:21): [True: 3, False: 12.0k]
  |  Branch (212:37): [True: 61, False: 11.9k]
  ------------------
  213|     64|                {
  214|     64|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  894|     64|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     64|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 64]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  215|     64|                }
  216|  12.0k|            }
  217|  28.8M|            else if (bitpos == 28)
  ------------------
  |  Branch (217:22): [True: 6.18k, False: 28.8M]
  ------------------
  218|  6.18k|            {
  219|  6.18k|                if ((byte & 0x70) != 0 && (byte & 0x78) != 0x78)
  ------------------
  |  Branch (219:21): [True: 4.23k, False: 1.94k]
  |  Branch (219:43): [True: 17, False: 4.21k]
  ------------------
  220|     17|                {
  221|     17|                    PB_RETURN_ERROR(stream, "varint overflow");
  ------------------
  |  |  894|     17|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     17|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  222|     17|                }
  223|  6.16k|                result |= (uint32_t)(byte & 0x0F) << bitpos;
  224|  6.16k|            }
  225|  28.8M|            else
  226|  28.8M|            {
  227|  28.8M|                result |= (uint32_t)(byte & 0x7F) << bitpos;
  228|  28.8M|            }
  229|  28.8M|            bitpos = (uint_fast8_t)(bitpos + 7);
  230|  28.8M|        } while (byte & 0x80);
  ------------------
  |  Branch (230:18): [True: 105k, False: 28.7M]
  ------------------
  231|  28.7M|   }
  232|       |   
  233|  63.3M|   *dest = result;
  234|  63.3M|   return true;
  235|  63.3M|}
pb_decode.c:pb_readbyte:
  126|   101M|{
  127|   101M|    if (stream->bytes_left == 0)
  ------------------
  |  Branch (127:9): [True: 373, False: 101M]
  ------------------
  128|    373|        PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  894|    373|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|    373|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 373]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  129|       |
  130|   101M|#ifndef PB_BUFFER_ONLY
  131|   101M|    if (!stream->callback(stream, buf, 1))
  ------------------
  |  Branch (131:9): [True: 1.54k, False: 101M]
  ------------------
  132|  1.54k|        PB_RETURN_ERROR(stream, "io error");
  ------------------
  |  |  894|  1.54k|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|  1.54k|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 1.54k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  133|       |#else
  134|       |    *buf = *(const pb_byte_t*)stream->state;
  135|       |    stream->state = (pb_byte_t*)stream->state + 1;
  136|       |#endif
  137|       |
  138|   101M|    stream->bytes_left--;
  139|       |    
  140|   101M|    return true;    
  141|   101M|}
pb_decode.c:pb_skip_varint:
  267|   241k|{
  268|   241k|    pb_byte_t byte;
  269|   241k|    do
  270|  1.05M|    {
  271|  1.05M|        if (!pb_read(stream, &byte, 1))
  ------------------
  |  Branch (271:13): [True: 68, False: 1.05M]
  ------------------
  272|     68|            return false;
  273|  1.05M|    } while (byte & 0x80);
  ------------------
  |  Branch (273:14): [True: 809k, False: 241k]
  ------------------
  274|   241k|    return true;
  275|   241k|}
pb_decode.c:pb_skip_string:
  278|   207k|{
  279|   207k|    uint32_t length;
  280|   207k|    if (!pb_decode_varint32(stream, &length))
  ------------------
  |  Branch (280:9): [True: 46, False: 207k]
  ------------------
  281|     46|        return false;
  282|       |    
  283|   207k|    if ((size_t)length != length)
  ------------------
  |  Branch (283:9): [True: 0, False: 207k]
  ------------------
  284|      0|    {
  285|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  286|      0|    }
  287|       |
  288|   207k|    return pb_read(stream, NULL, (size_t)length);
  289|   207k|}
pb_decode.c:pb_decode_inner:
  991|   307k|{
  992|   307k|    uint32_t extension_range_start = 0;
  993|   307k|    pb_extension_t *extensions = NULL;
  994|       |
  995|       |    /* 'fixed_count_field' and 'fixed_count_size' track position of a repeated fixed
  996|       |     * count field. This can only handle _one_ repeated fixed count field that
  997|       |     * is unpacked and unordered among other (non repeated fixed count) fields.
  998|       |     */
  999|   307k|    pb_size_t fixed_count_field = PB_SIZE_MAX;
  ------------------
  |  |  313|   307k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
 1000|   307k|    pb_size_t fixed_count_size = 0;
 1001|   307k|    pb_size_t fixed_count_total_size = 0;
 1002|       |
 1003|   307k|    pb_fields_seen_t fields_seen = {{0, 0}};
 1004|   307k|    const uint32_t allbits = ~(uint32_t)0;
 1005|   307k|    pb_field_iter_t iter;
 1006|       |
 1007|   307k|    if (pb_field_iter_begin(&iter, fields, dest_struct))
  ------------------
  |  Branch (1007:9): [True: 103k, False: 203k]
  ------------------
 1008|   103k|    {
 1009|   103k|        if ((flags & PB_DECODE_NOINIT) == 0)
  ------------------
  |  |   99|   103k|#define PB_DECODE_NOINIT          0x01U
  ------------------
  |  Branch (1009:13): [True: 95.0k, False: 8.94k]
  ------------------
 1010|  95.0k|        {
 1011|  95.0k|            if (!pb_message_set_to_defaults(&iter))
  ------------------
  |  Branch (1011:17): [True: 0, False: 95.0k]
  ------------------
 1012|      0|                PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1013|  95.0k|        }
 1014|   103k|    }
 1015|       |
 1016|  30.9M|    while (stream->bytes_left)
  ------------------
  |  Branch (1016:12): [True: 30.6M, False: 304k]
  ------------------
 1017|  30.6M|    {
 1018|  30.6M|        uint32_t tag;
 1019|  30.6M|        pb_wire_type_t wire_type;
 1020|  30.6M|        bool eof;
 1021|       |
 1022|  30.6M|        if (!pb_decode_tag(stream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (1022:13): [True: 1.63k, False: 30.6M]
  ------------------
 1023|  1.63k|        {
 1024|  1.63k|            if (eof)
  ------------------
  |  Branch (1024:17): [True: 1.54k, False: 89]
  ------------------
 1025|  1.54k|                break;
 1026|     89|            else
 1027|     89|                return false;
 1028|  1.63k|        }
 1029|       |
 1030|  30.6M|        if (tag == 0)
  ------------------
  |  Branch (1030:13): [True: 66, False: 30.6M]
  ------------------
 1031|     66|        {
 1032|     66|          if (flags & PB_DECODE_NULLTERMINATED)
  ------------------
  |  |  101|     66|#define PB_DECODE_NULLTERMINATED  0x04U
  ------------------
  |  Branch (1032:15): [True: 0, False: 66]
  ------------------
 1033|      0|          {
 1034|      0|            break;
 1035|      0|          }
 1036|     66|          else
 1037|     66|          {
 1038|     66|            PB_RETURN_ERROR(stream, "zero tag");
  ------------------
  |  |  894|     66|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     66|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 66]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1039|     66|          }
 1040|     66|        }
 1041|       |
 1042|  30.6M|        if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  299|  30.0M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  30.0M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (!pb_field_iter_find(&iter, tag) || PB_LTYPE(iter.type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  268|  30.0M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1042:13): [True: 547k, False: 30.0M]
  |  Branch (1042:48): [True: 661, False: 30.0M]
  ------------------
 1043|   548k|        {
 1044|       |            /* No match found, check if it matches an extension. */
 1045|   548k|            if (extension_range_start == 0)
  ------------------
  |  Branch (1045:17): [True: 8.15k, False: 540k]
  ------------------
 1046|  8.15k|            {
 1047|  8.15k|                if (pb_field_iter_find_extension(&iter))
  ------------------
  |  Branch (1047:21): [True: 3.45k, False: 4.70k]
  ------------------
 1048|  3.45k|                {
 1049|  3.45k|                    extensions = *(pb_extension_t* const *)iter.pData;
 1050|  3.45k|                    extension_range_start = iter.tag;
 1051|  3.45k|                }
 1052|       |
 1053|  8.15k|                if (!extensions)
  ------------------
  |  Branch (1053:21): [True: 5.24k, False: 2.91k]
  ------------------
 1054|  5.24k|                {
 1055|  5.24k|                    extension_range_start = (uint32_t)-1;
 1056|  5.24k|                }
 1057|  8.15k|            }
 1058|       |
 1059|   548k|            if (tag >= extension_range_start)
  ------------------
  |  Branch (1059:17): [True: 78.8k, False: 469k]
  ------------------
 1060|  78.8k|            {
 1061|  78.8k|                size_t pos = stream->bytes_left;
 1062|       |
 1063|  78.8k|                if (!decode_extension(stream, tag, wire_type, extensions))
  ------------------
  |  Branch (1063:21): [True: 119, False: 78.7k]
  ------------------
 1064|    119|                    return false;
 1065|       |
 1066|  78.7k|                if (pos != stream->bytes_left)
  ------------------
  |  Branch (1066:21): [True: 5.50k, False: 73.2k]
  ------------------
 1067|  5.50k|                {
 1068|       |                    /* The field was handled */
 1069|  5.50k|                    continue;
 1070|  5.50k|                }
 1071|  78.7k|            }
 1072|       |
 1073|       |            /* No match found, skip data */
 1074|   542k|            if (!pb_skip_field(stream, wire_type))
  ------------------
  |  Branch (1074:17): [True: 300, False: 542k]
  ------------------
 1075|    300|                return false;
 1076|   542k|            continue;
 1077|   542k|        }
 1078|       |
 1079|       |        /* If a repeated fixed count field was found, get size from
 1080|       |         * 'fixed_count_field' as there is no counter contained in the struct.
 1081|       |         */
 1082|  30.0M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  298|  30.0M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  30.0M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REPEATED && iter.pSize == &iter.array_size)
  ------------------
  |  |  285|  60.1M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1082:13): [True: 27.9M, False: 2.07M]
  |  Branch (1082:57): [True: 886, False: 27.9M]
  ------------------
 1083|    886|        {
 1084|    886|            if (fixed_count_field != iter.index) {
  ------------------
  |  Branch (1084:17): [True: 662, False: 224]
  ------------------
 1085|       |                /* If the new fixed count field does not match the previous one,
 1086|       |                 * check that the previous one is NULL or that it finished
 1087|       |                 * receiving all the expected data.
 1088|       |                 */
 1089|    662|                if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  313|  1.32k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1089:21): [True: 323, False: 339]
  ------------------
 1090|    662|                    fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1090:21): [True: 31, False: 292]
  ------------------
 1091|     31|                {
 1092|     31|                    PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  894|     31|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     31|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1093|     31|                }
 1094|       |
 1095|    631|                fixed_count_field = iter.index;
 1096|    631|                fixed_count_size = 0;
 1097|    631|                fixed_count_total_size = iter.array_size;
 1098|    631|            }
 1099|       |
 1100|    855|            iter.pSize = &fixed_count_size;
 1101|    855|        }
 1102|       |
 1103|  30.0M|        if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  298|  30.0M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  30.0M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter.type) == PB_HTYPE_REQUIRED
  ------------------
  |  |  282|  60.1M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (1103:13): [True: 2.03M, False: 28.0M]
  ------------------
 1104|  30.0M|            && iter.required_field_index < PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  204|  2.03M|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1104:16): [True: 2.03M, False: 0]
  ------------------
 1105|  2.03M|        {
 1106|  2.03M|            uint32_t tmp = ((uint32_t)1 << (iter.required_field_index & 31));
 1107|  2.03M|            fields_seen.bitfield[iter.required_field_index >> 5] |= tmp;
 1108|  2.03M|        }
 1109|       |
 1110|  30.0M|        if (!decode_field(stream, wire_type, &iter))
  ------------------
  |  Branch (1110:13): [True: 1.30k, False: 30.0M]
  ------------------
 1111|  1.30k|            return false;
 1112|  30.0M|    }
 1113|       |
 1114|       |    /* Check that all elements of the last decoded fixed count field were present. */
 1115|   305k|    if (fixed_count_field != PB_SIZE_MAX &&
  ------------------
  |  |  313|   611k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1115:9): [True: 257, False: 305k]
  ------------------
 1116|   305k|        fixed_count_size != fixed_count_total_size)
  ------------------
  |  Branch (1116:9): [True: 30, False: 227]
  ------------------
 1117|     30|    {
 1118|     30|        PB_RETURN_ERROR(stream, "wrong size for fixed count field");
  ------------------
  |  |  894|     30|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     30|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 30]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1119|     30|    }
 1120|       |
 1121|       |    /* Check that all required fields were present. */
 1122|   305k|    {
 1123|   305k|        pb_size_t req_field_count = iter.descriptor->required_field_count;
 1124|       |
 1125|   305k|        if (req_field_count > 0)
  ------------------
  |  Branch (1125:13): [True: 96.5k, False: 209k]
  ------------------
 1126|  96.5k|        {
 1127|  96.5k|            pb_size_t i;
 1128|       |
 1129|  96.5k|            if (req_field_count > PB_MAX_REQUIRED_FIELDS)
  ------------------
  |  |  204|  96.5k|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
  |  Branch (1129:17): [True: 0, False: 96.5k]
  ------------------
 1130|      0|                req_field_count = PB_MAX_REQUIRED_FIELDS;
  ------------------
  |  |  204|      0|#define PB_MAX_REQUIRED_FIELDS 64
  ------------------
 1131|       |
 1132|       |            /* Check the whole words */
 1133|  96.5k|            for (i = 0; i < (req_field_count >> 5); i++)
  ------------------
  |  Branch (1133:25): [True: 0, False: 96.5k]
  ------------------
 1134|      0|            {
 1135|      0|                if (fields_seen.bitfield[i] != allbits)
  ------------------
  |  Branch (1135:21): [True: 0, False: 0]
  ------------------
 1136|      0|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1137|      0|            }
 1138|       |
 1139|       |            /* Check the remaining bits (if any) */
 1140|  96.5k|            if ((req_field_count & 31) != 0)
  ------------------
  |  Branch (1140:17): [True: 96.5k, False: 0]
  ------------------
 1141|  96.5k|            {
 1142|  96.5k|                if (fields_seen.bitfield[req_field_count >> 5] !=
  ------------------
  |  Branch (1142:21): [True: 536, False: 96.0k]
  ------------------
 1143|  96.5k|                    (allbits >> (uint_least8_t)(32 - (req_field_count & 31))))
 1144|    536|                {
 1145|    536|                    PB_RETURN_ERROR(stream, "missing required field");
  ------------------
  |  |  894|    536|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|    536|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 536]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1146|    536|                }
 1147|  96.5k|            }
 1148|  96.5k|        }
 1149|   305k|    }
 1150|       |
 1151|   305k|    return true;
 1152|   305k|}
pb_decode.c:pb_message_set_to_defaults:
  952|   101k|{
  953|   101k|    pb_istream_t defstream = PB_ISTREAM_EMPTY;
  ------------------
  |  |   49|   101k|#define PB_ISTREAM_EMPTY {0,0,0,0}
  ------------------
  954|   101k|    uint32_t tag = 0;
  955|   101k|    pb_wire_type_t wire_type = PB_WT_VARINT;
  956|   101k|    bool eof;
  957|       |
  958|   101k|    if (iter->descriptor->default_value)
  ------------------
  |  Branch (958:9): [True: 0, False: 101k]
  ------------------
  959|      0|    {
  960|      0|        defstream = pb_istream_from_buffer(iter->descriptor->default_value, (size_t)-1);
  961|      0|        if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (961:13): [True: 0, False: 0]
  ------------------
  962|      0|            return false;
  963|      0|    }
  964|       |
  965|   101k|    do
  966|   912k|    {
  967|   912k|        if (!pb_field_set_to_default(iter))
  ------------------
  |  Branch (967:13): [True: 0, False: 912k]
  ------------------
  968|      0|            return false;
  969|       |
  970|   912k|        if (tag != 0 && iter->tag == tag)
  ------------------
  |  Branch (970:13): [True: 0, False: 912k]
  |  Branch (970:25): [True: 0, False: 0]
  ------------------
  971|      0|        {
  972|       |            /* We have a default value for this field in the defstream */
  973|      0|            if (!decode_field(&defstream, wire_type, iter))
  ------------------
  |  Branch (973:17): [True: 0, False: 0]
  ------------------
  974|      0|                return false;
  975|      0|            if (!pb_decode_tag(&defstream, &wire_type, &tag, &eof))
  ------------------
  |  Branch (975:17): [True: 0, False: 0]
  ------------------
  976|      0|                return false;
  977|       |
  978|      0|            if (iter->pSize)
  ------------------
  |  Branch (978:17): [True: 0, False: 0]
  ------------------
  979|      0|                *(bool*)iter->pSize = false;
  980|      0|        }
  981|   912k|    } while (pb_field_iter_next(iter));
  ------------------
  |  Branch (981:14): [True: 810k, False: 101k]
  ------------------
  982|       |
  983|   101k|    return true;
  984|   101k|}
pb_decode.c:pb_field_set_to_default:
  870|   912k|{
  871|   912k|    pb_type_t type;
  872|   912k|    type = field->type;
  873|       |
  874|   912k|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  299|   912k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   912k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  268|   912k|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (874:9): [True: 8.10k, False: 904k]
  ------------------
  875|  8.10k|    {
  876|  8.10k|        pb_extension_t *ext = *(pb_extension_t* const *)field->pData;
  877|  14.6k|        while (ext != NULL)
  ------------------
  |  Branch (877:16): [True: 6.55k, False: 8.10k]
  ------------------
  878|  6.55k|        {
  879|  6.55k|            pb_field_iter_t ext_iter;
  880|  6.55k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (880:17): [True: 6.55k, False: 0]
  ------------------
  881|  6.55k|            {
  882|  6.55k|                ext->found = false;
  883|  6.55k|                if (!pb_message_set_to_defaults(&ext_iter))
  ------------------
  |  Branch (883:21): [True: 0, False: 6.55k]
  ------------------
  884|      0|                    return false;
  885|  6.55k|            }
  886|  6.55k|            ext = ext->next;
  887|  6.55k|        }
  888|  8.10k|    }
  889|   904k|    else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  297|   904k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|   904k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_STATIC)
  ------------------
  |  |  292|   904k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (889:14): [True: 14.6k, False: 889k]
  ------------------
  890|  14.6k|    {
  891|  14.6k|        bool init_data = true;
  892|  14.6k|        if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  298|  14.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  14.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_OPTIONAL && field->pSize != NULL)
  ------------------
  |  |  283|  29.3k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (892:13): [True: 0, False: 14.6k]
  |  Branch (892:52): [True: 0, False: 0]
  ------------------
  893|      0|        {
  894|       |            /* Set has_field to false. Still initialize the optional field
  895|       |             * itself also. */
  896|      0|            *(bool*)field->pSize = false;
  897|      0|        }
  898|  14.6k|        else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  298|  14.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  14.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      else if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  285|  29.3k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (898:18): [True: 0, False: 14.6k]
  ------------------
  899|  14.6k|                 PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  298|  14.6k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  14.6k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                               PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|  14.6k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (899:18): [True: 8.10k, False: 6.55k]
  ------------------
  900|  8.10k|        {
  901|       |            /* REPEATED: Set array count to 0, no need to initialize contents.
  902|       |               ONEOF: Set which_field to 0. */
  903|  8.10k|            *(pb_size_t*)field->pSize = 0;
  904|  8.10k|            init_data = false;
  905|  8.10k|        }
  906|       |
  907|  14.6k|        if (init_data)
  ------------------
  |  Branch (907:13): [True: 6.55k, False: 8.10k]
  ------------------
  908|  6.55k|        {
  909|  6.55k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  300|  13.1k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|  6.55k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  6.55k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|  13.1k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 6.55k, False: 0]
  |  |  ------------------
  |  |  301|  13.1k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|      0|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  910|  6.55k|                (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (910:18): [True: 0, False: 6.55k]
  ------------------
  911|  6.55k|                 field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (911:18): [True: 0, False: 6.55k]
  ------------------
  912|  6.55k|                 field->submsg_desc->submsg_info[0] != NULL))
  ------------------
  |  Branch (912:18): [True: 0, False: 6.55k]
  ------------------
  913|      0|            {
  914|       |                /* Initialize submessage to defaults.
  915|       |                 * Only needed if it has default values
  916|       |                 * or callback/submessage fields. */
  917|      0|                pb_field_iter_t submsg_iter;
  918|      0|                if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (918:21): [True: 0, False: 0]
  ------------------
  919|      0|                {
  920|      0|                    if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (920:25): [True: 0, False: 0]
  ------------------
  921|      0|                        return false;
  922|      0|                }
  923|      0|            }
  924|  6.55k|            else
  925|  6.55k|            {
  926|       |                /* Initialize to zeros */
  927|  6.55k|                memset(field->pData, 0, (size_t)field->data_size);
  928|  6.55k|            }
  929|  6.55k|        }
  930|  14.6k|    }
  931|   889k|    else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  297|   889k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|   889k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  293|   889k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (931:14): [True: 889k, False: 0]
  ------------------
  932|   889k|    {
  933|       |        /* Initialize the pointer to NULL. */
  934|   889k|        *(void**)field->pField = NULL;
  935|       |
  936|       |        /* Initialize array count to 0. */
  937|   889k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  298|   889k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   889k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED ||
  ------------------
  |  |  285|  1.77M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (937:13): [True: 170k, False: 719k]
  ------------------
  938|   889k|            PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  298|   719k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   719k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|   719k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (938:13): [True: 16.2k, False: 703k]
  ------------------
  939|   186k|        {
  940|   186k|            *(pb_size_t*)field->pSize = 0;
  941|   186k|        }
  942|   889k|    }
  943|      0|    else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  297|      0|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|      0|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_ATYPE(type) == PB_ATYPE_CALLBACK)
  ------------------
  |  |  294|      0|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (943:14): [True: 0, False: 0]
  ------------------
  944|      0|    {
  945|       |        /* Don't overwrite callback */
  946|      0|    }
  947|       |
  948|   912k|    return true;
  949|   912k|}
pb_decode.c:decode_extension:
  848|  78.8k|{
  849|  78.8k|    size_t pos = stream->bytes_left;
  850|       |    
  851|   157k|    while (extension != NULL && pos == stream->bytes_left)
  ------------------
  |  Branch (851:12): [True: 78.8k, False: 78.7k]
  |  Branch (851:33): [True: 78.8k, False: 0]
  ------------------
  852|  78.8k|    {
  853|  78.8k|        bool status;
  854|  78.8k|        if (extension->type->decode)
  ------------------
  |  Branch (854:13): [True: 0, False: 78.8k]
  ------------------
  855|      0|            status = extension->type->decode(stream, extension, tag, wire_type);
  856|  78.8k|        else
  857|  78.8k|            status = default_extension_decoder(stream, extension, tag, wire_type);
  858|       |
  859|  78.8k|        if (!status)
  ------------------
  |  Branch (859:13): [True: 119, False: 78.7k]
  ------------------
  860|    119|            return false;
  861|       |        
  862|  78.7k|        extension = extension->next;
  863|  78.7k|    }
  864|       |    
  865|  78.7k|    return true;
  866|  78.8k|}
pb_decode.c:default_extension_decoder:
  831|  78.8k|{
  832|  78.8k|    pb_field_iter_t iter;
  833|       |
  834|  78.8k|    if (!pb_field_iter_begin_extension(&iter, extension))
  ------------------
  |  Branch (834:9): [True: 0, False: 78.8k]
  ------------------
  835|      0|        PB_RETURN_ERROR(stream, "invalid extension");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  836|       |
  837|  78.8k|    if (iter.tag != tag || !iter.message)
  ------------------
  |  Branch (837:9): [True: 73.2k, False: 5.62k]
  |  Branch (837:28): [True: 0, False: 5.62k]
  ------------------
  838|  73.2k|        return true;
  839|       |
  840|  5.62k|    extension->found = true;
  841|  5.62k|    return decode_field(stream, wire_type, &iter);
  842|  78.8k|}
pb_decode.c:decode_field:
  799|  30.0M|{
  800|  30.0M|#ifdef PB_ENABLE_MALLOC
  801|       |    /* When decoding an oneof field, check if there is old data that must be
  802|       |     * released first. */
  803|  30.0M|    if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  298|  30.0M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  30.0M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|  30.0M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (803:9): [True: 22.8k, False: 30.0M]
  ------------------
  804|  22.8k|    {
  805|  22.8k|        if (!pb_release_union_field(stream, field))
  ------------------
  |  Branch (805:13): [True: 0, False: 22.8k]
  ------------------
  806|      0|            return false;
  807|  22.8k|    }
  808|  30.0M|#endif
  809|       |
  810|  30.0M|    switch (PB_ATYPE(field->type))
  ------------------
  |  |  297|  30.0M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  30.0M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
  811|  30.0M|    {
  812|  11.8k|        case PB_ATYPE_STATIC:
  ------------------
  |  |  292|  11.8k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (812:9): [True: 11.8k, False: 30.0M]
  ------------------
  813|  11.8k|            return decode_static_field(stream, wire_type, field);
  814|       |        
  815|  30.0M|        case PB_ATYPE_POINTER:
  ------------------
  |  |  293|  30.0M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (815:9): [True: 30.0M, False: 11.8k]
  ------------------
  816|  30.0M|            return decode_pointer_field(stream, wire_type, field);
  817|       |        
  818|      0|        case PB_ATYPE_CALLBACK:
  ------------------
  |  |  294|      0|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (818:9): [True: 0, False: 30.0M]
  ------------------
  819|      0|            return decode_callback_field(stream, wire_type, field);
  820|       |        
  821|      0|        default:
  ------------------
  |  Branch (821:9): [True: 0, False: 30.0M]
  ------------------
  822|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  823|  30.0M|    }
  824|  30.0M|}
pb_decode.c:pb_release_union_field:
 1200|  22.8k|{
 1201|  22.8k|    pb_field_iter_t old_field = *field;
 1202|  22.8k|    pb_size_t old_tag = *(pb_size_t*)field->pSize; /* Previous which_ value */
 1203|  22.8k|    pb_size_t new_tag = field->tag; /* New which_ value */
 1204|       |
 1205|  22.8k|    if (old_tag == 0)
  ------------------
  |  Branch (1205:9): [True: 641, False: 22.2k]
  ------------------
 1206|    641|        return true; /* Ok, no old data in union */
 1207|       |
 1208|  22.2k|    if (old_tag == new_tag)
  ------------------
  |  Branch (1208:9): [True: 11.7k, False: 10.4k]
  ------------------
 1209|  11.7k|        return true; /* Ok, old data is of same type => merge */
 1210|       |
 1211|       |    /* Release old data. The find can fail if the message struct contains
 1212|       |     * invalid data. */
 1213|  10.4k|    if (!pb_field_iter_find(&old_field, old_tag))
  ------------------
  |  Branch (1213:9): [True: 0, False: 10.4k]
  ------------------
 1214|      0|        PB_RETURN_ERROR(stream, "invalid union tag");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1215|       |
 1216|  10.4k|    pb_release_single_field(&old_field);
 1217|       |
 1218|  10.4k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  297|  10.4k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  10.4k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  293|  10.4k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1218:9): [True: 7.69k, False: 2.74k]
  ------------------
 1219|  7.69k|    {
 1220|       |        /* Initialize the pointer to NULL to make sure it is valid
 1221|       |         * even in case of error return. */
 1222|  7.69k|        *(void**)field->pField = NULL;
 1223|  7.69k|        field->pData = NULL;
 1224|  7.69k|    }
 1225|       |
 1226|  10.4k|    return true;
 1227|  10.4k|}
pb_decode.c:decode_static_field:
  468|  11.8k|{
  469|  11.8k|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  298|  11.8k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  11.8k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  470|  11.8k|    {
  471|  5.62k|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  282|  5.62k|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (471:9): [True: 5.62k, False: 6.23k]
  ------------------
  472|  5.62k|            return decode_basic_field(stream, wire_type, field);
  473|       |            
  474|  2.85k|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  283|  2.85k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (474:9): [True: 2.85k, False: 9.01k]
  ------------------
  475|  2.85k|            if (field->pSize != NULL)
  ------------------
  |  Branch (475:17): [True: 2.85k, False: 0]
  ------------------
  476|  2.85k|                *(bool*)field->pSize = true;
  477|  2.85k|            return decode_basic_field(stream, wire_type, field);
  478|       |    
  479|      0|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  285|      0|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (479:9): [True: 0, False: 11.8k]
  ------------------
  480|      0|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (480:17): [True: 0, False: 0]
  ------------------
  481|      0|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  299|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  247|      0|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (481:20): [True: 0, False: 0]
  ------------------
  482|      0|            {
  483|       |                /* Packed array */
  484|      0|                bool status = true;
  485|      0|                pb_istream_t substream;
  486|      0|                pb_size_t *size = (pb_size_t*)field->pSize;
  487|      0|                field->pData = (char*)field->pField + field->data_size * (*size);
  488|       |
  489|      0|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (489:21): [True: 0, False: 0]
  ------------------
  490|      0|                    return false;
  491|       |
  492|      0|                while (substream.bytes_left > 0 && *size < field->array_size)
  ------------------
  |  Branch (492:24): [True: 0, False: 0]
  |  Branch (492:52): [True: 0, False: 0]
  ------------------
  493|      0|                {
  494|      0|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (494:25): [True: 0, False: 0]
  ------------------
  495|      0|                    {
  496|      0|                        status = false;
  497|      0|                        break;
  498|      0|                    }
  499|      0|                    (*size)++;
  500|      0|                    field->pData = (char*)field->pData + field->data_size;
  501|      0|                }
  502|       |
  503|      0|                if (substream.bytes_left != 0)
  ------------------
  |  Branch (503:21): [True: 0, False: 0]
  ------------------
  504|      0|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  505|      0|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (505:21): [True: 0, False: 0]
  ------------------
  506|      0|                    return false;
  507|       |
  508|      0|                return status;
  509|      0|            }
  510|      0|            else
  511|      0|            {
  512|       |                /* Repeated field */
  513|      0|                pb_size_t *size = (pb_size_t*)field->pSize;
  514|      0|                field->pData = (char*)field->pField + field->data_size * (*size);
  515|       |
  516|      0|                if ((*size)++ >= field->array_size)
  ------------------
  |  Branch (516:21): [True: 0, False: 0]
  ------------------
  517|      0|                    PB_RETURN_ERROR(stream, "array overflow");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  518|       |
  519|      0|                return decode_basic_field(stream, wire_type, field);
  520|      0|            }
  521|       |
  522|  3.38k|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  287|  3.38k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (522:9): [True: 3.38k, False: 8.48k]
  ------------------
  523|  3.38k|            if (PB_LTYPE_IS_SUBMSG(field->type) &&
  ------------------
  |  |  300|  6.76k|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|  3.38k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  3.38k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|  6.76k|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 3.38k, False: 0]
  |  |  ------------------
  |  |  301|  6.76k|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|      0|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  524|  3.38k|                *(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (524:17): [True: 2.93k, False: 446]
  ------------------
  525|  2.93k|            {
  526|       |                /* We memset to zero so that any callbacks are set to NULL.
  527|       |                 * This is because the callbacks might otherwise have values
  528|       |                 * from some other union field.
  529|       |                 * If callbacks are needed inside oneof field, use .proto
  530|       |                 * option submsg_callback to have a separate callback function
  531|       |                 * that can set the fields before submessage is decoded.
  532|       |                 * pb_dec_submessage() will set any default values. */
  533|  2.93k|                memset(field->pData, 0, (size_t)field->data_size);
  534|       |
  535|       |                /* Set default values for the submessage fields. */
  536|  2.93k|                if (field->submsg_desc->default_value != NULL ||
  ------------------
  |  Branch (536:21): [True: 0, False: 2.93k]
  ------------------
  537|  2.93k|                    field->submsg_desc->field_callback != NULL ||
  ------------------
  |  Branch (537:21): [True: 0, False: 2.93k]
  ------------------
  538|  2.93k|                    field->submsg_desc->submsg_info[0] != NULL)
  ------------------
  |  Branch (538:21): [True: 0, False: 2.93k]
  ------------------
  539|      0|                {
  540|      0|                    pb_field_iter_t submsg_iter;
  541|      0|                    if (pb_field_iter_begin(&submsg_iter, field->submsg_desc, field->pData))
  ------------------
  |  Branch (541:25): [True: 0, False: 0]
  ------------------
  542|      0|                    {
  543|      0|                        if (!pb_message_set_to_defaults(&submsg_iter))
  ------------------
  |  Branch (543:29): [True: 0, False: 0]
  ------------------
  544|      0|                            PB_RETURN_ERROR(stream, "failed to set defaults");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  545|      0|                    }
  546|      0|                }
  547|  2.93k|            }
  548|  3.38k|            *(pb_size_t*)field->pSize = field->tag;
  549|       |
  550|  3.38k|            return decode_basic_field(stream, wire_type, field);
  551|       |
  552|      0|        default:
  ------------------
  |  Branch (552:9): [True: 0, False: 11.8k]
  ------------------
  553|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  554|  11.8k|    }
  555|  11.8k|}
pb_decode.c:decode_basic_field:
  397|  39.0M|{
  398|  39.0M|    switch (PB_LTYPE(field->type))
  ------------------
  |  |  299|  39.0M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  39.0M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
  399|  39.0M|    {
  400|  4.41M|        case PB_LTYPE_BOOL:
  ------------------
  |  |  239|  4.41M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (400:9): [True: 4.41M, False: 34.6M]
  ------------------
  401|  4.41M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (401:17): [True: 3.86M, False: 550k]
  |  Branch (401:46): [True: 20, False: 3.86M]
  ------------------
  402|     20|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  894|     20|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     20|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  403|       |
  404|  4.41M|            return pb_dec_bool(stream, field);
  405|       |
  406|  1.91M|        case PB_LTYPE_VARINT:
  ------------------
  |  |  240|  1.91M|#define PB_LTYPE_VARINT  0x01U /* int32, int64, enum, bool */
  ------------------
  |  Branch (406:9): [True: 1.91M, False: 37.1M]
  ------------------
  407|  3.41M|        case PB_LTYPE_UVARINT:
  ------------------
  |  |  241|  3.41M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (407:9): [True: 1.49M, False: 37.5M]
  ------------------
  408|  6.34M|        case PB_LTYPE_SVARINT:
  ------------------
  |  |  242|  6.34M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (408:9): [True: 2.93M, False: 36.1M]
  ------------------
  409|  6.34M|            if (wire_type != PB_WT_VARINT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (409:17): [True: 5.15M, False: 1.19M]
  |  Branch (409:46): [True: 58, False: 5.15M]
  ------------------
  410|     58|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  894|     58|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     58|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  411|       |
  412|  6.34M|            return pb_dec_varint(stream, field);
  413|       |
  414|   116k|        case PB_LTYPE_FIXED32:
  ------------------
  |  |  243|   116k|#define PB_LTYPE_FIXED32 0x04U /* fixed32, sfixed32, float */
  ------------------
  |  Branch (414:9): [True: 116k, False: 38.9M]
  ------------------
  415|   116k|            if (wire_type != PB_WT_32BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (415:17): [True: 13.4k, False: 103k]
  |  Branch (415:45): [True: 10, False: 13.3k]
  ------------------
  416|     10|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  894|     10|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     10|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  417|       |
  418|   116k|            return pb_decode_fixed32(stream, field->pData);
  419|       |
  420|  51.6k|        case PB_LTYPE_FIXED64:
  ------------------
  |  |  244|  51.6k|#define PB_LTYPE_FIXED64 0x05U /* fixed64, sfixed64, double */
  ------------------
  |  Branch (420:9): [True: 51.6k, False: 38.9M]
  ------------------
  421|  51.6k|            if (wire_type != PB_WT_64BIT && wire_type != PB_WT_PACKED)
  ------------------
  |  Branch (421:17): [True: 6.49k, False: 45.1k]
  |  Branch (421:45): [True: 13, False: 6.48k]
  ------------------
  422|     13|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  894|     13|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     13|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  423|       |
  424|       |#ifdef PB_CONVERT_DOUBLE_FLOAT
  425|       |            if (field->data_size == sizeof(float))
  426|       |            {
  427|       |                return pb_decode_double_as_float(stream, (float*)field->pData);
  428|       |            }
  429|       |#endif
  430|       |
  431|       |#ifdef PB_WITHOUT_64BIT
  432|       |            PB_RETURN_ERROR(stream, "invalid data_size");
  433|       |#else
  434|  51.6k|            return pb_decode_fixed64(stream, field->pData);
  435|      0|#endif
  436|       |
  437|   540k|        case PB_LTYPE_BYTES:
  ------------------
  |  |  251|   540k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (437:9): [True: 540k, False: 38.4M]
  ------------------
  438|   540k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (438:17): [True: 11, False: 540k]
  ------------------
  439|     11|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  894|     11|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     11|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  440|       |
  441|   540k|            return pb_dec_bytes(stream, field);
  442|       |
  443|  98.0k|        case PB_LTYPE_STRING:
  ------------------
  |  |  255|  98.0k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (443:9): [True: 98.0k, False: 38.9M]
  ------------------
  444|  98.0k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (444:17): [True: 12, False: 98.0k]
  ------------------
  445|     12|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  894|     12|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     12|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  446|       |
  447|  98.0k|            return pb_dec_string(stream, field);
  448|       |
  449|   299k|        case PB_LTYPE_SUBMESSAGE:
  ------------------
  |  |  259|   299k|#define PB_LTYPE_SUBMESSAGE 0x08U
  ------------------
  |  Branch (449:9): [True: 299k, False: 38.7M]
  ------------------
  450|   299k|        case PB_LTYPE_SUBMSG_W_CB:
  ------------------
  |  |  264|   299k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (450:9): [True: 0, False: 39.0M]
  ------------------
  451|   299k|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (451:17): [True: 28, False: 299k]
  ------------------
  452|     28|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  894|     28|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     28|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 28]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  453|       |
  454|   299k|            return pb_dec_submessage(stream, field);
  455|       |
  456|  27.1M|        case PB_LTYPE_FIXED_LENGTH_BYTES:
  ------------------
  |  |  274|  27.1M|#define PB_LTYPE_FIXED_LENGTH_BYTES 0x0BU
  ------------------
  |  Branch (456:9): [True: 27.1M, False: 11.8M]
  ------------------
  457|  27.1M|            if (wire_type != PB_WT_STRING)
  ------------------
  |  Branch (457:17): [True: 2, False: 27.1M]
  ------------------
  458|      2|                PB_RETURN_ERROR(stream, "wrong wire type");
  ------------------
  |  |  894|      2|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      2|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  459|       |
  460|  27.1M|            return pb_dec_fixed_length_bytes(stream, field);
  461|       |
  462|      0|        default:
  ------------------
  |  Branch (462:9): [True: 0, False: 39.0M]
  ------------------
  463|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  464|  39.0M|    }
  465|  39.0M|}
pb_decode.c:pb_dec_bool:
 1421|  4.41M|{
 1422|  4.41M|    return pb_decode_bool(stream, (bool*)field->pData);
 1423|  4.41M|}
pb_decode.c:pb_dec_varint:
 1426|  6.34M|{
 1427|  6.34M|    if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  299|  6.34M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  6.34M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_UVARINT)
  ------------------
  |  |  241|  6.34M|#define PB_LTYPE_UVARINT 0x02U /* uint32, uint64 */
  ------------------
  |  Branch (1427:9): [True: 1.49M, False: 4.85M]
  ------------------
 1428|  1.49M|    {
 1429|  1.49M|        pb_uint64_t value, clamped;
  ------------------
  |  |   58|  1.49M|#define pb_uint64_t uint64_t
  ------------------
 1430|  1.49M|        if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1430:13): [True: 34, False: 1.49M]
  ------------------
 1431|     34|            return false;
 1432|       |
 1433|       |        /* Cast to the proper field size, while checking for overflows */
 1434|  1.49M|        if (field->data_size == sizeof(pb_uint64_t))
  ------------------
  |  Branch (1434:13): [True: 693k, False: 802k]
  ------------------
 1435|   693k|            clamped = *(pb_uint64_t*)field->pData = value;
 1436|   802k|        else if (field->data_size == sizeof(uint32_t))
  ------------------
  |  Branch (1436:18): [True: 781k, False: 21.4k]
  ------------------
 1437|   781k|            clamped = *(uint32_t*)field->pData = (uint32_t)value;
 1438|  21.4k|        else if (field->data_size == sizeof(uint_least16_t))
  ------------------
  |  Branch (1438:18): [True: 10.6k, False: 10.7k]
  ------------------
 1439|  10.6k|            clamped = *(uint_least16_t*)field->pData = (uint_least16_t)value;
 1440|  10.7k|        else if (field->data_size == sizeof(uint_least8_t))
  ------------------
  |  Branch (1440:18): [True: 10.7k, False: 0]
  ------------------
 1441|  10.7k|            clamped = *(uint_least8_t*)field->pData = (uint_least8_t)value;
 1442|      0|        else
 1443|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1444|       |
 1445|  1.49M|        if (clamped != value)
  ------------------
  |  Branch (1445:13): [True: 106, False: 1.49M]
  ------------------
 1446|    106|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  894|    106|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|    106|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 106]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1447|       |
 1448|  1.49M|        return true;
 1449|  1.49M|    }
 1450|  4.85M|    else
 1451|  4.85M|    {
 1452|  4.85M|        pb_uint64_t value;
  ------------------
  |  |   58|  4.85M|#define pb_uint64_t uint64_t
  ------------------
 1453|  4.85M|        pb_int64_t svalue;
  ------------------
  |  |   57|  4.85M|#define pb_int64_t int64_t
  ------------------
 1454|  4.85M|        pb_int64_t clamped;
  ------------------
  |  |   57|  4.85M|#define pb_int64_t int64_t
  ------------------
 1455|       |
 1456|  4.85M|        if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  299|  4.85M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  4.85M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(field->type) == PB_LTYPE_SVARINT)
  ------------------
  |  |  242|  4.85M|#define PB_LTYPE_SVARINT 0x03U /* sint32, sint64 */
  ------------------
  |  Branch (1456:13): [True: 2.93M, False: 1.91M]
  ------------------
 1457|  2.93M|        {
 1458|  2.93M|            if (!pb_decode_svarint(stream, &svalue))
  ------------------
  |  Branch (1458:17): [True: 32, False: 2.93M]
  ------------------
 1459|     32|                return false;
 1460|  2.93M|        }
 1461|  1.91M|        else
 1462|  1.91M|        {
 1463|  1.91M|            if (!pb_decode_varint(stream, &value))
  ------------------
  |  Branch (1463:17): [True: 47, False: 1.91M]
  ------------------
 1464|     47|                return false;
 1465|       |
 1466|       |            /* See issue 97: Google's C++ protobuf allows negative varint values to
 1467|       |            * be cast as int32_t, instead of the int64_t that should be used when
 1468|       |            * encoding. Nanopb versions before 0.2.5 had a bug in encoding. In order to
 1469|       |            * not break decoding of such messages, we cast <=32 bit fields to
 1470|       |            * int32_t first to get the sign correct.
 1471|       |            */
 1472|  1.91M|            if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1472:17): [True: 602k, False: 1.31M]
  ------------------
 1473|   602k|                svalue = (pb_int64_t)value;
 1474|  1.31M|            else
 1475|  1.31M|                svalue = (int32_t)value;
 1476|  1.91M|        }
 1477|       |
 1478|       |        /* Cast to the proper field size, while checking for overflows */
 1479|  4.85M|        if (field->data_size == sizeof(pb_int64_t))
  ------------------
  |  Branch (1479:13): [True: 3.46M, False: 1.39M]
  ------------------
 1480|  3.46M|            clamped = *(pb_int64_t*)field->pData = svalue;
 1481|  1.39M|        else if (field->data_size == sizeof(int32_t))
  ------------------
  |  Branch (1481:18): [True: 1.34M, False: 42.3k]
  ------------------
 1482|  1.34M|            clamped = *(int32_t*)field->pData = (int32_t)svalue;
 1483|  42.3k|        else if (field->data_size == sizeof(int_least16_t))
  ------------------
  |  Branch (1483:18): [True: 21.1k, False: 21.1k]
  ------------------
 1484|  21.1k|            clamped = *(int_least16_t*)field->pData = (int_least16_t)svalue;
 1485|  21.1k|        else if (field->data_size == sizeof(int_least8_t))
  ------------------
  |  Branch (1485:18): [True: 21.1k, False: 0]
  ------------------
 1486|  21.1k|            clamped = *(int_least8_t*)field->pData = (int_least8_t)svalue;
 1487|      0|        else
 1488|      0|            PB_RETURN_ERROR(stream, "invalid data_size");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1489|       |
 1490|  4.85M|        if (clamped != svalue)
  ------------------
  |  Branch (1490:13): [True: 86, False: 4.85M]
  ------------------
 1491|     86|            PB_RETURN_ERROR(stream, "integer too large");
  ------------------
  |  |  894|     86|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     86|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 86]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1492|       |
 1493|  4.85M|        return true;
 1494|  4.85M|    }
 1495|  6.34M|}
pb_decode.c:pb_dec_bytes:
 1498|   540k|{
 1499|   540k|    uint32_t size;
 1500|   540k|    size_t alloc_size;
 1501|   540k|    pb_bytes_array_t *dest;
 1502|       |    
 1503|   540k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1503:9): [True: 17, False: 540k]
  ------------------
 1504|     17|        return false;
 1505|       |    
 1506|   540k|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  313|   540k|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1506:9): [True: 32, False: 540k]
  ------------------
 1507|     32|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  894|     32|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     32|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1508|       |    
 1509|   540k|    alloc_size = PB_BYTES_ARRAY_T_ALLOCSIZE(size);
  ------------------
  |  |  377|   540k|#define PB_BYTES_ARRAY_T_ALLOCSIZE(n) ((size_t)n + offsetof(pb_bytes_array_t, bytes))
  ------------------
 1510|   540k|    if (size > alloc_size)
  ------------------
  |  Branch (1510:9): [True: 0, False: 540k]
  ------------------
 1511|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1512|       |    
 1513|   540k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  297|   540k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|   540k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  293|   540k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1513:9): [True: 540k, False: 0]
  ------------------
 1514|   540k|    {
 1515|       |#ifndef PB_ENABLE_MALLOC
 1516|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1517|       |#else
 1518|   540k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1518:13): [True: 30, False: 540k]
  ------------------
 1519|     30|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  894|     30|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     30|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 30]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1520|       |
 1521|   540k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1521:13): [True: 0, False: 540k]
  ------------------
 1522|      0|            return false;
 1523|   540k|        dest = *(pb_bytes_array_t**)field->pData;
 1524|   540k|#endif
 1525|   540k|    }
 1526|      0|    else
 1527|      0|    {
 1528|      0|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1528:13): [True: 0, False: 0]
  ------------------
 1529|      0|            PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1530|      0|        dest = (pb_bytes_array_t*)field->pData;
 1531|      0|    }
 1532|       |
 1533|   540k|    dest->size = (pb_size_t)size;
 1534|   540k|    return pb_read(stream, dest->bytes, (size_t)size);
 1535|   540k|}
pb_decode.c:allocate_field:
  563|  31.5M|{    
  564|  31.5M|    void *ptr = *(void**)pData;
  565|       |    
  566|  31.5M|    if (data_size == 0 || array_size == 0)
  ------------------
  |  Branch (566:9): [True: 0, False: 31.5M]
  |  Branch (566:27): [True: 0, False: 31.5M]
  ------------------
  567|      0|        PB_RETURN_ERROR(stream, "invalid size");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  568|       |    
  569|       |#ifdef __AVR__
  570|       |    /* Workaround for AVR libc bug 53284: http://savannah.nongnu.org/bugs/?53284
  571|       |     * Realloc to size of 1 byte can cause corruption of the malloc structures.
  572|       |     */
  573|       |    if (data_size == 1 && array_size == 1)
  574|       |    {
  575|       |        data_size = 2;
  576|       |    }
  577|       |#endif
  578|       |
  579|       |    /* Check for multiplication overflows.
  580|       |     * This code avoids the costly division if the sizes are small enough.
  581|       |     * Multiplication is safe as long as only half of bits are set
  582|       |     * in either multiplicand.
  583|       |     */
  584|  31.5M|    {
  585|  31.5M|        const size_t check_limit = (size_t)1 << (sizeof(size_t) * 4);
  586|  31.5M|        if (data_size >= check_limit || array_size >= check_limit)
  ------------------
  |  Branch (586:13): [True: 0, False: 31.5M]
  |  Branch (586:41): [True: 0, False: 31.5M]
  ------------------
  587|      0|        {
  588|      0|            const size_t size_max = (size_t)-1;
  589|      0|            if (size_max / array_size < data_size)
  ------------------
  |  Branch (589:17): [True: 0, False: 0]
  ------------------
  590|      0|            {
  591|      0|                PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  592|      0|            }
  593|      0|        }
  594|  31.5M|    }
  595|       |    
  596|       |    /* Allocate new or expand previous allocation */
  597|       |    /* Note: on failure the old pointer will remain in the structure,
  598|       |     * the message must be freed by caller also on error return. */
  599|  31.5M|    ptr = pb_realloc(ptr, array_size * data_size);
  ------------------
  |  |    3|  31.5M|#define pb_realloc(ptr,size) realloc_with_check(ptr,size)
  ------------------
  600|  31.5M|    if (ptr == NULL)
  ------------------
  |  Branch (600:9): [True: 0, False: 31.5M]
  ------------------
  601|      0|        PB_RETURN_ERROR(stream, "realloc failed");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  602|       |    
  603|  31.5M|    *(void**)pData = ptr;
  604|  31.5M|    return true;
  605|  31.5M|}
pb_decode.c:pb_dec_string:
 1538|  98.0k|{
 1539|  98.0k|    uint32_t size;
 1540|  98.0k|    size_t alloc_size;
 1541|  98.0k|    pb_byte_t *dest = (pb_byte_t*)field->pData;
 1542|       |
 1543|  98.0k|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1543:9): [True: 25, False: 97.9k]
  ------------------
 1544|     25|        return false;
 1545|       |
 1546|  97.9k|    if (size == (uint32_t)-1)
  ------------------
  |  Branch (1546:9): [True: 1, False: 97.9k]
  ------------------
 1547|      1|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  894|      1|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      1|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1548|       |
 1549|       |    /* Space for null terminator */
 1550|  97.9k|    alloc_size = (size_t)(size + 1);
 1551|       |
 1552|  97.9k|    if (alloc_size < size)
  ------------------
  |  Branch (1552:9): [True: 0, False: 97.9k]
  ------------------
 1553|      0|        PB_RETURN_ERROR(stream, "size too large");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1554|       |
 1555|  97.9k|    if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  297|  97.9k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  97.9k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(field->type) == PB_ATYPE_POINTER)
  ------------------
  |  |  293|  97.9k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1555:9): [True: 95.1k, False: 2.84k]
  ------------------
 1556|  95.1k|    {
 1557|       |#ifndef PB_ENABLE_MALLOC
 1558|       |        PB_RETURN_ERROR(stream, "no malloc support");
 1559|       |#else
 1560|  95.1k|        if (stream->bytes_left < size)
  ------------------
  |  Branch (1560:13): [True: 64, False: 95.0k]
  ------------------
 1561|     64|            PB_RETURN_ERROR(stream, "end-of-stream");
  ------------------
  |  |  894|     64|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     64|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 64]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1562|       |
 1563|  95.0k|        if (!allocate_field(stream, field->pData, alloc_size, 1))
  ------------------
  |  Branch (1563:13): [True: 0, False: 95.0k]
  ------------------
 1564|      0|            return false;
 1565|  95.0k|        dest = *(pb_byte_t**)field->pData;
 1566|  95.0k|#endif
 1567|  95.0k|    }
 1568|  2.84k|    else
 1569|  2.84k|    {
 1570|  2.84k|        if (alloc_size > field->data_size)
  ------------------
  |  Branch (1570:13): [True: 46, False: 2.79k]
  ------------------
 1571|     46|            PB_RETURN_ERROR(stream, "string overflow");
  ------------------
  |  |  894|     46|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     46|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1572|  2.84k|    }
 1573|       |    
 1574|  97.8k|    dest[size] = 0;
 1575|       |
 1576|  97.8k|    if (!pb_read(stream, dest, (size_t)size))
  ------------------
  |  Branch (1576:9): [True: 6, False: 97.8k]
  ------------------
 1577|      6|        return false;
 1578|       |
 1579|       |#ifdef PB_VALIDATE_UTF8
 1580|       |    if (!pb_validate_utf8((const char*)dest))
 1581|       |        PB_RETURN_ERROR(stream, "invalid utf8");
 1582|       |#endif
 1583|       |
 1584|  97.8k|    return true;
 1585|  97.8k|}
pb_decode.c:pb_dec_submessage:
 1588|   299k|{
 1589|   299k|    bool status = true;
 1590|   299k|    bool submsg_consumed = false;
 1591|   299k|    pb_istream_t substream;
 1592|       |
 1593|   299k|    if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (1593:9): [True: 146, False: 299k]
  ------------------
 1594|    146|        return false;
 1595|       |    
 1596|   299k|    if (field->submsg_desc == NULL)
  ------------------
  |  Branch (1596:9): [True: 0, False: 299k]
  ------------------
 1597|      0|        PB_RETURN_ERROR(stream, "invalid field descriptor");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1598|       |    
 1599|       |    /* Submessages can have a separate message-level callback that is called
 1600|       |     * before decoding the message. Typically it is used to set callback fields
 1601|       |     * inside oneofs. */
 1602|   299k|    if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  299|   299k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   299k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_SUBMSG_W_CB && field->pSize != NULL)
  ------------------
  |  |  264|   599k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  ------------------
  |  Branch (1602:9): [True: 0, False: 299k]
  |  Branch (1602:58): [True: 0, False: 0]
  ------------------
 1603|      0|    {
 1604|       |        /* Message callback is stored right before pSize. */
 1605|      0|        pb_callback_t *callback = (pb_callback_t*)field->pSize - 1;
 1606|      0|        if (callback->funcs.decode)
  ------------------
  |  Branch (1606:13): [True: 0, False: 0]
  ------------------
 1607|      0|        {
 1608|      0|            status = callback->funcs.decode(&substream, field, &callback->arg);
 1609|       |
 1610|      0|            if (substream.bytes_left == 0)
  ------------------
  |  Branch (1610:17): [True: 0, False: 0]
  ------------------
 1611|      0|            {
 1612|      0|                submsg_consumed = true;
 1613|      0|            }
 1614|      0|        }
 1615|      0|    }
 1616|       |
 1617|       |    /* Now decode the submessage contents */
 1618|   299k|    if (status && !submsg_consumed)
  ------------------
  |  Branch (1618:9): [True: 299k, False: 0]
  |  Branch (1618:19): [True: 299k, False: 0]
  ------------------
 1619|   299k|    {
 1620|   299k|        unsigned int flags = 0;
 1621|       |
 1622|       |        /* Static required/optional fields are already initialized by top-level
 1623|       |         * pb_decode(), no need to initialize them again. */
 1624|   299k|        if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  297|   299k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|   299k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(field->type) == PB_ATYPE_STATIC &&
  ------------------
  |  |  292|   599k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1624:13): [True: 8.94k, False: 290k]
  ------------------
 1625|   299k|            PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  298|  8.94k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  8.94k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          PB_HTYPE(field->type) != PB_HTYPE_REPEATED)
  ------------------
  |  |  285|  8.94k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1625:13): [True: 8.94k, False: 0]
  ------------------
 1626|  8.94k|        {
 1627|  8.94k|            flags = PB_DECODE_NOINIT;
  ------------------
  |  |   99|  8.94k|#define PB_DECODE_NOINIT          0x01U
  ------------------
 1628|  8.94k|        }
 1629|       |
 1630|   299k|        status = pb_decode_inner(&substream, field->submsg_desc, field->pData, flags);
 1631|   299k|    }
 1632|       |    
 1633|   299k|    if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (1633:9): [True: 0, False: 299k]
  ------------------
 1634|      0|        return false;
 1635|       |
 1636|   299k|    return status;
 1637|   299k|}
pb_decode.c:pb_dec_fixed_length_bytes:
 1640|  27.1M|{
 1641|  27.1M|    uint32_t size;
 1642|       |
 1643|  27.1M|    if (!pb_decode_varint32(stream, &size))
  ------------------
  |  Branch (1643:9): [True: 6, False: 27.1M]
  ------------------
 1644|      6|        return false;
 1645|       |
 1646|  27.1M|    if (size > PB_SIZE_MAX)
  ------------------
  |  |  313|  27.1M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (1646:9): [True: 28, False: 27.1M]
  ------------------
 1647|     28|        PB_RETURN_ERROR(stream, "bytes overflow");
  ------------------
  |  |  894|     28|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     28|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 28]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1648|       |
 1649|  27.1M|    if (size == 0)
  ------------------
  |  Branch (1649:9): [True: 26.0M, False: 1.16M]
  ------------------
 1650|  26.0M|    {
 1651|       |        /* As a special case, treat empty bytes string as all zeros for fixed_length_bytes. */
 1652|  26.0M|        memset(field->pData, 0, (size_t)field->data_size);
 1653|  26.0M|        return true;
 1654|  26.0M|    }
 1655|       |
 1656|  1.16M|    if (size != field->data_size)
  ------------------
  |  Branch (1656:9): [True: 43, False: 1.16M]
  ------------------
 1657|     43|        PB_RETURN_ERROR(stream, "incorrect fixed length bytes size");
  ------------------
  |  |  894|     43|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|     43|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 43]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1658|       |
 1659|  1.16M|    return pb_read(stream, (pb_byte_t*)field->pData, (size_t)field->data_size);
 1660|  1.16M|}
pb_decode.c:decode_pointer_field:
  625|  30.0M|{
  626|       |#ifndef PB_ENABLE_MALLOC
  627|       |    PB_UNUSED(wire_type);
  628|       |    PB_UNUSED(field);
  629|       |    PB_RETURN_ERROR(stream, "no malloc support");
  630|       |#else
  631|  30.0M|    switch (PB_HTYPE(field->type))
  ------------------
  |  |  298|  30.0M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  30.0M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
  632|  30.0M|    {
  633|  2.03M|        case PB_HTYPE_REQUIRED:
  ------------------
  |  |  282|  2.03M|#define PB_HTYPE_REQUIRED 0x00U
  ------------------
  |  Branch (633:9): [True: 2.03M, False: 28.0M]
  ------------------
  634|  2.05M|        case PB_HTYPE_OPTIONAL:
  ------------------
  |  |  283|  2.05M|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (634:9): [True: 11.5k, False: 30.0M]
  ------------------
  635|  2.06M|        case PB_HTYPE_ONEOF:
  ------------------
  |  |  287|  2.06M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (635:9): [True: 19.4k, False: 30.0M]
  ------------------
  636|  2.06M|            if (PB_LTYPE_IS_SUBMSG(field->type) && *(void**)field->pField != NULL)
  ------------------
  |  |  300|  4.13M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|  2.06M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  2.06M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|  4.13M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 86.7k, False: 1.98M]
  |  |  ------------------
  |  |  301|  4.13M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|  1.98M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  1.98M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|  1.98M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 0, False: 1.98M]
  |  |  ------------------
  ------------------
  |  Branch (636:52): [True: 47.9k, False: 38.8k]
  ------------------
  637|  47.9k|            {
  638|       |                /* Duplicate field, have to release the old allocation first. */
  639|       |                /* FIXME: Does this work correctly for oneofs? */
  640|  47.9k|                pb_release_single_field(field);
  641|  47.9k|            }
  642|       |        
  643|  2.06M|            if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  298|  2.06M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  2.06M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(field->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|  2.06M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (643:17): [True: 19.4k, False: 2.05M]
  ------------------
  644|  19.4k|            {
  645|  19.4k|                *(pb_size_t*)field->pSize = field->tag;
  646|  19.4k|            }
  647|       |
  648|  2.06M|            if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  299|  2.06M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  2.06M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  255|  4.13M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (648:17): [True: 70.0k, False: 1.99M]
  ------------------
  649|  2.06M|                PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  299|  1.99M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  1.99M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  251|  1.99M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (649:17): [True: 17.4k, False: 1.98M]
  ------------------
  650|  87.5k|            {
  651|       |                /* pb_dec_string and pb_dec_bytes handle allocation themselves */
  652|  87.5k|                field->pData = field->pField;
  653|  87.5k|                return decode_basic_field(stream, wire_type, field);
  654|  87.5k|            }
  655|  1.98M|            else
  656|  1.98M|            {
  657|  1.98M|                if (!allocate_field(stream, field->pField, field->data_size, 1))
  ------------------
  |  Branch (657:21): [True: 0, False: 1.98M]
  ------------------
  658|      0|                    return false;
  659|       |                
  660|  1.98M|                field->pData = *(void**)field->pField;
  661|  1.98M|                initialize_pointer_field(field->pData, field);
  662|  1.98M|                return decode_basic_field(stream, wire_type, field);
  663|  1.98M|            }
  664|       |    
  665|  27.9M|        case PB_HTYPE_REPEATED:
  ------------------
  |  |  285|  27.9M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (665:9): [True: 27.9M, False: 2.06M]
  ------------------
  666|  27.9M|            if (wire_type == PB_WT_STRING
  ------------------
  |  Branch (666:17): [True: 27.9M, False: 9.11k]
  ------------------
  667|  27.9M|                && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  299|  27.9M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  27.9M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                              && PB_LTYPE(field->type) <= PB_LTYPE_LAST_PACKABLE)
  ------------------
  |  |  247|  27.9M|#define PB_LTYPE_LAST_PACKABLE 0x05U
  ------------------
  |  Branch (667:20): [True: 59.2k, False: 27.9M]
  ------------------
  668|  59.2k|            {
  669|       |                /* Packed array, multiple items come in at once. */
  670|  59.2k|                bool status = true;
  671|  59.2k|                pb_size_t *size = (pb_size_t*)field->pSize;
  672|  59.2k|                size_t allocated_size = *size;
  673|  59.2k|                pb_istream_t substream;
  674|       |                
  675|  59.2k|                if (!pb_make_string_substream(stream, &substream))
  ------------------
  |  Branch (675:21): [True: 54, False: 59.2k]
  ------------------
  676|     54|                    return false;
  677|       |                
  678|  9.09M|                while (substream.bytes_left)
  ------------------
  |  Branch (678:24): [True: 9.03M, False: 59.1k]
  ------------------
  679|  9.03M|                {
  680|  9.03M|                    if (*size == PB_SIZE_MAX)
  ------------------
  |  |  313|  9.03M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (680:25): [True: 5, False: 9.03M]
  ------------------
  681|      5|                    {
  682|      5|#ifndef PB_NO_ERRMSG
  683|      5|                        stream->errmsg = "too many array entries";
  684|      5|#endif
  685|      5|                        status = false;
  686|      5|                        break;
  687|      5|                    }
  688|       |
  689|  9.03M|                    if ((size_t)*size + 1 > allocated_size)
  ------------------
  |  Branch (689:25): [True: 1.01M, False: 8.02M]
  ------------------
  690|  1.01M|                    {
  691|       |                        /* Allocate more storage. This tries to guess the
  692|       |                         * number of remaining entries. Round the division
  693|       |                         * upwards. */
  694|  1.01M|                        size_t remain = (substream.bytes_left - 1) / field->data_size + 1;
  695|  1.01M|                        if (remain < PB_SIZE_MAX - allocated_size)
  ------------------
  |  |  313|  1.01M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (695:29): [True: 192k, False: 821k]
  ------------------
  696|   192k|                            allocated_size += remain;
  697|   821k|                        else
  698|   821k|                            allocated_size += 1;
  699|       |                        
  700|  1.01M|                        if (!allocate_field(&substream, field->pField, field->data_size, allocated_size))
  ------------------
  |  Branch (700:29): [True: 0, False: 1.01M]
  ------------------
  701|      0|                        {
  702|      0|                            status = false;
  703|      0|                            break;
  704|      0|                        }
  705|  1.01M|                    }
  706|       |
  707|       |                    /* Decode the array entry */
  708|  9.03M|                    field->pData = *(char**)field->pField + field->data_size * (*size);
  709|  9.03M|                    if (field->pData == NULL)
  ------------------
  |  Branch (709:25): [True: 0, False: 9.03M]
  ------------------
  710|      0|                    {
  711|       |                        /* Shouldn't happen, but satisfies static analyzers */
  712|      0|                        status = false;
  713|      0|                        break;
  714|      0|                    }
  715|  9.03M|                    initialize_pointer_field(field->pData, field);
  716|  9.03M|                    if (!decode_basic_field(&substream, PB_WT_PACKED, field))
  ------------------
  |  Branch (716:25): [True: 71, False: 9.03M]
  ------------------
  717|     71|                    {
  718|     71|                        status = false;
  719|     71|                        break;
  720|     71|                    }
  721|       |                    
  722|  9.03M|                    (*size)++;
  723|  9.03M|                }
  724|  59.2k|                if (!pb_close_string_substream(stream, &substream))
  ------------------
  |  Branch (724:21): [True: 0, False: 59.2k]
  ------------------
  725|      0|                    return false;
  726|       |                
  727|  59.2k|                return status;
  728|  59.2k|            }
  729|  27.9M|            else
  730|  27.9M|            {
  731|       |                /* Normal repeated field, i.e. only one item at a time. */
  732|  27.9M|                pb_size_t *size = (pb_size_t*)field->pSize;
  733|       |
  734|  27.9M|                if (*size == PB_SIZE_MAX)
  ------------------
  |  |  313|  27.9M|#define PB_SIZE_MAX ((pb_size_t)-1)
  ------------------
  |  Branch (734:21): [True: 1, False: 27.9M]
  ------------------
  735|      1|                    PB_RETURN_ERROR(stream, "too many array entries");
  ------------------
  |  |  894|      1|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      1|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  736|       |                
  737|  27.9M|                if (!allocate_field(stream, field->pField, field->data_size, (size_t)(*size + 1)))
  ------------------
  |  Branch (737:21): [True: 0, False: 27.9M]
  ------------------
  738|      0|                    return false;
  739|       |            
  740|  27.9M|                field->pData = *(char**)field->pField + field->data_size * (*size);
  741|  27.9M|                (*size)++;
  742|  27.9M|                initialize_pointer_field(field->pData, field);
  743|  27.9M|                return decode_basic_field(stream, wire_type, field);
  744|  27.9M|            }
  745|       |
  746|      0|        default:
  ------------------
  |  Branch (746:9): [True: 0, False: 30.0M]
  ------------------
  747|      0|            PB_RETURN_ERROR(stream, "invalid field type");
  ------------------
  |  |  894|      0|#define PB_RETURN_ERROR(stream, msg) return PB_SET_ERROR(stream, msg), false
  |  |  ------------------
  |  |  |  |  890|      0|#define PB_SET_ERROR(stream, msg) (stream->errmsg = (stream)->errmsg ? (stream)->errmsg : (msg))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (890:53): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  748|  30.0M|    }
  749|  30.0M|#endif
  750|  30.0M|}
pb_decode.c:initialize_pointer_field:
  609|  38.9M|{
  610|  38.9M|    if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  299|  38.9M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  38.9M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(field->type) == PB_LTYPE_STRING ||
  ------------------
  |  |  255|  77.8M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (610:9): [True: 25.0k, False: 38.9M]
  ------------------
  611|  38.9M|        PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  299|  38.9M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  38.9M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      PB_LTYPE(field->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  251|  38.9M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (611:9): [True: 522k, False: 38.3M]
  ------------------
  612|   547k|    {
  613|   547k|        *(void**)pItem = NULL;
  614|   547k|    }
  615|  38.3M|    else if (PB_LTYPE_IS_SUBMSG(field->type))
  ------------------
  |  |  300|  38.3M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|  38.3M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  38.3M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|  76.7M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 290k, False: 38.1M]
  |  |  ------------------
  |  |  301|  38.3M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|  38.1M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  38.1M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|  38.1M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 0, False: 38.1M]
  |  |  ------------------
  ------------------
  616|   290k|    {
  617|       |        /* We memset to zero so that any callbacks are set to NULL.
  618|       |         * Default values will be set by pb_dec_submessage(). */
  619|   290k|        memset(pItem, 0, field->data_size);
  620|   290k|    }
  621|  38.9M|}
pb_decode.c:pb_release_single_field:
 1230|  1.14M|{
 1231|  1.14M|    pb_type_t type;
 1232|  1.14M|    type = field->type;
 1233|       |
 1234|  1.14M|    if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  298|  1.14M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  1.14M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|  1.14M|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (1234:9): [True: 53.0k, False: 1.09M]
  ------------------
 1235|  53.0k|    {
 1236|  53.0k|        if (*(pb_size_t*)field->pSize != field->tag)
  ------------------
  |  Branch (1236:13): [True: 30.4k, False: 22.5k]
  ------------------
 1237|  30.4k|            return; /* This is not the current field in the union */
 1238|  53.0k|    }
 1239|       |
 1240|       |    /* Release anything contained inside an extension or submsg.
 1241|       |     * This has to be done even if the submsg itself is statically
 1242|       |     * allocated. */
 1243|  1.11M|    if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  299|  1.11M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  1.11M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  if (PB_LTYPE(type) == PB_LTYPE_EXTENSION)
  ------------------
  |  |  268|  1.11M|#define PB_LTYPE_EXTENSION 0x0AU
  ------------------
  |  Branch (1243:9): [True: 10.4k, False: 1.10M]
  ------------------
 1244|  10.4k|    {
 1245|       |        /* Release fields from all extensions in the linked list */
 1246|  10.4k|        pb_extension_t *ext = *(pb_extension_t**)field->pData;
 1247|  19.3k|        while (ext != NULL)
  ------------------
  |  Branch (1247:16): [True: 8.87k, False: 10.4k]
  ------------------
 1248|  8.87k|        {
 1249|  8.87k|            pb_field_iter_t ext_iter;
 1250|  8.87k|            if (pb_field_iter_begin_extension(&ext_iter, ext))
  ------------------
  |  Branch (1250:17): [True: 8.87k, False: 0]
  ------------------
 1251|  8.87k|            {
 1252|  8.87k|                pb_release_single_field(&ext_iter);
 1253|  8.87k|            }
 1254|  8.87k|            ext = ext->next;
 1255|  8.87k|        }
 1256|  10.4k|    }
 1257|  1.10M|    else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  300|  2.21M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|  1.10M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  1.10M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|  2.21M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 161k, False: 946k]
  |  |  ------------------
  |  |  301|  2.21M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|   946k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|   946k|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|   946k|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 0, False: 946k]
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  297|   161k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|   161k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE_IS_SUBMSG(type) && PB_ATYPE(type) != PB_ATYPE_CALLBACK)
  ------------------
  |  |  294|   161k|#define PB_ATYPE_CALLBACK 0x40U
  ------------------
  |  Branch (1257:42): [True: 161k, False: 0]
  ------------------
 1258|   161k|    {
 1259|       |        /* Release fields in submessage or submsg array */
 1260|   161k|        pb_size_t count = 1;
 1261|       |        
 1262|   161k|        if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  297|   161k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|   161k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                      if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  293|   161k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1262:13): [True: 149k, False: 11.8k]
  ------------------
 1263|   149k|        {
 1264|   149k|            field->pData = *(void**)field->pField;
 1265|   149k|        }
 1266|  11.8k|        else
 1267|  11.8k|        {
 1268|  11.8k|            field->pData = field->pField;
 1269|  11.8k|        }
 1270|       |        
 1271|   161k|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  298|   161k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   161k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  285|   161k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1271:13): [True: 20.8k, False: 141k]
  ------------------
 1272|  20.8k|        {
 1273|  20.8k|            count = *(pb_size_t*)field->pSize;
 1274|       |
 1275|  20.8k|            if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  297|  20.8k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  20.8k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(type) == PB_ATYPE_STATIC && count > field->array_size)
  ------------------
  |  |  292|  41.7k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (1275:17): [True: 0, False: 20.8k]
  |  Branch (1275:54): [True: 0, False: 0]
  ------------------
 1276|      0|            {
 1277|       |                /* Protect against corrupted _count fields */
 1278|      0|                count = field->array_size;
 1279|      0|            }
 1280|  20.8k|        }
 1281|       |        
 1282|   161k|        if (field->pData)
  ------------------
  |  Branch (1282:13): [True: 100k, False: 61.4k]
  ------------------
 1283|   100k|        {
 1284|   403k|            for (; count > 0; count--)
  ------------------
  |  Branch (1284:20): [True: 302k, False: 100k]
  ------------------
 1285|   302k|            {
 1286|   302k|                pb_release(field->submsg_desc, field->pData);
 1287|   302k|                field->pData = (char*)field->pData + field->data_size;
 1288|   302k|            }
 1289|   100k|        }
 1290|   161k|    }
 1291|       |    
 1292|  1.11M|    if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  297|  1.11M|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|  1.11M|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                  if (PB_ATYPE(type) == PB_ATYPE_POINTER)
  ------------------
  |  |  293|  1.11M|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (1292:9): [True: 1.08M, False: 31.1k]
  ------------------
 1293|  1.08M|    {
 1294|  1.08M|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  298|  1.08M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  1.08M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED &&
  ------------------
  |  |  285|  2.17M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1294:13): [True: 218k, False: 868k]
  ------------------
 1295|  1.08M|            (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  299|   218k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   218k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                          (PB_LTYPE(type) == PB_LTYPE_STRING ||
  ------------------
  |  |  255|   437k|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (1295:14): [True: 10.4k, False: 208k]
  ------------------
 1296|   218k|             PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  299|   208k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   208k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                           PB_LTYPE(type) == PB_LTYPE_BYTES))
  ------------------
  |  |  251|   208k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (1296:14): [True: 10.4k, False: 198k]
  ------------------
 1297|  20.8k|        {
 1298|       |            /* Release entries in repeated string or bytes array */
 1299|  20.8k|            void **pItem = *(void***)field->pField;
 1300|  20.8k|            pb_size_t count = *(pb_size_t*)field->pSize;
 1301|   568k|            for (; count > 0; count--)
  ------------------
  |  Branch (1301:20): [True: 547k, False: 20.8k]
  ------------------
 1302|   547k|            {
 1303|   547k|                pb_free(*pItem);
  ------------------
  |  |    4|   547k|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1304|   547k|                *pItem++ = NULL;
 1305|   547k|            }
 1306|  20.8k|        }
 1307|       |        
 1308|  1.08M|        if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  298|  1.08M|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  1.08M|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  285|  1.08M|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (1308:13): [True: 218k, False: 868k]
  ------------------
 1309|   218k|        {
 1310|       |            /* We are going to release the array, so set the size to 0 */
 1311|   218k|            *(pb_size_t*)field->pSize = 0;
 1312|   218k|        }
 1313|       |        
 1314|       |        /* Release main pointer */
 1315|  1.08M|        pb_free(*(void**)field->pField);
  ------------------
  |  |    4|  1.08M|#define pb_free(ptr) free_with_check(ptr)
  ------------------
 1316|  1.08M|        *(void**)field->pField = NULL;
 1317|  1.08M|    }
 1318|  1.11M|}

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

malloc_with_check:
   55|  1.08M|{
   56|  1.08M|    char *buf = NULL;
   57|       |
   58|  1.08M|    if (size <= g_max_alloc_bytes - g_alloc_bytes)
  ------------------
  |  Branch (58:9): [True: 1.08M, False: 0]
  ------------------
   59|  1.08M|    {
   60|  1.08M|        buf = malloc(round_blocksize(size + GUARD_SIZE));
  ------------------
  |  |   12|  1.08M|#define GUARD_SIZE (sizeof(size_t)*3)
  ------------------
   61|  1.08M|    }
   62|       |
   63|  1.08M|    if (buf)
  ------------------
  |  Branch (63:9): [True: 1.08M, False: 0]
  ------------------
   64|  1.08M|    {
   65|  1.08M|        ((size_t*)buf)[0] = size;
   66|  1.08M|        ((size_t*)buf)[1] = CHECK1;
  ------------------
  |  |   14|  1.08M|#define CHECK1 ((size_t)0xDEADBEEF)
  ------------------
   67|  1.08M|        ((size_t*)(buf + size))[2] = CHECK2;
  ------------------
  |  |   15|  1.08M|#define CHECK2 ((size_t)0x600DCAFE)
  ------------------
   68|  1.08M|        g_alloc_count++;
   69|  1.08M|        g_alloc_bytes += size;
   70|  1.08M|        if (DEBUG_MALLOC) fprintf(stderr, "Alloc 0x%04x/%u\n", (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   22|  1.08M|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (22:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
                      if (DEBUG_MALLOC) fprintf(stderr, "Alloc 0x%04x/%u\n", (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   13|      0|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   71|  1.08M|        return buf + PREFIX_SIZE;
  ------------------
  |  |   13|  1.08M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   72|  1.08M|    }
   73|      0|    else
   74|      0|    {
   75|      0|        if (DEBUG_MALLOC) fprintf(stderr, "malloc(%u) failed\n", (unsigned)size);
  ------------------
  |  |   22|      0|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (22:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
   76|      0|        return NULL;
   77|      0|    }
   78|  1.08M|}
free_with_check:
   82|  1.64M|{
   83|  1.64M|    if (mem)
  ------------------
  |  Branch (83:9): [True: 1.08M, False: 565k]
  ------------------
   84|  1.08M|    {
   85|  1.08M|        char *buf = (char*)mem - PREFIX_SIZE;
  ------------------
  |  |   13|  1.08M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
   86|  1.08M|        size_t size = ((size_t*)buf)[0];
   87|  1.08M|        if (DEBUG_MALLOC) fprintf(stderr, "Release 0x%04x/%u\n", (unsigned)(uintptr_t)mem, (unsigned)size);
  ------------------
  |  |   22|  1.08M|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (22:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
   88|  1.08M|        assert(((size_t*)buf)[1] == CHECK1);
   89|  1.08M|        assert(((size_t*)(buf + size))[2] == CHECK2);
   90|  1.08M|        assert(g_alloc_count > 0);
   91|  1.08M|        assert(g_alloc_bytes >= size);
   92|  1.08M|        ((size_t*)buf)[1] = 0;
   93|  1.08M|        ((size_t*)(buf + size))[2] = 0;
   94|  1.08M|        g_alloc_count--;
   95|  1.08M|        g_alloc_bytes -= size;
   96|  1.08M|        free(buf);
   97|  1.08M|    }
   98|  1.64M|}
realloc_with_check:
  102|  31.5M|{
  103|  31.5M|    if (!ptr && size)
  ------------------
  |  Branch (103:9): [True: 1.07M, False: 30.4M]
  |  Branch (103:17): [True: 1.07M, False: 0]
  ------------------
  104|  1.07M|    {
  105|       |        /* Allocate new block and write guard values */
  106|  1.07M|        return malloc_with_check(size);
  107|  1.07M|    }
  108|  30.4M|    else if (ptr && size)
  ------------------
  |  Branch (108:14): [True: 30.4M, False: 0]
  |  Branch (108:21): [True: 30.4M, False: 0]
  ------------------
  109|  30.4M|    {
  110|       |        /* Change block size */
  111|  30.4M|        char *buf = (char*)ptr - PREFIX_SIZE;
  ------------------
  |  |   13|  30.4M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  112|  30.4M|        size_t oldsize = ((size_t*)buf)[0];
  113|  30.4M|        assert(((size_t*)buf)[1] == CHECK1);
  114|  30.4M|        assert(((size_t*)(buf + oldsize))[2] == CHECK2);
  115|  30.4M|        assert(g_alloc_count > 0);
  116|  30.4M|        assert(g_alloc_bytes >= oldsize);
  117|       |
  118|  30.4M|        if (size <= g_max_alloc_bytes - (g_alloc_bytes - oldsize))
  ------------------
  |  Branch (118:13): [True: 30.4M, False: 0]
  ------------------
  119|  30.4M|        {
  120|  30.4M|            size_t new_rounded = round_blocksize(size + GUARD_SIZE);
  ------------------
  |  |   12|  30.4M|#define GUARD_SIZE (sizeof(size_t)*3)
  ------------------
  121|  30.4M|            size_t old_rounded = round_blocksize(oldsize + GUARD_SIZE);
  ------------------
  |  |   12|  30.4M|#define GUARD_SIZE (sizeof(size_t)*3)
  ------------------
  122|       |
  123|  30.4M|            if (new_rounded != old_rounded)
  ------------------
  |  Branch (123:17): [True: 301k, False: 30.1M]
  ------------------
  124|   301k|            {
  125|   301k|                buf = realloc(buf, new_rounded);
  126|   301k|            }
  127|  30.4M|        }
  128|      0|        else
  129|      0|        {
  130|      0|            buf = NULL;
  131|      0|        }
  132|       |
  133|  30.4M|        if (!buf)
  ------------------
  |  Branch (133:13): [True: 0, False: 30.4M]
  ------------------
  134|      0|        {
  135|      0|            if (DEBUG_MALLOC) fprintf(stderr, "Realloc 0x%04x/%u to %u failed\n", (unsigned)(uintptr_t)ptr, (unsigned)oldsize, (unsigned)size);
  ------------------
  |  |   22|      0|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (22:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
  136|      0|            return NULL;
  137|      0|        }
  138|       |
  139|  30.4M|        ((size_t*)buf)[0] = size;
  140|  30.4M|        ((size_t*)buf)[1] = CHECK1;
  ------------------
  |  |   14|  30.4M|#define CHECK1 ((size_t)0xDEADBEEF)
  ------------------
  141|  30.4M|        ((size_t*)(buf + size))[2] = CHECK2;
  ------------------
  |  |   15|  30.4M|#define CHECK2 ((size_t)0x600DCAFE)
  ------------------
  142|  30.4M|        g_alloc_bytes -= oldsize;
  143|  30.4M|        g_alloc_bytes += size;
  144|       |
  145|  30.4M|        if (DEBUG_MALLOC) fprintf(stderr, "Realloc 0x%04x/%u to 0x%04x/%u\n", (unsigned)(uintptr_t)ptr, (unsigned)oldsize, (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   22|  30.4M|#define DEBUG_MALLOC 0
  |  |  ------------------
  |  |  |  Branch (22:22): [Folded - Ignored]
  |  |  ------------------
  ------------------
                      if (DEBUG_MALLOC) fprintf(stderr, "Realloc 0x%04x/%u to 0x%04x/%u\n", (unsigned)(uintptr_t)ptr, (unsigned)oldsize, (unsigned)(uintptr_t)(buf + PREFIX_SIZE), (unsigned)size);
  ------------------
  |  |   13|      0|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  146|  30.4M|        return buf + PREFIX_SIZE;
  ------------------
  |  |   13|  30.4M|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  147|  30.4M|    }
  148|      0|    else if (ptr && !size)
  ------------------
  |  Branch (148:14): [True: 0, False: 0]
  |  Branch (148:21): [True: 0, False: 0]
  ------------------
  149|      0|    {
  150|       |        /* Deallocate */
  151|      0|        free_with_check(ptr);
  152|      0|        return NULL;
  153|      0|    }
  154|      0|    else
  155|      0|    {
  156|       |        /* No action */
  157|      0|        return NULL;
  158|      0|    }
  159|  31.5M|}
get_alloc_count:
  163|  17.7k|{
  164|  17.7k|    return g_alloc_count;
  165|  17.7k|}
get_allocation_size:
  169|   826k|{
  170|   826k|    char *buf = (char*)mem - PREFIX_SIZE;
  ------------------
  |  |   13|   826k|#define PREFIX_SIZE (sizeof(size_t)*2)
  ------------------
  171|   826k|    return ((size_t*)buf)[0];
  172|   826k|}
malloc_wrappers.c:round_blocksize:
   36|  62.0M|{
   37|  62.0M|    if (size < 256)
  ------------------
  |  Branch (37:9): [True: 4.52M, False: 57.5M]
  ------------------
   38|  4.52M|    {
   39|  4.52M|        return size;
   40|  4.52M|    }
   41|  57.5M|    else
   42|  57.5M|    {
   43|  57.5M|        return (size + 1023) / 1024 * 1024;
   44|  57.5M|    }
   45|  62.0M|}

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

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

validate_static:
    7|  5.99k|{
    8|  5.99k|    pb_size_t count = 1;
    9|  5.99k|    pb_size_t i;
   10|  5.99k|    bool truebool = true;
   11|  5.99k|    bool falsebool = false;
   12|       |
   13|  5.99k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  298|  5.99k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  5.99k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize)
  ------------------
  |  |  285|  11.9k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (13:9): [True: 0, False: 5.99k]
  |  Branch (13:54): [True: 0, False: 0]
  ------------------
   14|      0|    {
   15|       |        /* Array count must be between 0 and statically allocated size */
   16|      0|        count = *(pb_size_t*)iter->pSize;
   17|      0|        assert(count <= iter->array_size);
   18|      0|    }
   19|  5.99k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  298|  5.99k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  5.99k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_OPTIONAL && iter->pSize)
  ------------------
  |  |  283|  11.9k|#define PB_HTYPE_OPTIONAL 0x10U
  ------------------
  |  Branch (19:14): [True: 0, False: 5.99k]
  |  Branch (19:59): [True: 0, False: 0]
  ------------------
   20|      0|    {
   21|       |        /* Boolean has_ field must have a valid value */
   22|      0|        assert(memcmp(iter->pSize, &truebool, sizeof(bool)) == 0 ||
   23|      0|               memcmp(iter->pSize, &falsebool, sizeof(bool)) == 0);
   24|      0|    }
   25|  5.99k|    else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  298|  5.99k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  5.99k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  else if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|  5.99k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (25:14): [True: 5.99k, False: 0]
  ------------------
   26|  5.99k|    {
   27|  5.99k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (27:13): [True: 5.87k, False: 118]
  ------------------
   28|  5.87k|        {
   29|       |            /* Some different field in oneof */
   30|  5.87k|            return;
   31|  5.87k|        }
   32|  5.99k|    }
   33|       |
   34|    236|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (34:17): [True: 118, False: 118]
  ------------------
   35|    118|    {
   36|    118|        void *pData = (char*)iter->pData + iter->data_size * i;
   37|       |
   38|    118|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  299|    118|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|    118|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  255|    118|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (38:13): [True: 0, False: 118]
  ------------------
   39|      0|        {
   40|       |            /* String length must be at most statically allocated size */
   41|      0|            assert(strlen(pData) + 1 <= iter->data_size);
   42|      0|        }
   43|    118|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  299|    118|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|    118|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  251|    118|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (43:18): [True: 0, False: 118]
  ------------------
   44|      0|        {
   45|       |            /* Bytes length must be at most statically allocated size */
   46|      0|            pb_bytes_array_t *bytes = pData;
   47|      0|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= iter->data_size);
   48|      0|        }
   49|    118|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  299|    118|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|    118|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  239|    118|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (49:18): [True: 0, False: 118]
  ------------------
   50|      0|        {
   51|       |            /* Bool fields must have valid value */
   52|      0|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
   53|      0|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
   54|      0|        }
   55|    118|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  300|    118|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|    118|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|    118|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|    236|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 118, False: 0]
  |  |  ------------------
  |  |  301|    118|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|      0|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|      0|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|      0|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   56|    118|        {
   57|    118|            validate_message(pData, 0, iter->submsg_desc);
   58|    118|        }
   59|    118|    }
   60|    118|}
validate_pointer:
   63|   627k|{
   64|   627k|    pb_size_t count = 1;
   65|   627k|    pb_size_t i;
   66|   627k|    bool truebool = true;
   67|   627k|    bool falsebool = false;
   68|       |
   69|   627k|    if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  298|   627k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   627k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_ONEOF)
  ------------------
  |  |  287|   627k|#define PB_HTYPE_ONEOF    0x30U
  ------------------
  |  Branch (69:9): [True: 11.9k, False: 615k]
  ------------------
   70|  11.9k|    {
   71|  11.9k|        if (*(pb_size_t*)iter->pSize != iter->tag)
  ------------------
  |  Branch (71:13): [True: 11.5k, False: 396]
  ------------------
   72|  11.5k|        {
   73|       |            /* Some different field in oneof */
   74|  11.5k|            return;
   75|  11.5k|        }
   76|  11.9k|    }
   77|   615k|    else if (!iter->pData)
  ------------------
  |  Branch (77:14): [True: 271k, False: 344k]
  ------------------
   78|   271k|    {
   79|       |        /* Nothing allocated */
   80|   271k|        if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize != &iter->array_size)
  ------------------
  |  |  298|   271k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   271k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                      if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED && iter->pSize != &iter->array_size)
  ------------------
  |  |  285|   542k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (80:13): [True: 116k, False: 154k]
  |  Branch (80:58): [True: 104k, False: 11.7k]
  ------------------
   81|   104k|        {
   82|   104k|            assert(*(pb_size_t*)iter->pSize == 0);
   83|   104k|        }
   84|   271k|        return;
   85|   271k|    }
   86|       |
   87|   344k|    if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  298|   344k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   344k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                  if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  285|   344k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (87:9): [True: 9.25k, False: 335k]
  ------------------
   88|  9.25k|    {
   89|       |        /* Check that enough memory has been allocated for array */
   90|  9.25k|        size_t allocated_size = get_allocation_size(iter->pData);
   91|  9.25k|        count = *(pb_size_t*)iter->pSize;
   92|  9.25k|        assert(allocated_size >= count * iter->data_size);
   93|  9.25k|    }
   94|   335k|    else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  299|   335k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   335k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  255|   671k|#define PB_LTYPE_STRING 0x07U
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  299|   289k|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|   289k|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                  else if (PB_LTYPE(iter->type) != PB_LTYPE_STRING && PB_LTYPE(iter->type) != PB_LTYPE_BYTES)
  ------------------
  |  |  251|   289k|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (94:14): [True: 289k, False: 45.6k]
  |  Branch (94:57): [True: 283k, False: 6.58k]
  ------------------
   95|   283k|    {
   96|   283k|        size_t allocated_size = get_allocation_size(iter->pData);
   97|   283k|        assert(allocated_size >= iter->data_size);
   98|   283k|    }
   99|       |
  100|  34.4M|    for (i = 0; i < count; i++)
  ------------------
  |  Branch (100:17): [True: 34.1M, False: 344k]
  ------------------
  101|  34.1M|    {
  102|  34.1M|        void *pData = (char*)iter->pData + iter->data_size * i;
  103|       |
  104|  34.1M|        if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  299|  34.1M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  34.1M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      if (PB_LTYPE(iter->type) == PB_LTYPE_STRING)
  ------------------
  |  |  255|  34.1M|#define PB_LTYPE_STRING 0x07U
  ------------------
  |  Branch (104:13): [True: 70.0k, False: 34.0M]
  ------------------
  105|  70.0k|        {
  106|       |            /* Check that enough memory is allocated for string and that
  107|       |               the string is properly terminated. */
  108|  70.0k|            const char *str = pData;
  109|       |
  110|  70.0k|            if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  298|  70.0k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|  70.0k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  285|  70.0k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (110:17): [True: 24.3k, False: 45.6k]
  ------------------
  111|  24.3k|            {
  112|       |                /* String arrays are stored as array of pointers */
  113|  24.3k|                str = ((const char**)iter->pData)[i];
  114|  24.3k|            }
  115|       |
  116|  70.0k|            assert(strlen(str) + 1 <= get_allocation_size(str));
  117|  70.0k|        }
  118|  34.0M|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  299|  34.0M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  34.0M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BYTES)
  ------------------
  |  |  251|  34.0M|#define PB_LTYPE_BYTES 0x06U
  ------------------
  |  Branch (118:18): [True: 463k, False: 33.5M]
  ------------------
  119|   463k|        {
  120|       |            /* Bytes length must be at most statically allocated size */
  121|   463k|            const pb_bytes_array_t *bytes = pData;
  122|       |
  123|   463k|            if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  298|   463k|#define PB_HTYPE(x) ((x) & PB_HTYPE_MASK)
  |  |  ------------------
  |  |  |  |  288|   463k|#define PB_HTYPE_MASK     0x30U
  |  |  ------------------
  ------------------
                          if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED)
  ------------------
  |  |  285|   463k|#define PB_HTYPE_REPEATED 0x20U
  ------------------
  |  Branch (123:17): [True: 456k, False: 6.58k]
  ------------------
  124|   456k|            {
  125|       |                /* Bytes arrays are stored as array of pointers */
  126|   456k|                bytes = ((const pb_bytes_array_t**)iter->pData)[i];
  127|   456k|            }
  128|       |
  129|   463k|            assert(PB_BYTES_ARRAY_T_ALLOCSIZE(bytes->size) <= get_allocation_size(bytes));
  130|   463k|        }
  131|  33.5M|        else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  299|  33.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  ------------------
  |  |  |  |  278|  33.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  ------------------
  ------------------
                      else if (PB_LTYPE(iter->type) == PB_LTYPE_BOOL)
  ------------------
  |  |  239|  33.5M|#define PB_LTYPE_BOOL    0x00U /* bool */
  ------------------
  |  Branch (131:18): [True: 2.03M, False: 31.5M]
  ------------------
  132|  2.03M|        {
  133|       |            /* Bool fields must have valid value */
  134|  2.03M|            assert(memcmp(pData, &truebool, sizeof(bool)) == 0 ||
  135|  2.03M|                   memcmp(pData, &falsebool, sizeof(bool)) == 0);
  136|  2.03M|        }
  137|  31.5M|        else if (PB_LTYPE_IS_SUBMSG(iter->type))
  ------------------
  |  |  300|  31.5M|#define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  299|  31.5M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  31.5M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define PB_LTYPE_IS_SUBMSG(x) (PB_LTYPE(x) == PB_LTYPE_SUBMESSAGE || \
  |  |  ------------------
  |  |  |  |  259|  63.0M|#define PB_LTYPE_SUBMESSAGE 0x08U
  |  |  ------------------
  |  |  |  Branch (300:32): [True: 103k, False: 31.4M]
  |  |  ------------------
  |  |  301|  31.5M|                               PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  299|  31.4M|#define PB_LTYPE(x) ((x) & PB_LTYPE_MASK)
  |  |  |  |  ------------------
  |  |  |  |  |  |  278|  31.4M|#define PB_LTYPE_MASK 0x0FU
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                              PB_LTYPE(x) == PB_LTYPE_SUBMSG_W_CB)
  |  |  ------------------
  |  |  |  |  264|  31.4M|#define PB_LTYPE_SUBMSG_W_CB 0x09U
  |  |  ------------------
  |  |  |  Branch (301:32): [True: 0, False: 31.4M]
  |  |  ------------------
  ------------------
  138|   103k|        {
  139|   103k|            validate_message(pData, 0, iter->submsg_desc);
  140|   103k|        }
  141|  34.1M|    }
  142|   344k|}
validate_message:
  145|   109k|{
  146|   109k|    pb_field_iter_t iter;
  147|       |
  148|   109k|    if (pb_field_iter_begin_const(&iter, msgtype, msg))
  ------------------
  |  Branch (148:9): [True: 63.4k, False: 45.7k]
  ------------------
  149|  63.4k|    {
  150|  63.4k|        do
  151|   639k|        {
  152|   639k|            if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  297|   639k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|   639k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          if (PB_ATYPE(iter.type) == PB_ATYPE_STATIC)
  ------------------
  |  |  292|   639k|#define PB_ATYPE_STATIC   0x00U
  ------------------
  |  Branch (152:17): [True: 5.99k, False: 633k]
  ------------------
  153|  5.99k|            {
  154|  5.99k|                validate_static(&iter);
  155|  5.99k|            }
  156|   633k|            else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  297|   633k|#define PB_ATYPE(x) ((x) & PB_ATYPE_MASK)
  |  |  ------------------
  |  |  |  |  295|   633k|#define PB_ATYPE_MASK     0xC0U
  |  |  ------------------
  ------------------
                          else if (PB_ATYPE(iter.type) == PB_ATYPE_POINTER)
  ------------------
  |  |  293|   633k|#define PB_ATYPE_POINTER  0x80U
  ------------------
  |  Branch (156:22): [True: 627k, False: 5.99k]
  ------------------
  157|   627k|            {
  158|   627k|                validate_pointer(&iter);
  159|   627k|            }
  160|   639k|        } while (pb_field_iter_next(&iter));
  ------------------
  |  Branch (160:18): [True: 576k, False: 63.4k]
  ------------------
  161|  63.4k|    }
  162|   109k|}

