jv_get_kind:
  102|  74.1M|jv_kind jv_get_kind(jv x) {
  103|  74.1M|  return JVP_KIND(x);
  ------------------
  |  |   90|  74.1M|#define JVP_KIND(j)   (JVP_FLAGS(j) & KIND_MASK)
  |  |  ------------------
  |  |  |  |   89|  74.1M|#define JVP_FLAGS(j)  ((j).kind_flags)
  |  |  ------------------
  |  |               #define JVP_KIND(j)   (JVP_FLAGS(j) & KIND_MASK)
  |  |  ------------------
  |  |  |  |   77|  74.1M|#define KIND_MASK   0xF
  |  |  ------------------
  ------------------
  104|  74.1M|}
jv_true:
  126|    391|jv jv_true(void) {
  127|    391|  return JV_TRUE;
  128|    391|}
jv_false:
  130|    258|jv jv_false(void) {
  131|    258|  return JV_FALSE;
  132|    258|}
jv_null:
  134|    275|jv jv_null(void) {
  135|    275|  return JV_NULL;
  136|    275|}
jv_invalid_with_msg:
  153|  3.90k|jv jv_invalid_with_msg(jv err) {
  154|  3.90k|  jvp_invalid* i = jv_mem_alloc(sizeof(jvp_invalid));
  155|  3.90k|  i->refcnt = JV_REFCNT_INIT;
  156|  3.90k|  i->errmsg = err;
  157|       |
  158|  3.90k|  jv x = {JVP_FLAGS_INVALID_MSG, 0, 0, 0, {&i->refcnt}};
  ------------------
  |  |  146|  3.90k|#define JVP_FLAGS_INVALID_MSG   JVP_MAKE_FLAGS(JV_KIND_INVALID, JVP_PAYLOAD_ALLOCATED)
  |  |  ------------------
  |  |  |  |   87|  3.90k|#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   77|  3.90k|#define KIND_MASK   0xF
  |  |  |  |  ------------------
  |  |  |  |               #define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   78|  3.90k|#define PFLAGS_MASK 0xF0
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  159|  3.90k|  return x;
  160|  3.90k|}
jv_invalid:
  162|  6.73M|jv jv_invalid(void) {
  163|  6.73M|  return JV_INVALID;
  164|  6.73M|}
jv_invalid_get_msg:
  166|  1.95k|jv jv_invalid_get_msg(jv inv) {
  167|  1.95k|  assert(JVP_HAS_KIND(inv, JV_KIND_INVALID));
  ------------------
  |  Branch (167:3): [True: 0, False: 1.95k]
  |  Branch (167:3): [True: 1.95k, False: 0]
  ------------------
  168|       |
  169|  1.95k|  jv x;
  170|  1.95k|  if (JVP_HAS_FLAGS(inv, JVP_FLAGS_INVALID_MSG)) {
  ------------------
  |  |   92|  1.95k|#define JVP_HAS_FLAGS(j, flags) (JVP_FLAGS(j) == flags)
  |  |  ------------------
  |  |  |  |   89|  1.95k|#define JVP_FLAGS(j)  ((j).kind_flags)
  |  |  ------------------
  |  |  |  Branch (92:33): [True: 1.95k, False: 0]
  |  |  ------------------
  ------------------
  171|  1.95k|    x = jv_copy(((jvp_invalid*)inv.u.ptr)->errmsg);
  172|  1.95k|  }
  173|      0|  else {
  174|      0|    x = jv_null();
  175|      0|  }
  176|       |
  177|  1.95k|  jv_free(inv);
  178|  1.95k|  return x;
  179|  1.95k|}
jv_invalid_has_msg:
  181|  4.97k|int jv_invalid_has_msg(jv inv) {
  182|  4.97k|  assert(JVP_HAS_KIND(inv, JV_KIND_INVALID));
  ------------------
  |  Branch (182:3): [True: 0, False: 4.97k]
  |  Branch (182:3): [True: 4.97k, False: 0]
  ------------------
  183|  4.97k|  int r = JVP_HAS_FLAGS(inv, JVP_FLAGS_INVALID_MSG);
  ------------------
  |  |   92|  4.97k|#define JVP_HAS_FLAGS(j, flags) (JVP_FLAGS(j) == flags)
  |  |  ------------------
  |  |  |  |   89|  4.97k|#define JVP_FLAGS(j)  ((j).kind_flags)
  |  |  ------------------
  ------------------
  184|  4.97k|  jv_free(inv);
  185|  4.97k|  return r;
  186|  4.97k|}
jv_tsd_dec_ctx_fini:
  491|      1|void jv_tsd_dec_ctx_fini(void) {
  492|      1|  jv_mem_free(pthread_getspecific(dec_ctx_key));
  493|       |  pthread_setspecific(dec_ctx_key, NULL);
  494|      1|}
jv_tsd_dec_ctx_init:
  496|      1|void jv_tsd_dec_ctx_init(void) {
  497|      1|  if (pthread_key_create(&dec_ctx_key, jv_mem_free) != 0) {
  ------------------
  |  Branch (497:7): [True: 0, False: 1]
  ------------------
  498|      0|    fprintf(stderr, "error: cannot create thread specific key");
  499|      0|    abort();
  500|      0|  }
  501|      1|  atexit(jv_tsd_dec_ctx_fini);
  502|      1|}
jv_number_with_literal:
  668|  6.54M|jv jv_number_with_literal(const char * literal) {
  669|  6.54M|  return jvp_literal_number_new(literal);
  670|  6.54M|}
jv_number:
  673|  1.72k|jv jv_number(double x) {
  674|  1.72k|  jv j = {
  675|  1.72k|#ifdef USE_DECNUM
  676|  1.72k|    JVP_FLAGS_NUMBER_NATIVE,
  ------------------
  |  |  205|  1.72k|#define JVP_FLAGS_NUMBER_NATIVE       JVP_MAKE_FLAGS(JV_KIND_NUMBER, JVP_MAKE_PFLAGS(JVP_NUMBER_NATIVE, 0))
  |  |  ------------------
  |  |  |  |   87|  3.44k|#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   77|  1.72k|#define KIND_MASK   0xF
  |  |  |  |  ------------------
  |  |  |  |               #define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   78|  1.72k|#define PFLAGS_MASK 0xF0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:61): [Folded, False: 1.72k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  677|       |#else
  678|       |    JV_KIND_NUMBER,
  679|       |#endif
  680|  1.72k|    0, 0, 0, {.number = x}
  681|  1.72k|  };
  682|  1.72k|  return j;
  683|  1.72k|}
jv_array_sized:
  982|   159k|jv jv_array_sized(int n) {
  983|   159k|  return jvp_array_new(n);
  984|   159k|}
jv_array:
  986|   159k|jv jv_array(void) {
  987|   159k|  return jv_array_sized(16);
  988|   159k|}
jv_array_length:
  990|  6.60M|int jv_array_length(jv j) {
  991|  6.60M|  assert(JVP_HAS_KIND(j, JV_KIND_ARRAY));
  ------------------
  |  Branch (991:3): [True: 0, False: 6.60M]
  |  Branch (991:3): [True: 6.60M, False: 0]
  ------------------
  992|  6.60M|  int len = jvp_array_length(j);
  993|  6.60M|  jv_free(j);
  994|  6.60M|  return len;
  995|  6.60M|}
jv_array_set:
 1010|  6.59M|jv jv_array_set(jv j, int idx, jv val) {
 1011|  6.59M|  assert(JVP_HAS_KIND(j, JV_KIND_ARRAY));
  ------------------
  |  Branch (1011:3): [True: 0, False: 6.59M]
  |  Branch (1011:3): [True: 6.59M, False: 0]
  ------------------
 1012|       |
 1013|  6.59M|  if (idx < 0)
  ------------------
  |  Branch (1013:7): [True: 0, False: 6.59M]
  ------------------
 1014|      0|    idx = jvp_array_length(j) + idx;
 1015|  6.59M|  if (idx < 0) {
  ------------------
  |  Branch (1015:7): [True: 0, False: 6.59M]
  ------------------
 1016|      0|    jv_free(j);
 1017|      0|    jv_free(val);
 1018|      0|    return jv_invalid_with_msg(jv_string("Out of bounds negative array index"));
 1019|      0|  }
 1020|  6.59M|  if (idx > (INT_MAX >> 2) - jvp_array_offset(j)) {
  ------------------
  |  Branch (1020:7): [True: 0, False: 6.59M]
  ------------------
 1021|      0|    jv_free(j);
 1022|      0|    jv_free(val);
 1023|      0|    return jv_invalid_with_msg(jv_string("Array index too large"));
 1024|      0|  }
 1025|       |  // copy/free of val,j coalesced
 1026|  6.59M|  jv* slot = jvp_array_write(&j, idx);
 1027|  6.59M|  jv_free(*slot);
 1028|  6.59M|  *slot = val;
 1029|  6.59M|  return j;
 1030|  6.59M|}
jv_array_append:
 1032|  6.59M|jv jv_array_append(jv j, jv val) {
 1033|       |  // copy/free of val,j coalesced
 1034|  6.59M|  return jv_array_set(j, jv_array_length(jv_copy(j)), val);
 1035|  6.59M|}
jv_string_sized:
 1317|  51.3k|jv jv_string_sized(const char* str, int len) {
 1318|  51.3k|  return
 1319|  51.3k|    jvp_utf8_is_valid(str, str+len) ?
  ------------------
  |  Branch (1319:5): [True: 45.4k, False: 5.86k]
  ------------------
 1320|  45.4k|    jvp_string_new(str, len) :
 1321|  51.3k|    jvp_string_copy_replace_bad(str, len);
 1322|  51.3k|}
jv_string:
 1328|     69|jv jv_string(const char* str) {
 1329|     69|  return jv_string_sized(str, strlen(str));
 1330|     69|}
jv_string_value:
 1486|  1.95k|const char* jv_string_value(jv j) {
 1487|  1.95k|  assert(JVP_HAS_KIND(j, JV_KIND_STRING));
  ------------------
  |  Branch (1487:3): [True: 0, False: 1.95k]
  |  Branch (1487:3): [True: 1.95k, False: 0]
  ------------------
 1488|  1.95k|  return jvp_string_ptr(j)->data;
 1489|  1.95k|}
jv_string_vfmt:
 1568|  3.83k|jv jv_string_vfmt(const char* fmt, va_list ap) {
 1569|  3.83k|  int size = 1024;
 1570|  4.19k|  while (1) {
  ------------------
  |  Branch (1570:10): [True: 4.19k, Folded]
  ------------------
 1571|  4.19k|    char* buf = jv_mem_alloc(size);
 1572|  4.19k|    va_list ap2;
 1573|  4.19k|    va_copy(ap2, ap);
 1574|  4.19k|    int n = vsnprintf(buf, size, fmt, ap2);
 1575|  4.19k|    va_end(ap2);
 1576|       |    /*
 1577|       |     * NOTE: here we support old vsnprintf()s that return -1 because the
 1578|       |     * buffer is too small.
 1579|       |     */
 1580|  4.19k|    if (n >= 0 && n < size) {
  ------------------
  |  Branch (1580:9): [True: 4.19k, False: 0]
  |  Branch (1580:19): [True: 3.83k, False: 366]
  ------------------
 1581|  3.83k|      jv ret = jv_string_sized(buf, n);
 1582|  3.83k|      jv_mem_free(buf);
 1583|  3.83k|      return ret;
 1584|  3.83k|    } else {
 1585|    366|      jv_mem_free(buf);
 1586|    366|      size = (n > 0) ? /* standard */ (n * 2) : /* not standard */ (size * 2);
  ------------------
  |  Branch (1586:14): [True: 366, False: 0]
  ------------------
 1587|    366|    }
 1588|  4.19k|  }
 1589|  3.83k|}
jv_string_fmt:
 1591|  1.95k|jv jv_string_fmt(const char* fmt, ...) {
 1592|  1.95k|  va_list args;
 1593|  1.95k|  va_start(args, fmt);
 1594|  1.95k|  jv res = jv_string_vfmt(fmt, args);
 1595|       |  va_end(args);
 1596|  1.95k|  return res;
 1597|  1.95k|}
jv_object:
 1854|   162k|jv jv_object(void) {
 1855|   162k|  return jvp_object_new(8);
 1856|   162k|}
jv_object_set:
 1883|  36.9k|jv jv_object_set(jv object, jv key, jv value) {
 1884|  36.9k|  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));
  ------------------
  |  Branch (1884:3): [True: 0, False: 36.9k]
  |  Branch (1884:3): [True: 36.9k, False: 0]
  ------------------
 1885|  36.9k|  assert(JVP_HAS_KIND(key, JV_KIND_STRING));
  ------------------
  |  Branch (1885:3): [True: 0, False: 36.9k]
  |  Branch (1885:3): [True: 36.9k, False: 0]
  ------------------
 1886|       |  // copy/free of object, key, value coalesced
 1887|  36.9k|  jv* slot;
 1888|  36.9k|  if (!jvp_object_write(&object, key, &slot)) {
  ------------------
  |  Branch (1888:7): [True: 0, False: 36.9k]
  ------------------
 1889|      0|    jv_free(object);
 1890|      0|    jv_free(value);
 1891|      0|    return jv_invalid_with_msg(jv_string("Object too big"));
 1892|      0|  }
 1893|  36.9k|  jv_free(*slot);
 1894|  36.9k|  *slot = value;
 1895|  36.9k|  return object;
 1896|  36.9k|}
jv_object_length:
 1906|  60.5k|int jv_object_length(jv object) {
 1907|  60.5k|  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));
  ------------------
  |  Branch (1907:3): [True: 0, False: 60.5k]
  |  Branch (1907:3): [True: 60.5k, False: 0]
  ------------------
 1908|  60.5k|  int n = jvp_object_length(object);
 1909|  60.5k|  jv_free(object);
 1910|  60.5k|  return n;
 1911|  60.5k|}
jv_copy:
 2007|  23.6M|jv jv_copy(jv j) {
 2008|  23.6M|  if (JVP_IS_ALLOCATED(j)) {
  ------------------
  |  |   95|  23.6M|#define JVP_IS_ALLOCATED(j) (j.kind_flags & JVP_PAYLOAD_ALLOCATED)
  |  |  ------------------
  |  |  |  Branch (95:29): [True: 23.6M, False: 4.97k]
  |  |  ------------------
  ------------------
 2009|  23.6M|    jvp_refcnt_inc(j.u.ptr);
 2010|  23.6M|  }
 2011|  23.6M|  return j;
 2012|  23.6M|}
jv_free:
 2019|  20.2M|void jv_free(jv j) {
 2020|  20.2M|  jv* pending = NULL;
 2021|  20.2M|  size_t len = 0, cap = 0;
 2022|  43.8M|  while (1) {
  ------------------
  |  Branch (2022:10): [True: 43.8M, Folded]
  ------------------
 2023|  43.8M|    switch (JVP_KIND(j)) {
  ------------------
  |  |   90|  43.8M|#define JVP_KIND(j)   (JVP_FLAGS(j) & KIND_MASK)
  |  |  ------------------
  |  |  |  |   89|  43.8M|#define JVP_FLAGS(j)  ((j).kind_flags)
  |  |  ------------------
  |  |               #define JVP_KIND(j)   (JVP_FLAGS(j) & KIND_MASK)
  |  |  ------------------
  |  |  |  |   77|  43.8M|#define KIND_MASK   0xF
  |  |  ------------------
  |  |  |  Branch (90:23): [True: 37.2M, False: 6.60M]
  |  |  ------------------
  ------------------
 2024|  6.79M|      case JV_KIND_ARRAY:
  ------------------
  |  Branch (2024:7): [True: 6.79M, False: 37.0M]
  ------------------
 2025|  6.79M|        if (jvp_refcnt_dec(j.u.ptr)) {
  ------------------
  |  Branch (2025:13): [True: 161k, False: 6.63M]
  ------------------
 2026|   161k|          jvp_array* arr = jvp_array_ptr(j);
 2027|   161k|          if (len + arr->length > cap) {
  ------------------
  |  Branch (2027:15): [True: 3.24k, False: 158k]
  ------------------
 2028|  3.24k|            cap = (len + arr->length) * 2;
 2029|  3.24k|            pending = jv_mem_realloc(pending, cap * sizeof(jv));
 2030|  3.24k|          }
 2031|  23.7M|          for (int i = 0; i < arr->length; i++)
  ------------------
  |  Branch (2031:27): [True: 23.5M, False: 161k]
  ------------------
 2032|  23.5M|            pending[len++] = arr->elements[i];
 2033|   161k|          jv_mem_free(arr);
 2034|   161k|        }
 2035|  6.79M|        break;
 2036|   369k|      case JV_KIND_OBJECT:
  ------------------
  |  Branch (2036:7): [True: 369k, False: 43.4M]
  ------------------
 2037|   369k|        if (jvp_refcnt_dec(j.u.ptr)) {
  ------------------
  |  Branch (2037:13): [True: 162k, False: 207k]
  ------------------
 2038|   162k|          int sz = jvp_object_size(j);
 2039|   162k|          if (len + sz > cap) {
  ------------------
  |  Branch (2039:15): [True: 95.2k, False: 67.2k]
  ------------------
 2040|  95.2k|            cap = (len + sz) * 2;
 2041|  95.2k|            pending = jv_mem_realloc(pending, cap * sizeof(jv));
 2042|  95.2k|          }
 2043|  1.48M|          for (int i = 0; i < sz; i++) {
  ------------------
  |  Branch (2043:27): [True: 1.32M, False: 162k]
  ------------------
 2044|  1.32M|            struct object_slot* slot = jvp_object_get_slot(j, i);
 2045|  1.32M|            if (jv_get_kind(slot->string) != JV_KIND_NULL) {
  ------------------
  |  Branch (2045:17): [True: 34.5k, False: 1.29M]
  ------------------
 2046|  34.5k|              jvp_string_free(slot->string);
 2047|  34.5k|              pending[len++] = slot->value;
 2048|  34.5k|            }
 2049|  1.32M|          }
 2050|   162k|          jv_mem_free(jvp_object_ptr(j));
 2051|   162k|        }
 2052|   369k|        break;
 2053|  6.73M|      case JV_KIND_INVALID:
  ------------------
  |  Branch (2053:7): [True: 6.73M, False: 37.1M]
  ------------------
 2054|  6.73M|        if (JVP_HAS_FLAGS(j, JVP_FLAGS_INVALID_MSG) && jvp_refcnt_dec(j.u.ptr)) {
  ------------------
  |  |   92|  13.4M|#define JVP_HAS_FLAGS(j, flags) (JVP_FLAGS(j) == flags)
  |  |  ------------------
  |  |  |  |   89|  6.73M|#define JVP_FLAGS(j)  ((j).kind_flags)
  |  |  ------------------
  |  |  |  Branch (92:33): [True: 7.73k, False: 6.73M]
  |  |  ------------------
  ------------------
  |  Branch (2054:56): [True: 3.90k, False: 3.83k]
  ------------------
 2055|  3.90k|          if (len + 1 > cap) {
  ------------------
  |  Branch (2055:15): [True: 3.90k, False: 0]
  ------------------
 2056|  3.90k|            cap = (len + 1) * 2;
 2057|  3.90k|            pending = jv_mem_realloc(pending, cap * sizeof(jv));
 2058|  3.90k|          }
 2059|  3.90k|          pending[len++] = ((jvp_invalid*)j.u.ptr)->errmsg;
 2060|  3.90k|          jv_mem_free(j.u.ptr);
 2061|  3.90k|        }
 2062|  6.73M|        break;
 2063|  18.5k|      case JV_KIND_STRING:
  ------------------
  |  Branch (2063:7): [True: 18.5k, False: 43.8M]
  ------------------
 2064|  18.5k|        jvp_string_free(j);
 2065|  18.5k|        break;
 2066|  23.3M|      case JV_KIND_NUMBER:
  ------------------
  |  Branch (2066:7): [True: 23.3M, False: 20.5M]
  ------------------
 2067|  23.3M|        jvp_number_free(j);
 2068|  23.3M|        break;
 2069|  43.8M|    }
 2070|  43.8M|    if (len == 0) break;
  ------------------
  |  Branch (2070:9): [True: 20.2M, False: 23.5M]
  ------------------
 2071|  23.5M|    j = pending[--len];
 2072|  23.5M|  }
 2073|  20.2M|  jv_mem_free(pending);
 2074|  20.2M|}
jv.c:jvp_literal_number_new:
  572|  6.54M|static jv jvp_literal_number_new(const char * literal) {
  573|  6.54M|  size_t len = strlen(literal);
  574|  6.54M|  if (len > DEC_MAX_DIGITS)
  ------------------
  |  |   88|  6.54M|  #define DEC_MAX_DIGITS 999999999
  ------------------
  |  Branch (574:7): [True: 0, False: 6.54M]
  ------------------
  575|      0|    return JV_INVALID;
  576|  6.54M|  jvp_literal_number* n = jvp_literal_number_alloc(len);
  577|       |
  578|  6.54M|  decContext *ctx = DEC_CONTEXT();
  ------------------
  |  |  487|  6.54M|#define DEC_CONTEXT() tsd_dec_ctx_get(&dec_ctx_key)
  ------------------
  579|  6.54M|  decContextClearStatus(ctx, DEC_Conversion_syntax);
  ------------------
  |  |  128|  6.54M|    #define DEC_Conversion_syntax    0x00000001
  ------------------
  580|  6.54M|  decNumberFromString(&n->num_decimal, literal, ctx);
  581|       |
  582|  6.54M|  if (ctx->status & DEC_Conversion_syntax) {
  ------------------
  |  |  128|  6.54M|    #define DEC_Conversion_syntax    0x00000001
  ------------------
  |  Branch (582:7): [True: 600, False: 6.54M]
  ------------------
  583|    600|    jv_mem_free(n);
  584|    600|    return JV_INVALID;
  585|    600|  }
  586|  6.54M|  if (decNumberIsNaN(&n->num_decimal)) {
  ------------------
  |  |  172|  6.54M|  #define decNumberIsNaN(dn)       (((dn)->bits&(DECNAN|DECSNAN))!=0)
  |  |  ------------------
  |  |  |  |   33|  6.54M|  #define DECNAN    0x20      /* 1=NaN                                */
  |  |  ------------------
  |  |                 #define decNumberIsNaN(dn)       (((dn)->bits&(DECNAN|DECSNAN))!=0)
  |  |  ------------------
  |  |  |  |   34|  6.54M|  #define DECSNAN   0x10      /* 1=sNaN                               */
  |  |  ------------------
  |  |  |  Branch (172:36): [True: 1.77k, False: 6.54M]
  |  |  ------------------
  ------------------
  587|       |    // Reject NaN with payload.
  588|  1.77k|    if (n->num_decimal.digits > 1 || *n->num_decimal.lsu != 0) {
  ------------------
  |  Branch (588:9): [True: 43, False: 1.72k]
  |  Branch (588:38): [True: 4, False: 1.72k]
  ------------------
  589|     47|      jv_mem_free(n);
  590|     47|      return JV_INVALID;
  591|     47|    }
  592|  1.72k|    jv_mem_free(n);
  593|  1.72k|    return jv_number(NAN);
  594|  1.77k|  }
  595|       |
  596|  6.54M|  jv r = {JVP_FLAGS_NUMBER_LITERAL, 0, 0, 0, {&n->refcnt}};
  ------------------
  |  |  206|  6.54M|#define JVP_FLAGS_NUMBER_LITERAL      JVP_MAKE_FLAGS(JV_KIND_NUMBER, JVP_MAKE_PFLAGS(JVP_NUMBER_DECIMAL, 1))
  |  |  ------------------
  |  |  |  |   87|  13.0M|#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   77|  6.54M|#define KIND_MASK   0xF
  |  |  |  |  ------------------
  |  |  |  |               #define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   78|  6.54M|#define PFLAGS_MASK 0xF0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:61): [True: 6.54M, Folded]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  597|  6.54M|  return r;
  598|  6.54M|}
jv.c:jvp_literal_number_ptr:
  547|  6.54M|static jvp_literal_number* jvp_literal_number_ptr(jv j) {
  548|  6.54M|  assert(JVP_HAS_FLAGS(j, JVP_FLAGS_NUMBER_LITERAL));
  ------------------
  |  Branch (548:3): [True: 0, Folded]
  |  Branch (548:3): [True: 0, False: 6.54M]
  |  Branch (548:3): [True: 6.54M, Folded]
  |  Branch (548:3): [True: 6.54M, False: 0]
  ------------------
  549|  6.54M|  return (jvp_literal_number*)j.u.ptr;
  550|  6.54M|}
jv.c:jvp_literal_number_alloc:
  557|  6.54M|static jvp_literal_number* jvp_literal_number_alloc(unsigned literal_length) {
  558|       |  /* The number of units needed is ceil(DECNUMDIGITS/DECDPUN)         */
  559|  6.54M|  int units = ((literal_length+DECDPUN-1)/DECDPUN);
  ------------------
  |  |   43|  6.54M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
                int units = ((literal_length+DECDPUN-1)/DECDPUN);
  ------------------
  |  |   43|  6.54M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  560|       |
  561|  6.54M|  jvp_literal_number* n = jv_mem_alloc(
  562|  6.54M|    sizeof(jvp_literal_number)
  563|  6.54M|    + sizeof(decNumberUnit) * units
  564|  6.54M|  );
  565|       |
  566|  6.54M|  n->refcnt = JV_REFCNT_INIT;
  567|  6.54M|  n->num_double = NAN;
  568|       |  n->literal_data = NULL;
  569|  6.54M|  return n;
  570|  6.54M|}
jv.c:tsd_dec_ctx_get:
  504|  6.54M|static decContext* tsd_dec_ctx_get(pthread_key_t *key) {
  505|  6.54M|  pthread_once(&dec_ctx_once, jv_tsd_dec_ctx_init); // cannot fail
  506|  6.54M|  decContext *ctx = (decContext*)pthread_getspecific(*key);
  507|  6.54M|  if (ctx) {
  ------------------
  |  Branch (507:7): [True: 6.54M, False: 1]
  ------------------
  508|  6.54M|    return ctx;
  509|  6.54M|  }
  510|       |
  511|      1|  ctx = malloc(sizeof(decContext));
  512|      1|  if (ctx) {
  ------------------
  |  Branch (512:7): [True: 1, False: 0]
  ------------------
  513|      1|    if (key == &dec_ctx_key)
  ------------------
  |  Branch (513:9): [True: 1, False: 0]
  ------------------
  514|      1|    {
  515|      1|      decContextDefault(ctx, DEC_INIT_BASE);
  ------------------
  |  |  227|      1|  #define DEC_INIT_BASE         0
  ------------------
  516|       |      // make sure (Int)D2U(rhs->exponent-lhs->exponent) does not overflow
  517|      1|      ctx->digits = MIN(DEC_MAX_DIGITS,
  ------------------
  |  |   71|      1|  ({ __typeof__ (a) _a = (a); \
  |  |   72|      1|   __typeof__ (b) _b = (b); \
  |  |   73|      1|   _a < _b ? _a : _b; })
  |  |  ------------------
  |  |  |  Branch (73:4): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  518|      1|          INT32_MAX - (DECDPUN - 1) - (ctx->emax - ctx->emin - 1));
  519|      1|      ctx->traps = 0; /*no errors*/
  520|      1|    }
  521|      1|    if (pthread_setspecific(*key, ctx) != 0) {
  ------------------
  |  Branch (521:9): [True: 0, False: 1]
  ------------------
  522|      0|      fprintf(stderr, "error: cannot store thread specific data");
  523|      0|      abort();
  524|      0|    }
  525|      1|  }
  526|      1|  return ctx;
  527|      1|}
jv.c:jvp_array_new:
  840|   159k|static jv jvp_array_new(unsigned size) {
  841|   159k|  jv r = {JVP_FLAGS_ARRAY, 0, 0, 0, {&jvp_array_alloc(size)->refcnt}};
  ------------------
  |  |  813|   159k|#define JVP_FLAGS_ARRAY   JVP_MAKE_FLAGS(JV_KIND_ARRAY, JVP_PAYLOAD_ALLOCATED)
  |  |  ------------------
  |  |  |  |   87|   159k|#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   77|   159k|#define KIND_MASK   0xF
  |  |  |  |  ------------------
  |  |  |  |               #define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   78|   159k|#define PFLAGS_MASK 0xF0
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  842|   159k|  return r;
  843|   159k|}
jv.c:jvp_array_alloc:
  832|   161k|static jvp_array* jvp_array_alloc(unsigned size) {
  833|   161k|  jvp_array* a = jv_mem_alloc(sizeof(jvp_array) + sizeof(jv) * size);
  834|   161k|  a->refcnt.count = 1;
  835|   161k|  a->length = 0;
  836|   161k|  a->alloc_length = size;
  837|   161k|  return a;
  838|   161k|}
jv.c:jvp_array_length:
  845|  23.5M|static int jvp_array_length(jv a) {
  846|  23.5M|  assert(JVP_HAS_KIND(a, JV_KIND_ARRAY));
  ------------------
  |  Branch (846:3): [True: 0, False: 23.5M]
  |  Branch (846:3): [True: 23.5M, False: 0]
  ------------------
  847|  23.5M|  return a.size;
  848|  23.5M|}
jv.c:jvp_array_offset:
  850|  30.1M|static int jvp_array_offset(jv a) {
  851|  30.1M|  assert(JVP_HAS_KIND(a, JV_KIND_ARRAY));
  ------------------
  |  Branch (851:3): [True: 0, False: 30.1M]
  |  Branch (851:3): [True: 30.1M, False: 0]
  ------------------
  852|  30.1M|  return a.offset;
  853|  30.1M|}
jv.c:jvp_array_write:
  866|  6.59M|static jv* jvp_array_write(jv* a, int i) {
  867|  6.59M|  assert(i >= 0);
  ------------------
  |  Branch (867:3): [True: 0, False: 6.59M]
  |  Branch (867:3): [True: 6.59M, False: 0]
  ------------------
  868|  6.59M|  jvp_array* array = jvp_array_ptr(*a);
  869|       |
  870|  6.59M|  int pos = i + jvp_array_offset(*a);
  871|  6.59M|  if (pos < array->alloc_length && jvp_refcnt_unshared(a->u.ptr)) {
  ------------------
  |  Branch (871:7): [True: 6.59M, False: 2.22k]
  |  Branch (871:36): [True: 6.59M, False: 0]
  ------------------
  872|       |    // use existing array space
  873|  13.1M|    for (int j = array->length; j <= pos; j++) {
  ------------------
  |  Branch (873:33): [True: 6.59M, False: 6.59M]
  ------------------
  874|  6.59M|      array->elements[j] = JV_NULL;
  875|  6.59M|    }
  876|  6.59M|    array->length = imax(pos + 1, array->length);
  877|  6.59M|    a->size = imax(i + 1, a->size);
  878|  6.59M|    return &array->elements[pos];
  879|  6.59M|  } else {
  880|       |    // allocate a new array
  881|  2.22k|    int new_length = imax(i + 1, jvp_array_length(*a));
  882|  2.22k|    jvp_array* new_array = jvp_array_alloc(ARRAY_SIZE_ROUND_UP(new_length));
  ------------------
  |  |  812|  2.22k|#define ARRAY_SIZE_ROUND_UP(n) (((n)*3)/2)
  ------------------
  883|  2.22k|    int j;
  884|  16.9M|    for (j = 0; j < jvp_array_length(*a); j++) {
  ------------------
  |  Branch (884:17): [True: 16.9M, False: 2.22k]
  ------------------
  885|  16.9M|      new_array->elements[j] =
  886|  16.9M|        jv_copy(array->elements[j + jvp_array_offset(*a)]);
  887|  16.9M|    }
  888|  4.44k|    for (; j < new_length; j++) {
  ------------------
  |  Branch (888:12): [True: 2.22k, False: 2.22k]
  ------------------
  889|  2.22k|      new_array->elements[j] = JV_NULL;
  890|  2.22k|    }
  891|  2.22k|    new_array->length = new_length;
  892|  2.22k|    jv_free(*a);
  893|  2.22k|    jv new_jv = {JVP_FLAGS_ARRAY, 0, 0, new_length, {&new_array->refcnt}};
  ------------------
  |  |  813|  2.22k|#define JVP_FLAGS_ARRAY   JVP_MAKE_FLAGS(JV_KIND_ARRAY, JVP_PAYLOAD_ALLOCATED)
  |  |  ------------------
  |  |  |  |   87|  2.22k|#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   77|  2.22k|#define KIND_MASK   0xF
  |  |  |  |  ------------------
  |  |  |  |               #define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   78|  2.22k|#define PFLAGS_MASK 0xF0
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  894|  2.22k|    *a = new_jv;
  895|  2.22k|    return &new_array->elements[i];
  896|  2.22k|  }
  897|  6.59M|}
jv.c:jvp_refcnt_unshared:
   72|  6.63M|static int jvp_refcnt_unshared(jv_refcnt* c) {
   73|  6.63M|  assert(c->count > 0);
  ------------------
  |  Branch (73:3): [True: 0, False: 6.63M]
  |  Branch (73:3): [True: 6.63M, False: 0]
  ------------------
   74|  6.63M|  return c->count == 1;
   75|  6.63M|}
jv.c:imax:
  815|  13.1M|static int imax(int a, int b) {
  816|  13.1M|  if (a>b) return a;
  ------------------
  |  Branch (816:7): [True: 13.1M, False: 0]
  ------------------
  817|      0|  else return b;
  818|  13.1M|}
jv.c:jvp_string_new:
 1141|  45.4k|static jv jvp_string_new(const char* data, uint32_t length) {
 1142|  45.4k|  jvp_string* s = jvp_string_alloc(length);
 1143|  45.4k|  s->length_hashed = length << 1;
 1144|  45.4k|  if (data != NULL)
  ------------------
  |  Branch (1144:7): [True: 45.4k, False: 0]
  ------------------
 1145|  45.4k|    memcpy(s->data, data, length);
 1146|  45.4k|  s->data[length] = 0;
 1147|  45.4k|  jv r = {JVP_FLAGS_STRING, 0, 0, 0, {&s->refcnt}};
  ------------------
  |  | 1087|  45.4k|#define JVP_FLAGS_STRING  JVP_MAKE_FLAGS(JV_KIND_STRING, JVP_PAYLOAD_ALLOCATED)
  |  |  ------------------
  |  |  |  |   87|  45.4k|#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   77|  45.4k|#define KIND_MASK   0xF
  |  |  |  |  ------------------
  |  |  |  |               #define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   78|  45.4k|#define PFLAGS_MASK 0xF0
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1148|  45.4k|  return r;
 1149|  45.4k|}
jv.c:jvp_string_alloc:
 1104|  51.3k|static jvp_string* jvp_string_alloc(uint32_t size) {
 1105|  51.3k|  jvp_string* s = jv_mem_alloc(sizeof(jvp_string) + size + 1);
 1106|  51.3k|  s->refcnt.count = 1;
 1107|  51.3k|  s->alloc_length = size;
 1108|  51.3k|  return s;
 1109|  51.3k|}
jv.c:jvp_string_copy_replace_bad:
 1112|  5.86k|static jv jvp_string_copy_replace_bad(const char* data, uint32_t length) {
 1113|  5.86k|  const char* end = data + length;
 1114|  5.86k|  const char* i = data;
 1115|       |
 1116|       |  // worst case: all bad bytes, each becomes a 3-byte U+FFFD
 1117|  5.86k|  uint64_t maxlength = (uint64_t)length * 3 + 1;
 1118|  5.86k|  if (maxlength >= INT_MAX) {
  ------------------
  |  Branch (1118:7): [True: 0, False: 5.86k]
  ------------------
 1119|      0|    return jv_invalid_with_msg(jv_string("String too long"));
 1120|      0|  }
 1121|       |
 1122|  5.86k|  jvp_string* s = jvp_string_alloc(maxlength);
 1123|  5.86k|  char* out = s->data;
 1124|  5.86k|  int c = 0;
 1125|       |
 1126|  28.5M|  while ((i = jvp_utf8_next(i, end, &c))) {
  ------------------
  |  Branch (1126:10): [True: 28.5M, False: 5.86k]
  ------------------
 1127|  28.5M|    if (c == -1) {
  ------------------
  |  Branch (1127:9): [True: 2.96M, False: 25.5M]
  ------------------
 1128|  2.96M|      c = 0xFFFD; // U+FFFD REPLACEMENT CHARACTER
 1129|  2.96M|    }
 1130|  28.5M|    out += jvp_utf8_encode(c, out);
 1131|  28.5M|    assert(out < s->data + maxlength);
  ------------------
  |  Branch (1131:5): [True: 0, False: 28.5M]
  |  Branch (1131:5): [True: 28.5M, False: 0]
  ------------------
 1132|  28.5M|  }
 1133|  5.86k|  length = out - s->data;
 1134|  5.86k|  s->data[length] = 0;
 1135|  5.86k|  s->length_hashed = length << 1;
 1136|  5.86k|  jv r = {JVP_FLAGS_STRING, 0, 0, 0, {&s->refcnt}};
  ------------------
  |  | 1087|  5.86k|#define JVP_FLAGS_STRING  JVP_MAKE_FLAGS(JV_KIND_STRING, JVP_PAYLOAD_ALLOCATED)
  |  |  ------------------
  |  |  |  |   87|  5.86k|#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   77|  5.86k|#define KIND_MASK   0xF
  |  |  |  |  ------------------
  |  |  |  |               #define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   78|  5.86k|#define PFLAGS_MASK 0xF0
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1137|  5.86k|  return r;
 1138|  5.86k|}
jv.c:jvp_string_length:
 1168|  44.1k|static uint32_t jvp_string_length(jvp_string* s) {
 1169|  44.1k|  return s->length_hashed >> 1;
 1170|  44.1k|}
jv.c:jvp_string_ptr:
 1099|   255k|static jvp_string* jvp_string_ptr(jv a) {
 1100|   255k|  assert(JVP_HAS_KIND(a, JV_KIND_STRING));
  ------------------
  |  Branch (1100:3): [True: 0, False: 255k]
  |  Branch (1100:3): [True: 255k, False: 0]
  ------------------
 1101|   255k|  return (jvp_string*)a.u.ptr;
 1102|   255k|}
jv.c:jvp_string_hash:
 1245|   192k|static uint32_t jvp_string_hash(jv jstr) {
 1246|   192k|  jvp_string* str = jvp_string_ptr(jstr);
 1247|   192k|  if (str->length_hashed & 1)
  ------------------
  |  Branch (1247:7): [True: 155k, False: 36.9k]
  ------------------
 1248|   155k|    return str->hash;
 1249|       |
 1250|       |  /* The following is based on MurmurHash3.
 1251|       |     MurmurHash3 was written by Austin Appleby, and is placed
 1252|       |     in the public domain. */
 1253|       |
 1254|  36.9k|  const uint8_t* data = (const uint8_t*)str->data;
 1255|  36.9k|  int len = (int)jvp_string_length(str);
 1256|  36.9k|  const int nblocks = len / 4;
 1257|       |
 1258|  36.9k|  uint32_t h1 = jvp_hash_seed();
 1259|       |
 1260|  36.9k|  const uint32_t c1 = 0xcc9e2d51;
 1261|  36.9k|  const uint32_t c2 = 0x1b873593;
 1262|  36.9k|  const uint32_t* blocks = (const uint32_t *)(data + nblocks*4);
 1263|       |
 1264|  1.10M|  for(int i = -nblocks; i; i++) {
  ------------------
  |  Branch (1264:25): [True: 1.07M, False: 36.9k]
  ------------------
 1265|  1.07M|    uint32_t k1 = blocks[i]; //FIXME: endianness/alignment
 1266|       |
 1267|  1.07M|    k1 *= c1;
 1268|  1.07M|    k1 = rotl32(k1,15);
 1269|  1.07M|    k1 *= c2;
 1270|       |
 1271|  1.07M|    h1 ^= k1;
 1272|  1.07M|    h1 = rotl32(h1,13);
 1273|  1.07M|    h1 = h1*5+0xe6546b64;
 1274|  1.07M|  }
 1275|       |
 1276|  36.9k|  const uint8_t* tail = (const uint8_t*)(data + nblocks*4);
 1277|       |
 1278|  36.9k|  uint32_t k1 = 0;
 1279|       |
 1280|  36.9k|  switch(len & 3) {
  ------------------
  |  Branch (1280:10): [True: 27.6k, False: 9.27k]
  ------------------
 1281|  8.31k|  case 3: k1 ^= tail[2] << 16;
  ------------------
  |  Branch (1281:3): [True: 8.31k, False: 28.6k]
  ------------------
 1282|  8.31k|          JQ_FALLTHROUGH;
  ------------------
  |  |   14|  8.31k|# define JQ_FALLTHROUGH __attribute__((fallthrough))
  ------------------
 1283|  15.1k|  case 2: k1 ^= tail[1] << 8;
  ------------------
  |  Branch (1283:3): [True: 6.81k, False: 30.1k]
  ------------------
 1284|  15.1k|          JQ_FALLTHROUGH;
  ------------------
  |  |   14|  15.1k|# define JQ_FALLTHROUGH __attribute__((fallthrough))
  ------------------
 1285|  27.6k|  case 1: k1 ^= tail[0];
  ------------------
  |  Branch (1285:3): [True: 12.5k, False: 24.4k]
  ------------------
 1286|  27.6k|          k1 *= c1; k1 = rotl32(k1,15); k1 *= c2; h1 ^= k1;
 1287|  36.9k|  }
 1288|       |
 1289|  36.9k|  h1 ^= len;
 1290|       |
 1291|  36.9k|  h1 ^= h1 >> 16;
 1292|  36.9k|  h1 *= 0x85ebca6b;
 1293|  36.9k|  h1 ^= h1 >> 13;
 1294|  36.9k|  h1 *= 0xc2b2ae35;
 1295|  36.9k|  h1 ^= h1 >> 16;
 1296|       |
 1297|  36.9k|  str->length_hashed |= 1;
 1298|  36.9k|  str->hash = h1;
 1299|       |
 1300|  36.9k|  return h1;
 1301|  36.9k|}
jv.c:jvp_hash_seed:
 1236|  36.9k|static uint32_t jvp_hash_seed(void) {
 1237|  36.9k|  pthread_once(&hash_seed_once, jvp_hash_seed_init);
 1238|  36.9k|  return hash_seed;
 1239|  36.9k|}
jv.c:jvp_hash_seed_init:
 1211|      1|static void jvp_hash_seed_init(void) {
 1212|      1|  uint32_t seed;
 1213|       |  /* Prefer getentropy() over arc4random(): glibc's arc4random() aborts the
 1214|       |   * process when the kernel lacks getrandom(2) (#3584), while getentropy()
 1215|       |   * merely fails, letting us fall back to /dev/urandom. */
 1216|      1|#if defined(HAVE_GETENTROPY)
 1217|      1|  if (getentropy(&seed, sizeof(seed)) == 0) {
  ------------------
  |  Branch (1217:7): [True: 1, False: 0]
  ------------------
 1218|      1|    hash_seed = seed;
 1219|      1|    return;
 1220|      1|  }
 1221|       |#elif defined(HAVE_ARC4RANDOM)
 1222|       |  hash_seed = arc4random();
 1223|       |  return;
 1224|       |#endif
 1225|      0|  int fd = open("/dev/urandom", O_RDONLY);
 1226|      0|  if (fd >= 0) {
  ------------------
  |  Branch (1226:7): [True: 0, False: 0]
  ------------------
 1227|      0|    if (read(fd, &seed, sizeof(seed)) != 4)
  ------------------
  |  Branch (1227:9): [True: 0, False: 0]
  ------------------
 1228|      0|      seed = (uint32_t)getpid() ^ (uint32_t)time(NULL);
 1229|      0|    close(fd);
 1230|      0|  } else {
 1231|       |    seed = (uint32_t)getpid() ^ (uint32_t)time(NULL);
 1232|      0|  }
 1233|      0|  hash_seed = seed;
 1234|      0|}
jv.c:rotl32:
 1241|  2.17M|static uint32_t rotl32 (uint32_t x, int8_t r){
 1242|  2.17M|  return (x << r) | (x >> (32 - r));
 1243|  2.17M|}
jv.c:jvp_object_new:
 1620|   164k|static jv jvp_object_new(int size) {
 1621|       |  // Allocates an object of (size) slots and (size*2) hash buckets.
 1622|       |
 1623|       |  // size must be a power of two
 1624|   164k|  assert(size > 0 && (size & (size - 1)) == 0);
  ------------------
  |  Branch (1624:3): [True: 0, False: 164k]
  |  Branch (1624:3): [True: 0, False: 0]
  |  Branch (1624:3): [True: 164k, False: 0]
  |  Branch (1624:3): [True: 164k, False: 0]
  ------------------
 1625|       |
 1626|   164k|  jvp_object* obj = jv_mem_alloc(sizeof(jvp_object) +
 1627|   164k|                                 sizeof(struct object_slot) * size +
 1628|   164k|                                 sizeof(int) * (size * 2));
 1629|   164k|  obj->refcnt.count = 1;
 1630|  1.51M|  for (int i=0; i<size; i++) {
  ------------------
  |  Branch (1630:17): [True: 1.35M, False: 164k]
  ------------------
 1631|  1.35M|    obj->elements[i].next = i - 1;
 1632|  1.35M|    obj->elements[i].string = JV_NULL;
 1633|  1.35M|    obj->elements[i].hash = 0;
 1634|  1.35M|    obj->elements[i].value = JV_NULL;
 1635|  1.35M|  }
 1636|   164k|  obj->next_free = 0;
 1637|   164k|  int* hashbuckets = (int*)(&obj->elements[size]);
 1638|  2.87M|  for (int i=0; i<size*2; i++) {
  ------------------
  |  Branch (1638:17): [True: 2.70M, False: 164k]
  ------------------
 1639|  2.70M|    hashbuckets[i] = -1;
 1640|  2.70M|  }
 1641|   164k|  jv r = {JVP_FLAGS_OBJECT, 0, 0, size, {&obj->refcnt}};
  ------------------
  |  | 1603|   164k|#define JVP_FLAGS_OBJECT  JVP_MAKE_FLAGS(JV_KIND_OBJECT, JVP_PAYLOAD_ALLOCATED)
  |  |  ------------------
  |  |  |  |   87|   164k|#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   77|   164k|#define KIND_MASK   0xF
  |  |  |  |  ------------------
  |  |  |  |               #define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   78|   164k|#define PFLAGS_MASK 0xF0
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1642|   164k|  return r;
 1643|   164k|}
jv.c:jvp_object_find_bucket:
 1664|  65.8k|static int* jvp_object_find_bucket(jv object, jv key) {
 1665|  65.8k|  return jvp_object_buckets(object) + (jvp_object_mask(object) & jvp_string_hash(key));
 1666|  65.8k|}
jv.c:jvp_object_buckets:
 1660|  65.8k|static int* jvp_object_buckets(jv o) {
 1661|  65.8k|  return (int*)(&jvp_object_ptr(o)->elements[o.size]);
 1662|  65.8k|}
jv.c:jvp_object_mask:
 1650|  65.8k|static uint32_t jvp_object_mask(jv o) {
 1651|  65.8k|  assert(JVP_HAS_KIND(o, JV_KIND_OBJECT));
  ------------------
  |  Branch (1651:3): [True: 0, False: 65.8k]
  |  Branch (1651:3): [True: 65.8k, False: 0]
  ------------------
 1652|  65.8k|  return (o.size * 2) - 1;
 1653|  65.8k|}
jv.c:jvp_object_find_slot:
 1678|  65.8k|static struct object_slot* jvp_object_find_slot(jv object, jv keystr, int* bucket) {
 1679|  65.8k|  uint32_t hash = jvp_string_hash(keystr);
 1680|  65.8k|  for (struct object_slot* curr = jvp_object_get_slot(object, *bucket);
 1681|  75.5k|       curr;
  ------------------
  |  Branch (1681:8): [True: 12.1k, False: 63.4k]
  ------------------
 1682|  65.8k|       curr = jvp_object_next_slot(object, curr)) {
 1683|  12.1k|    if (curr->hash == hash && jvp_string_equal(keystr, curr->string)) {
  ------------------
  |  Branch (1683:9): [True: 2.42k, False: 9.71k]
  |  Branch (1683:31): [True: 2.42k, False: 0]
  ------------------
 1684|  2.42k|      return curr;
 1685|  2.42k|    }
 1686|  12.1k|  }
 1687|  63.4k|  return 0;
 1688|  65.8k|}
jv.c:jvp_string_equal:
 1304|  2.42k|static int jvp_string_equal(jv a, jv b) {
 1305|  2.42k|  assert(JVP_HAS_KIND(a, JV_KIND_STRING));
  ------------------
  |  Branch (1305:3): [True: 0, False: 2.42k]
  |  Branch (1305:3): [True: 2.42k, False: 0]
  ------------------
 1306|  2.42k|  assert(JVP_HAS_KIND(b, JV_KIND_STRING));
  ------------------
  |  Branch (1306:3): [True: 0, False: 2.42k]
  |  Branch (1306:3): [True: 2.42k, False: 0]
  ------------------
 1307|  2.42k|  jvp_string* stra = jvp_string_ptr(a);
 1308|  2.42k|  jvp_string* strb = jvp_string_ptr(b);
 1309|  2.42k|  if (jvp_string_length(stra) != jvp_string_length(strb)) return 0;
  ------------------
  |  Branch (1309:7): [True: 0, False: 2.42k]
  ------------------
 1310|  2.42k|  return memcmp(stra->data, strb->data, jvp_string_length(stra)) == 0;
 1311|  2.42k|}
jv.c:jvp_object_next_slot:
 1674|  9.71k|static struct object_slot* jvp_object_next_slot(jv object, struct object_slot* slot) {
 1675|  9.71k|  return jvp_object_get_slot(object, slot->next);
 1676|  9.71k|}
jv.c:jvp_object_write:
 1760|  36.9k|static int jvp_object_write(jv* object, jv key, jv **valpp) {
 1761|  36.9k|  *object = jvp_object_unshare(*object);
 1762|  36.9k|  int* bucket = jvp_object_find_bucket(*object, key);
 1763|  36.9k|  struct object_slot* slot = jvp_object_find_slot(*object, key, bucket);
 1764|  36.9k|  if (slot) {
  ------------------
  |  Branch (1764:7): [True: 2.42k, False: 34.5k]
  ------------------
 1765|       |    // already has the key
 1766|  2.42k|    jvp_string_free(key);
 1767|  2.42k|    *valpp = &slot->value;
 1768|  2.42k|    return 1;
 1769|  2.42k|  }
 1770|  34.5k|  slot = jvp_object_add_slot(*object, key, bucket);
 1771|  34.5k|  if (slot) {
  ------------------
  |  Branch (1771:7): [True: 32.2k, False: 2.30k]
  ------------------
 1772|  32.2k|    slot->value = jv_invalid();
 1773|  32.2k|  } else {
 1774|  2.30k|    if (!jvp_object_rehash(object)) {
  ------------------
  |  Branch (1774:9): [True: 0, False: 2.30k]
  ------------------
 1775|      0|      jvp_string_free(key);
 1776|      0|      *valpp = NULL;
 1777|      0|      return 0;
 1778|      0|    }
 1779|  2.30k|    bucket = jvp_object_find_bucket(*object, key);
 1780|  2.30k|    assert(!jvp_object_find_slot(*object, key, bucket));
  ------------------
  |  Branch (1780:5): [True: 0, False: 2.30k]
  |  Branch (1780:5): [True: 2.30k, False: 0]
  ------------------
 1781|  2.30k|    slot = jvp_object_add_slot(*object, key, bucket);
 1782|  2.30k|    assert(slot);
  ------------------
  |  Branch (1782:5): [True: 0, False: 2.30k]
  |  Branch (1782:5): [True: 2.30k, False: 0]
  ------------------
 1783|  2.30k|    slot->value = jv_invalid();
 1784|  2.30k|  }
 1785|  34.5k|  *valpp = &slot->value;
 1786|  34.5k|  return 1;
 1787|  34.5k|}
jv.c:jvp_object_unshare:
 1734|  36.9k|static jv jvp_object_unshare(jv object) {
 1735|  36.9k|  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));
  ------------------
  |  Branch (1735:3): [True: 0, False: 36.9k]
  |  Branch (1735:3): [True: 36.9k, False: 0]
  ------------------
 1736|  36.9k|  if (jvp_refcnt_unshared(object.u.ptr))
  ------------------
  |  Branch (1736:7): [True: 36.9k, False: 0]
  ------------------
 1737|  36.9k|    return object;
 1738|       |
 1739|      0|  jv new_object = jvp_object_new(jvp_object_size(object));
 1740|      0|  jvp_object_ptr(new_object)->next_free = jvp_object_ptr(object)->next_free;
 1741|      0|  for (int i=0; i<jvp_object_size(new_object); i++) {
  ------------------
  |  Branch (1741:17): [True: 0, False: 0]
  ------------------
 1742|      0|    struct object_slot* old_slot = jvp_object_get_slot(object, i);
 1743|      0|    struct object_slot* new_slot = jvp_object_get_slot(new_object, i);
 1744|      0|    *new_slot = *old_slot;
 1745|      0|    if (jv_get_kind(old_slot->string) != JV_KIND_NULL) {
  ------------------
  |  Branch (1745:9): [True: 0, False: 0]
  ------------------
 1746|      0|      new_slot->string = jv_copy(old_slot->string);
 1747|      0|      new_slot->value = jv_copy(old_slot->value);
 1748|      0|    }
 1749|      0|  }
 1750|       |
 1751|      0|  int* old_buckets = jvp_object_buckets(object);
 1752|      0|  int* new_buckets = jvp_object_buckets(new_object);
 1753|      0|  memcpy(new_buckets, old_buckets, sizeof(int) * jvp_object_size(new_object)*2);
 1754|       |
 1755|      0|  jv_free(object);
 1756|      0|  assert(jvp_refcnt_unshared(new_object.u.ptr));
  ------------------
  |  Branch (1756:3): [True: 0, False: 0]
  |  Branch (1756:3): [True: 0, False: 0]
  ------------------
 1757|      0|  return new_object;
 1758|      0|}
jv.c:jvp_object_add_slot:
 1690|  63.4k|static struct object_slot* jvp_object_add_slot(jv object, jv key, int* bucket) {
 1691|  63.4k|  jvp_object* o = jvp_object_ptr(object);
 1692|  63.4k|  int newslot_idx = o->next_free;
 1693|  63.4k|  if (newslot_idx == jvp_object_size(object)) return 0;
  ------------------
  |  Branch (1693:7): [True: 2.30k, False: 61.1k]
  ------------------
 1694|  61.1k|  struct object_slot* newslot = jvp_object_get_slot(object, newslot_idx);
 1695|  61.1k|  o->next_free++;
 1696|  61.1k|  newslot->next = *bucket;
 1697|  61.1k|  *bucket = newslot_idx;
 1698|  61.1k|  newslot->hash = jvp_string_hash(key);
 1699|  61.1k|  newslot->string = key;
 1700|  61.1k|  return newslot;
 1701|  63.4k|}
jv.c:jvp_object_rehash:
 1711|  2.30k|static int jvp_object_rehash(jv *objectp) {
 1712|  2.30k|  jv object = *objectp;
 1713|  2.30k|  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));
  ------------------
  |  Branch (1713:3): [True: 0, False: 2.30k]
  |  Branch (1713:3): [True: 2.30k, False: 0]
  ------------------
 1714|  2.30k|  assert(jvp_refcnt_unshared(object.u.ptr));
  ------------------
  |  Branch (1714:3): [True: 0, False: 2.30k]
  |  Branch (1714:3): [True: 2.30k, False: 0]
  ------------------
 1715|  2.30k|  int size = jvp_object_size(object);
 1716|  2.30k|  if (size > INT_MAX >> 2)
  ------------------
  |  Branch (1716:7): [True: 0, False: 2.30k]
  ------------------
 1717|      0|    return 0;
 1718|  2.30k|  jv new_object = jvp_object_new(size * 2);
 1719|  28.9k|  for (int i=0; i<size; i++) {
  ------------------
  |  Branch (1719:17): [True: 26.6k, False: 2.30k]
  ------------------
 1720|  26.6k|    struct object_slot* slot = jvp_object_get_slot(object, i);
 1721|  26.6k|    if (jv_get_kind(slot->string) == JV_KIND_NULL) continue;
  ------------------
  |  Branch (1721:9): [True: 0, False: 26.6k]
  ------------------
 1722|  26.6k|    int* new_bucket = jvp_object_find_bucket(new_object, slot->string);
 1723|  26.6k|    assert(!jvp_object_find_slot(new_object, slot->string, new_bucket));
  ------------------
  |  Branch (1723:5): [True: 0, False: 26.6k]
  |  Branch (1723:5): [True: 26.6k, False: 0]
  ------------------
 1724|  26.6k|    struct object_slot* new_slot = jvp_object_add_slot(new_object, slot->string, new_bucket);
 1725|  26.6k|    assert(new_slot);
  ------------------
  |  Branch (1725:5): [True: 0, False: 26.6k]
  |  Branch (1725:5): [True: 26.6k, False: 0]
  ------------------
 1726|  26.6k|    new_slot->value = slot->value;
 1727|  26.6k|  }
 1728|       |  // references are transported, just drop the old table
 1729|  2.30k|  jv_mem_free(jvp_object_ptr(object));
 1730|  2.30k|  *objectp = new_object;
 1731|  2.30k|  return 1;
 1732|  2.30k|}
jv.c:jvp_object_length:
 1810|  60.5k|static int jvp_object_length(jv object) {
 1811|  60.5k|  int n = 0;
 1812|   545k|  for (int i=0; i<jvp_object_size(object); i++) {
  ------------------
  |  Branch (1812:17): [True: 485k, False: 60.5k]
  ------------------
 1813|   485k|    struct object_slot* slot = jvp_object_get_slot(object, i);
 1814|   485k|    if (jv_get_kind(slot->string) != JV_KIND_NULL) n++;
  ------------------
  |  Branch (1814:9): [True: 784, False: 484k]
  ------------------
 1815|   485k|  }
 1816|  60.5k|  return n;
 1817|  60.5k|}
jv.c:jvp_object_size:
 1655|  2.68M|static int jvp_object_size(jv o) {
 1656|  2.68M|  assert(JVP_HAS_KIND(o, JV_KIND_OBJECT));
  ------------------
  |  Branch (1656:3): [True: 0, False: 2.68M]
  |  Branch (1656:3): [True: 2.68M, False: 0]
  ------------------
 1657|  2.68M|  return o.size;
 1658|  2.68M|}
jv.c:jvp_object_get_slot:
 1668|  1.97M|static struct object_slot* jvp_object_get_slot(jv object, int slot) {
 1669|  1.97M|  assert(slot == -1 || (slot >= 0 && slot < jvp_object_size(object)));
  ------------------
  |  Branch (1669:3): [True: 0, False: 0]
  |  Branch (1669:3): [True: 0, False: 0]
  |  Branch (1669:3): [True: 1.97M, False: 0]
  |  Branch (1669:3): [True: 1.91M, False: 0]
  |  Branch (1669:3): [True: 1.91M, False: 0]
  |  Branch (1669:3): [True: 63.4k, False: 1.91M]
  ------------------
 1670|  1.97M|  if (slot == -1) return 0;
  ------------------
  |  Branch (1670:7): [True: 63.4k, False: 1.91M]
  ------------------
 1671|  1.91M|  else return &jvp_object_ptr(object)->elements[slot];
 1672|  1.97M|}
jv.c:jvp_refcnt_inc:
   63|  23.6M|static void jvp_refcnt_inc(jv_refcnt* c) {
   64|  23.6M|  c->count++;
   65|  23.6M|}
jv.c:jvp_refcnt_dec:
   67|  30.5M|static int jvp_refcnt_dec(jv_refcnt* c) {
   68|  30.5M|  c->count--;
   69|  30.5M|  return c->count == 0;
   70|  30.5M|}
jv.c:jvp_array_ptr:
  827|  6.75M|static jvp_array* jvp_array_ptr(jv a) {
  828|  6.75M|  assert(JVP_HAS_KIND(a, JV_KIND_ARRAY));
  ------------------
  |  Branch (828:3): [True: 0, False: 6.75M]
  |  Branch (828:3): [True: 6.75M, False: 0]
  ------------------
  829|  6.75M|  return (jvp_array*)a.u.ptr;
  830|  6.75M|}
jv.c:jvp_string_free:
 1161|  55.5k|static void jvp_string_free(jv js) {
 1162|  55.5k|  jvp_string* s = jvp_string_ptr(js);
 1163|  55.5k|  if (jvp_refcnt_dec(&s->refcnt)) {
  ------------------
  |  Branch (1163:7): [True: 51.3k, False: 4.17k]
  ------------------
 1164|  51.3k|    jv_mem_free(s);
 1165|  51.3k|  }
 1166|  55.5k|}
jv.c:jvp_object_ptr:
 1645|  2.20M|static jvp_object* jvp_object_ptr(jv o) {
 1646|  2.20M|  assert(JVP_HAS_KIND(o, JV_KIND_OBJECT));
  ------------------
  |  Branch (1646:3): [True: 0, False: 2.20M]
  |  Branch (1646:3): [True: 2.20M, False: 0]
  ------------------
 1647|  2.20M|  return (jvp_object*)o.u.ptr;
 1648|  2.20M|}
jv.c:jvp_number_free:
  685|  23.3M|static void jvp_number_free(jv j) {
  686|  23.3M|  assert(JVP_HAS_KIND(j, JV_KIND_NUMBER));
  ------------------
  |  Branch (686:3): [True: 0, False: 23.3M]
  |  Branch (686:3): [True: 23.3M, False: 0]
  ------------------
  687|  23.3M|#ifdef USE_DECNUM
  688|  23.3M|  if (JVP_HAS_FLAGS(j, JVP_FLAGS_NUMBER_LITERAL) && jvp_refcnt_dec(j.u.ptr)) {
  ------------------
  |  |   92|  46.6M|#define JVP_HAS_FLAGS(j, flags) (JVP_FLAGS(j) == flags)
  |  |  ------------------
  |  |  |  |   89|  23.3M|#define JVP_FLAGS(j)  ((j).kind_flags)
  |  |  ------------------
  |  |  |  Branch (92:33): [True: 23.3M, False: 4.34k]
  |  |  |  Branch (92:50): [True: 23.3M, Folded]
  |  |  ------------------
  ------------------
  |  Branch (688:53): [True: 6.54M, False: 16.7M]
  ------------------
  689|  6.54M|    jvp_literal_number* n = jvp_literal_number_ptr(j);
  690|  6.54M|    if (n->literal_data) {
  ------------------
  |  Branch (690:9): [True: 0, False: 6.54M]
  ------------------
  691|      0|      jv_mem_free(n->literal_data);
  692|      0|    }
  693|  6.54M|    jv_mem_free(n);
  694|  6.54M|  }
  695|  23.3M|#endif
  696|  23.3M|}

jv_parse.c:jv_is_valid:
   56|  58.9M|static int jv_is_valid(jv x) { return jv_get_kind(x) != JV_KIND_INVALID; }

jv_mem_alloc:
  141|  6.93M|void* jv_mem_alloc(size_t sz) {
  142|  6.93M|  void* p = malloc(sz);
  143|  6.93M|  if (!p) {
  ------------------
  |  Branch (143:7): [True: 0, False: 6.93M]
  ------------------
  144|      0|    memory_exhausted();
  145|      0|  }
  146|  6.93M|  return p;
  147|  6.93M|}
jv_mem_free:
  179|  27.1M|void jv_mem_free(void* p) {
  180|  27.1M|  free(p);
  181|  27.1M|}
jv_mem_realloc:
  183|   106k|void* jv_mem_realloc(void* p, size_t sz) {
  184|   106k|  p = realloc(p, sz);
  185|   106k|  if (!p) {
  ------------------
  |  Branch (185:7): [True: 0, False: 106k]
  ------------------
  186|      0|    memory_exhausted();
  187|      0|  }
  188|   106k|  return p;
  189|   106k|}

jvp_dtoa_context_init:
  522|  3.05k|void jvp_dtoa_context_init(struct dtoa_context* C) {
  523|  3.05k|  int i;
  524|  27.4k|  for (i=0; i<(int)(sizeof(C->freelist)/sizeof(C->freelist[0])); i++) {
  ------------------
  |  Branch (524:13): [True: 24.4k, False: 3.05k]
  ------------------
  525|  24.4k|    C->freelist[i] = 0;
  526|  24.4k|  }
  527|  3.05k|  C->p5s = 0;
  528|  3.05k|}
jvp_dtoa_context_free:
  569|  3.05k|void jvp_dtoa_context_free(struct dtoa_context* C) {
  570|  3.05k|  int k;
  571|  3.05k|  while (C->p5s) {
  ------------------
  |  Branch (571:10): [True: 0, False: 3.05k]
  ------------------
  572|      0|    Bigint* p5 = C->p5s;
  573|      0|    C->p5s = p5->next;
  574|      0|    Bfree(C, p5);
  575|      0|  }
  576|  27.4k|  for (k=0; k<(int)(sizeof(C->freelist)/sizeof(C->freelist[0])); k++) {
  ------------------
  |  Branch (576:13): [True: 24.4k, False: 3.05k]
  ------------------
  577|  24.4k|    while (C->freelist[k]) {
  ------------------
  |  Branch (577:12): [True: 0, False: 24.4k]
  ------------------
  578|      0|      Bigint* v = C->freelist[k];
  579|      0|      C->freelist[k] = v->next;
  580|      0|      FREE(v);
  ------------------
  |  |  200|      0|#define FREE jv_mem_free
  ------------------
  581|      0|    }
  582|  24.4k|  }
  583|  3.05k|}

jv_parser_set_buf:
  736|  3.05k|void jv_parser_set_buf(struct jv_parser* p, const char* buf, int length, int is_partial) {
  737|  3.05k|  assert((p->curr_buf == 0 || p->curr_buf_pos == p->curr_buf_length)
  ------------------
  |  Branch (737:3): [True: 3.05k, False: 0]
  |  Branch (737:3): [True: 0, False: 0]
  |  Branch (737:3): [True: 0, False: 0]
  |  Branch (737:3): [True: 3.05k, False: 0]
  |  Branch (737:3): [True: 0, False: 0]
  |  Branch (737:3): [True: 3.05k, False: 0]
  ------------------
  738|  3.05k|         && "previous buffer not exhausted");
  739|  3.05k|  p->curr_buf = buf;
  740|  3.05k|  p->curr_buf_length = length;
  741|  3.05k|  p->curr_buf_pos = 0;
  742|  3.05k|  p->curr_buf_is_partial = is_partial;
  743|  3.05k|}
jv_parser_next:
  757|  4.65k|jv jv_parser_next(struct jv_parser* p) {
  758|  4.65k|  if (p->eof)
  ------------------
  |  Branch (758:7): [True: 855, False: 3.80k]
  ------------------
  759|    855|    return jv_invalid();
  760|  3.80k|  if (!p->curr_buf)
  ------------------
  |  Branch (760:7): [True: 0, False: 3.80k]
  ------------------
  761|      0|    return jv_invalid(); // Need a buffer
  762|  3.80k|  jv value = jv_invalid();
  763|  3.80k|  if ((p->flags & JV_PARSE_STREAMING) && stream_check_done(p, &value))
  ------------------
  |  Branch (763:7): [True: 0, False: 3.80k]
  |  Branch (763:42): [True: 0, False: 0]
  ------------------
  764|      0|    return value;
  765|  3.80k|  char ch;
  766|  3.80k|  presult msg = 0;
  767|  72.7M|  while (!msg && p->curr_buf_pos < p->curr_buf_length) {
  ------------------
  |  Branch (767:10): [True: 72.7M, False: 1.18k]
  |  Branch (767:18): [True: 72.7M, False: 2.62k]
  ------------------
  768|  72.7M|    ch = p->curr_buf[p->curr_buf_pos++];
  769|  72.7M|    if (p->st == JV_PARSER_WAITING_FOR_RS) {
  ------------------
  |  Branch (769:9): [True: 0, False: 72.7M]
  ------------------
  770|      0|      if (ch == '\n') {
  ------------------
  |  Branch (770:11): [True: 0, False: 0]
  ------------------
  771|      0|        p->line++;
  772|      0|        p->column = 0;
  773|      0|      } else {
  774|      0|        p->column++;
  775|      0|      }
  776|      0|      if (ch == '\036')
  ------------------
  |  Branch (776:11): [True: 0, False: 0]
  ------------------
  777|      0|        p->st = JV_PARSER_NORMAL;
  778|      0|      continue; // need to resync, wait for RS
  779|      0|    }
  780|  72.7M|    msg = scan(p, ch, &value);
  781|  72.7M|  }
  782|  3.80k|  if (msg == OK) {
  ------------------
  |  Branch (782:7): [True: 764, False: 3.03k]
  ------------------
  783|    764|    return value;
  784|  3.03k|  } else if (msg) {
  ------------------
  |  Branch (784:14): [True: 416, False: 2.62k]
  ------------------
  785|    416|    jv_free(value);
  786|    416|    if (ch != '\036' && (p->flags & JV_PARSE_SEQ)) {
  ------------------
  |  Branch (786:9): [True: 416, False: 0]
  |  Branch (786:25): [True: 0, False: 416]
  ------------------
  787|       |      // Skip to the next RS
  788|      0|      value = make_error(p, "%s at line %d, column %d (need RS to resync)", msg, p->line, p->column);
  789|      0|      parser_reset(p);
  790|      0|      p->st = JV_PARSER_WAITING_FOR_RS;
  791|      0|      return value;
  792|      0|    }
  793|    416|    value = make_error(p, "%s at line %d, column %d", msg, p->line, p->column);
  794|    416|    parser_reset(p);
  795|    416|    if (!(p->flags & JV_PARSE_SEQ)) {
  ------------------
  |  Branch (795:9): [True: 416, False: 0]
  ------------------
  796|       |      // We're not parsing a JSON text sequence; throw this buffer away.
  797|       |      // XXX We should fail permanently here.
  798|    416|      p->curr_buf = 0;
  799|    416|      p->curr_buf_pos = 0;
  800|    416|    } // Else ch must be RS; don't clear buf so we can start parsing again after this ch
  801|    416|    return value;
  802|  2.62k|  } else if (p->curr_buf_is_partial) {
  ------------------
  |  Branch (802:14): [True: 0, False: 2.62k]
  ------------------
  803|      0|    assert(p->curr_buf_pos == p->curr_buf_length);
  ------------------
  |  Branch (803:5): [True: 0, False: 0]
  |  Branch (803:5): [True: 0, False: 0]
  ------------------
  804|       |    // need another buffer
  805|      0|    return jv_invalid();
  806|  2.62k|  } else {
  807|       |    // at EOF
  808|  2.62k|    p->eof = 1;
  809|  2.62k|    assert(p->curr_buf_pos == p->curr_buf_length);
  ------------------
  |  Branch (809:5): [True: 0, False: 2.62k]
  |  Branch (809:5): [True: 2.62k, False: 0]
  ------------------
  810|  2.62k|    jv_free(value);
  811|  2.62k|    if (p->st == JV_PARSER_WAITING_FOR_RS)
  ------------------
  |  Branch (811:9): [True: 0, False: 2.62k]
  ------------------
  812|      0|      return make_error(p, "Unfinished abandoned text at EOF at line %d, column %d", p->line, p->column);
  813|  2.62k|    if (p->st != JV_PARSER_NORMAL) {
  ------------------
  |  Branch (813:9): [True: 103, False: 2.51k]
  ------------------
  814|    103|      value = make_error(p, "Unfinished string at EOF at line %d, column %d", p->line, p->column);
  815|    103|      parser_reset(p);
  816|    103|      p->st = JV_PARSER_WAITING_FOR_RS;
  817|    103|      return value;
  818|    103|    }
  819|  2.51k|    if ((msg = check_literal(p))) {
  ------------------
  |  Branch (819:9): [True: 697, False: 1.82k]
  ------------------
  820|    697|      value = make_error(p, "%s at EOF at line %d, column %d", msg, p->line, p->column);
  821|    697|      parser_reset(p);
  822|    697|      p->st = JV_PARSER_WAITING_FOR_RS;
  823|    697|      return value;
  824|    697|    }
  825|  1.82k|    if (((p->flags & JV_PARSE_STREAMING) && p->stacklen != 0) ||
  ------------------
  |  Branch (825:10): [True: 0, False: 1.82k]
  |  Branch (825:45): [True: 0, False: 0]
  ------------------
  826|  1.82k|        (!(p->flags & JV_PARSE_STREAMING) && p->stackpos != 0)) {
  ------------------
  |  Branch (826:10): [True: 1.82k, False: 0]
  |  Branch (826:46): [True: 666, False: 1.15k]
  ------------------
  827|    666|      value = make_error(p, "Unfinished JSON term at EOF at line %d, column %d", p->line, p->column);
  828|    666|      parser_reset(p);
  829|    666|      p->st = JV_PARSER_WAITING_FOR_RS;
  830|    666|      return value;
  831|    666|    }
  832|       |    // p->next is either invalid (nothing here, but no syntax error)
  833|       |    // or valid (this is the value). either way it's the thing to return
  834|  1.15k|    if ((p->flags & JV_PARSE_STREAMING) && jv_is_valid(p->next)) {
  ------------------
  |  Branch (834:9): [True: 0, False: 1.15k]
  |  Branch (834:44): [True: 0, False: 0]
  ------------------
  835|      0|      value = JV_ARRAY(jv_copy(p->path), p->next); // except in streaming mode we've got to make it [path,value]
  ------------------
  |  |  120|      0|  JV_ARRAY_IDX(__VA_ARGS__, JV_ARRAY_9, JV_ARRAY_8, JV_ARRAY_7, JV_ARRAY_6, JV_ARRAY_5, JV_ARRAY_4, JV_ARRAY_3, JV_ARRAY_2, JV_ARRAY_1, dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  118|      0|#define JV_ARRAY_IDX(_1,_2,_3,_4,_5,_6,_7,_8,_9,NAME,...) NAME
  |  |  |  |  ------------------
  |  |  |  |  |  |  120|      0|  JV_ARRAY_IDX(__VA_ARGS__, JV_ARRAY_9, JV_ARRAY_8, JV_ARRAY_7, JV_ARRAY_6, JV_ARRAY_5, JV_ARRAY_4, JV_ARRAY_3, JV_ARRAY_2, JV_ARRAY_1, dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  110|      0|#define JV_ARRAY_2(e1,e2) (jv_array_append(JV_ARRAY_1(e1),e2))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  109|      0|#define JV_ARRAY_1(e) (jv_array_append(jv_array(),e))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  836|  1.15k|    } else {
  837|  1.15k|      value = p->next;
  838|  1.15k|    }
  839|  1.15k|    p->next = jv_invalid();
  840|  1.15k|    if ((p->flags & JV_PARSE_SEQ) && !p->last_ch_was_ws && jv_get_kind(value) == JV_KIND_NUMBER) {
  ------------------
  |  Branch (840:9): [True: 0, False: 1.15k]
  |  Branch (840:38): [True: 0, False: 0]
  |  Branch (840:60): [True: 0, False: 0]
  ------------------
  841|      0|      jv_free(value);
  842|      0|      return make_error(p, "Potentially truncated top-level numeric value at EOF at line %d, column %d", p->line, p->column);
  843|      0|    }
  844|  1.15k|    return value;
  845|  1.15k|  }
  846|  3.80k|}
jv_parse_sized_custom_flags:
  848|  3.05k|jv jv_parse_sized_custom_flags(const char* string, int length, int flags) {
  849|  3.05k|  struct jv_parser parser;
  850|  3.05k|  parser_init(&parser, flags);
  851|  3.05k|  jv_parser_set_buf(&parser, string, length, 0);
  852|  3.05k|  jv value = jv_parser_next(&parser);
  853|  3.05k|  if (jv_is_valid(value)) {
  ------------------
  |  Branch (853:7): [True: 1.60k, False: 1.45k]
  ------------------
  854|  1.60k|    jv next = jv_parser_next(&parser);
  855|  1.60k|    if (jv_is_valid(next)) {
  ------------------
  |  Branch (855:9): [True: 34, False: 1.56k]
  ------------------
  856|       |      // multiple JSON values, we only wanted one
  857|     34|      jv_free(value);
  858|     34|      jv_free(next);
  859|     34|      value = jv_invalid_with_msg(jv_string("Unexpected extra JSON values"));
  860|  1.56k|    } else if (jv_invalid_has_msg(jv_copy(next))) {
  ------------------
  |  Branch (860:16): [True: 463, False: 1.10k]
  ------------------
  861|       |      // parser error after the first JSON value
  862|    463|      jv_free(value);
  863|    463|      value = next;
  864|  1.10k|    } else {
  865|       |      // a single valid JSON value
  866|  1.10k|      jv_free(next);
  867|  1.10k|    }
  868|  1.60k|  } else if (jv_invalid_has_msg(jv_copy(value))) {
  ------------------
  |  Branch (868:14): [True: 1.41k, False: 35]
  ------------------
  869|       |    // parse error, we'll return it
  870|  1.41k|  } else {
  871|       |    // no value at all
  872|     35|    jv_free(value);
  873|     35|    value = jv_invalid_with_msg(jv_string("Expected JSON value"));
  874|     35|  }
  875|  3.05k|  parser_free(&parser);
  876|       |
  877|  3.05k|  if (!jv_is_valid(value) && jv_invalid_has_msg(jv_copy(value))) {
  ------------------
  |  Branch (877:7): [True: 1.95k, False: 1.10k]
  |  Branch (877:30): [True: 1.95k, False: 0]
  ------------------
  878|  1.95k|    jv msg = jv_invalid_get_msg(value);
  879|  1.95k|    value = jv_invalid_with_msg(jv_string_fmt("%s (while parsing '%.*s')",
  880|  1.95k|                                              jv_string_value(msg),
  881|  1.95k|                                              length,
  882|  1.95k|                                              string));
  883|  1.95k|    jv_free(msg);
  884|  1.95k|  }
  885|  3.05k|  return value;
  886|  3.05k|}
jv_parse_sized:
  888|  3.05k|jv jv_parse_sized(const char* string, int length) {
  889|  3.05k|  return jv_parse_sized_custom_flags(string, length, 0);
  890|  3.05k|}
jv_parse:
  892|  3.05k|jv jv_parse(const char* string) {
  893|  3.05k|  return jv_parse_sized(string, strlen(string));
  894|  3.05k|}
jv_parse.c:parser_init:
   69|  3.05k|static void parser_init(struct jv_parser* p, int flags) {
   70|  3.05k|  p->flags = flags;
   71|  3.05k|  if ((p->flags & JV_PARSE_STREAMING)) {
  ------------------
  |  Branch (71:7): [True: 0, False: 3.05k]
  ------------------
   72|      0|    p->path = jv_array();
   73|  3.05k|  } else {
   74|  3.05k|    p->path = jv_invalid();
   75|  3.05k|    p->flags &= ~(JV_PARSE_STREAM_ERRORS);
   76|  3.05k|  }
   77|  3.05k|  p->stack = 0;
   78|  3.05k|  p->stacklen = p->stackpos = 0;
   79|  3.05k|  p->last_seen = JV_LAST_NONE;
   80|  3.05k|  p->output = jv_invalid();
   81|  3.05k|  p->next = jv_invalid();
   82|  3.05k|  p->tokenlen = 256;
   83|  3.05k|  p->tokenbuf = jv_mem_alloc(p->tokenlen);
   84|  3.05k|  p->tokenpos = 0;
   85|  3.05k|  if ((p->flags & JV_PARSE_SEQ))
  ------------------
  |  Branch (85:7): [True: 0, False: 3.05k]
  ------------------
   86|      0|    p->st = JV_PARSER_WAITING_FOR_RS;
   87|  3.05k|  else
   88|  3.05k|    p->st = JV_PARSER_NORMAL;
   89|  3.05k|  p->eof = 0;
   90|  3.05k|  p->curr_buf = 0;
   91|  3.05k|  p->curr_buf_length = p->curr_buf_pos = p->curr_buf_is_partial = 0;
   92|  3.05k|  p->last_ch_was_ws = 0;
   93|  3.05k|  p->line = 1;
   94|  3.05k|  p->column = 0;
   95|  3.05k|  jvp_dtoa_context_init(&p->dtoa);
   96|  3.05k|}
jv_parse.c:parser_free:
  116|  3.05k|static void parser_free(struct jv_parser* p) {
  117|  3.05k|  parser_reset(p);
  118|  3.05k|  jv_free(p->path);
  119|  3.05k|  jv_free(p->output);
  120|  3.05k|  jv_mem_free(p->stack);
  121|  3.05k|  jv_mem_free(p->tokenbuf);
  122|  3.05k|  jvp_dtoa_context_free(&p->dtoa);
  123|  3.05k|}
jv_parse.c:scan:
  652|  72.7M|static pfunc scan(struct jv_parser* p, char ch, jv* out) {
  653|  72.7M|  p->column++;
  654|  72.7M|  if (ch == '\n') {
  ------------------
  |  Branch (654:7): [True: 38.5k, False: 72.6M]
  ------------------
  655|  38.5k|    p->line++;
  656|  38.5k|    p->column = 0;
  657|  38.5k|  }
  658|  72.7M|  if ((p->flags & JV_PARSE_SEQ)
  ------------------
  |  Branch (658:7): [True: 0, False: 72.7M]
  ------------------
  659|      0|      && ch == '\036' /* ASCII RS; see draft-ietf-json-sequence-07 */) {
  ------------------
  |  Branch (659:10): [True: 0, False: 0]
  ------------------
  660|      0|    if (check_truncation(p)) {
  ------------------
  |  |  647|      0|   (((p)->flags & JV_PARSE_STREAMING) ? stream_seq_check_truncation((p)) : seq_check_truncation((p)))
  |  |  ------------------
  |  |  |  Branch (647:4): [True: 0, False: 0]
  |  |  |  Branch (647:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  661|      0|      if (check_literal(p) == 0 && is_top_num(p))
  ------------------
  |  |  650|      0|   (((p)->flags & JV_PARSE_STREAMING) ? stream_is_top_num((p)) : parse_is_top_num((p)))
  |  |  ------------------
  |  |  |  Branch (650:4): [True: 0, False: 0]
  |  |  |  Branch (650:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (661:11): [True: 0, False: 0]
  ------------------
  662|      0|        return "Potentially truncated top-level numeric value";
  663|      0|      return "Truncated value";
  664|      0|    }
  665|      0|    TRY(check_literal(p));
  ------------------
  |  |   18|      0|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 0, False: 0]
  |  |  |  Branch (18:74): [Folded, False: 0]
  |  |  ------------------
  ------------------
  666|      0|    if (p->st == JV_PARSER_NORMAL && check_done(p, out))
  ------------------
  |  |  641|      0|   (((p)->flags & JV_PARSE_STREAMING) ? stream_check_done((p), (o)) : parse_check_done((p), (o)))
  |  |  ------------------
  |  |  |  Branch (641:4): [True: 0, False: 0]
  |  |  |  Branch (641:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (666:9): [True: 0, False: 0]
  ------------------
  667|      0|      return OK;
  668|       |    // shouldn't happen?
  669|      0|    assert(!jv_is_valid(*out));
  ------------------
  |  Branch (669:5): [True: 0, False: 0]
  |  Branch (669:5): [True: 0, False: 0]
  ------------------
  670|      0|    parser_reset(p);
  671|      0|    jv_free(*out);
  672|      0|    *out = jv_invalid();
  673|      0|    return OK;
  674|      0|  }
  675|  72.7M|  presult answer = 0;
  676|  72.7M|  p->last_ch_was_ws = 0;
  677|  72.7M|  if (p->st == JV_PARSER_NORMAL) {
  ------------------
  |  Branch (677:7): [True: 63.3M, False: 9.38M]
  ------------------
  678|  63.3M|    chclass cls = classify(ch);
  679|  63.3M|    if (cls == WHITESPACE)
  ------------------
  |  Branch (679:9): [True: 355k, False: 62.9M]
  ------------------
  680|   355k|      p->last_ch_was_ws = 1;
  681|  63.3M|    if (cls != LITERAL) {
  ------------------
  |  Branch (681:9): [True: 7.46M, False: 55.8M]
  ------------------
  682|  7.46M|      TRY(check_literal(p));
  ------------------
  |  |   18|  7.46M|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 59, False: 7.46M]
  |  |  |  Branch (18:74): [Folded, False: 7.46M]
  |  |  ------------------
  ------------------
  683|  7.46M|      if (check_done(p, out)) answer = OK;
  ------------------
  |  |  641|  7.46M|   (((p)->flags & JV_PARSE_STREAMING) ? stream_check_done((p), (o)) : parse_check_done((p), (o)))
  |  |  ------------------
  |  |  |  Branch (641:4): [True: 366, False: 7.46M]
  |  |  |  Branch (641:5): [True: 0, False: 7.46M]
  |  |  ------------------
  ------------------
  684|  7.46M|    }
  685|  63.3M|    switch (cls) {
  ------------------
  |  Branch (685:13): [True: 63.3M, False: 0]
  ------------------
  686|  55.8M|    case LITERAL:
  ------------------
  |  Branch (686:5): [True: 55.8M, False: 7.46M]
  ------------------
  687|  55.8M|      TRY(tokenadd(p, ch));
  ------------------
  |  |   18|  55.8M|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 0, False: 55.8M]
  |  |  |  Branch (18:74): [Folded, False: 55.8M]
  |  |  ------------------
  ------------------
  688|  55.8M|      break;
  689|  55.8M|    case WHITESPACE:
  ------------------
  |  Branch (689:5): [True: 355k, False: 62.9M]
  ------------------
  690|   355k|      break;
  691|  47.7k|    case QUOTE:
  ------------------
  |  Branch (691:5): [True: 47.7k, False: 63.2M]
  ------------------
  692|  47.7k|      p->st = JV_PARSER_STRING;
  693|  47.7k|      break;
  694|  7.06M|    case STRUCTURE:
  ------------------
  |  Branch (694:5): [True: 7.06M, False: 56.2M]
  ------------------
  695|  7.06M|      TRY(token(p, ch));
  ------------------
  |  |   18|  14.1M|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:37): [True: 0, False: 7.06M]
  |  |  |  Branch (18:45): [True: 179, False: 7.06M]
  |  |  |  Branch (18:74): [Folded, False: 7.06M]
  |  |  ------------------
  ------------------
  696|  7.06M|      break;
  697|  7.06M|    case INVALID:
  ------------------
  |  Branch (697:5): [True: 0, False: 63.3M]
  ------------------
  698|      0|      return "Invalid character";
  699|  63.3M|    }
  700|  63.3M|    if (check_done(p, out)) answer = OK;
  ------------------
  |  |  641|  63.3M|   (((p)->flags & JV_PARSE_STREAMING) ? stream_check_done((p), (o)) : parse_check_done((p), (o)))
  |  |  ------------------
  |  |  |  Branch (641:4): [True: 129, False: 63.3M]
  |  |  |  Branch (641:5): [True: 0, False: 63.3M]
  |  |  ------------------
  ------------------
  701|  63.3M|  } else {
  702|  9.38M|    if (ch == '"' && p->st == JV_PARSER_STRING) {
  ------------------
  |  Branch (702:9): [True: 49.5k, False: 9.33M]
  |  Branch (702:22): [True: 47.6k, False: 1.98k]
  ------------------
  703|  47.6k|      TRY(found_string(p));
  ------------------
  |  |   18|  47.6k|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 178, False: 47.4k]
  |  |  |  Branch (18:74): [Folded, False: 47.4k]
  |  |  ------------------
  ------------------
  704|  47.4k|      p->st = JV_PARSER_NORMAL;
  705|  47.4k|      if (check_done(p, out)) answer = OK;
  ------------------
  |  |  641|  47.4k|   (((p)->flags & JV_PARSE_STREAMING) ? stream_check_done((p), (o)) : parse_check_done((p), (o)))
  |  |  ------------------
  |  |  |  Branch (641:4): [True: 276, False: 47.1k]
  |  |  |  Branch (641:5): [True: 0, False: 47.4k]
  |  |  ------------------
  ------------------
  706|  9.33M|    } else {
  707|  9.33M|      TRY(tokenadd(p, ch));
  ------------------
  |  |   18|  9.33M|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 0, False: 9.33M]
  |  |  |  Branch (18:74): [Folded, False: 9.33M]
  |  |  ------------------
  ------------------
  708|  9.33M|      if (ch == '\\' && p->st == JV_PARSER_STRING) {
  ------------------
  |  Branch (708:11): [True: 39.1k, False: 9.29M]
  |  Branch (708:25): [True: 36.8k, False: 2.34k]
  ------------------
  709|  36.8k|        p->st = JV_PARSER_STRING_ESCAPE;
  710|  9.29M|      } else {
  711|  9.29M|        p->st = JV_PARSER_STRING;
  712|  9.29M|      }
  713|  9.33M|    }
  714|  9.38M|  }
  715|  72.7M|  return answer;
  716|  72.7M|}
jv_parse.c:parse_check_done:
  591|  70.8M|static int parse_check_done(struct jv_parser* p, jv* out) {
  592|  70.8M|  if (p->stackpos == 0 && jv_is_valid(p->next)) {
  ------------------
  |  Branch (592:7): [True: 45.2M, False: 25.5M]
  |  Branch (592:27): [True: 771, False: 45.2M]
  ------------------
  593|    771|    *out = p->next;
  594|    771|    p->next = jv_invalid();
  595|    771|    return 1;
  596|  70.8M|  } else {
  597|  70.8M|    return 0;
  598|  70.8M|  }
  599|  70.8M|}
jv_parse.c:classify:
  562|  63.3M|static chclass classify(char c) {
  563|  63.3M|  switch (c) {
  564|      0|  case '\0':
  ------------------
  |  Branch (564:3): [True: 0, False: 63.3M]
  ------------------
  565|       |    // RFC 8259 forbids raw NUL in JSON text. Treating it as a literal lets it
  566|       |    // slip into the token buffer, where check_literal() reads the buffer as a
  567|       |    // NUL-terminated C string and silently truncates the token. Reject it.
  568|      0|    return INVALID;
  569|   325k|  case ' ':
  ------------------
  |  Branch (569:3): [True: 325k, False: 63.0M]
  ------------------
  570|   325k|  case '\t':
  ------------------
  |  Branch (570:3): [True: 388, False: 63.3M]
  ------------------
  571|   326k|  case '\r':
  ------------------
  |  Branch (571:3): [True: 214, False: 63.3M]
  ------------------
  572|   355k|  case '\n':
  ------------------
  |  Branch (572:3): [True: 29.8k, False: 63.3M]
  ------------------
  573|   355k|    return WHITESPACE;
  574|  47.7k|  case '"':
  ------------------
  |  Branch (574:3): [True: 47.7k, False: 63.2M]
  ------------------
  575|  47.7k|    return QUOTE;
  576|   159k|  case '[':
  ------------------
  |  Branch (576:3): [True: 159k, False: 63.1M]
  ------------------
  577|  6.78M|  case ',':
  ------------------
  |  Branch (577:3): [True: 6.62M, False: 56.7M]
  ------------------
  578|  6.79M|  case ']':
  ------------------
  |  Branch (578:3): [True: 11.5k, False: 63.3M]
  ------------------
  579|  6.96M|  case '{':
  ------------------
  |  Branch (579:3): [True: 162k, False: 63.1M]
  ------------------
  580|  6.99M|  case ':':
  ------------------
  |  Branch (580:3): [True: 37.6k, False: 63.3M]
  ------------------
  581|  7.06M|  case '}':
  ------------------
  |  Branch (581:3): [True: 67.7k, False: 63.2M]
  ------------------
  582|  7.06M|    return STRUCTURE;
  583|  55.8M|  default:
  ------------------
  |  Branch (583:3): [True: 55.8M, False: 7.46M]
  ------------------
  584|  55.8M|    return LITERAL;
  585|  63.3M|  }
  586|  63.3M|}
jv_parse.c:tokenadd:
  421|  65.2M|static pfunc tokenadd(struct jv_parser* p, char c) {
  422|  65.2M|  assert(p->tokenpos <= p->tokenlen);
  ------------------
  |  Branch (422:3): [True: 0, False: 65.2M]
  |  Branch (422:3): [True: 65.2M, False: 0]
  ------------------
  423|  65.2M|  if (p->tokenpos >= (p->tokenlen - 1)) {
  ------------------
  |  Branch (423:7): [True: 2.57k, False: 65.2M]
  ------------------
  424|  2.57k|    if (p->tokenlen > INT_MAX / 2)
  ------------------
  |  Branch (424:9): [True: 0, False: 2.57k]
  ------------------
  425|      0|      return "Token too long";
  426|  2.57k|    p->tokenlen *= 2;
  427|  2.57k|    p->tokenbuf = jv_mem_realloc(p->tokenbuf, p->tokenlen);
  428|  2.57k|  }
  429|  65.2M|  assert(p->tokenpos < p->tokenlen);
  ------------------
  |  Branch (429:3): [True: 0, False: 65.2M]
  |  Branch (429:3): [True: 65.2M, False: 0]
  ------------------
  430|  65.2M|  p->tokenbuf[p->tokenpos++] = c;
  431|  65.2M|  return 0;
  432|  65.2M|}
jv_parse.c:parse_token:
  156|  7.06M|static pfunc parse_token(struct jv_parser* p, char ch) {
  157|  7.06M|  switch (ch) {
  ------------------
  |  Branch (157:11): [True: 7.06M, False: 0]
  ------------------
  158|   159k|  case '[':
  ------------------
  |  Branch (158:3): [True: 159k, False: 6.90M]
  ------------------
  159|   159k|    if (p->stackpos >= MAX_PARSING_DEPTH) return "Exceeds depth limit for parsing";
  ------------------
  |  |   15|   159k|#define MAX_PARSING_DEPTH (10000)
  ------------------
  |  Branch (159:9): [True: 1, False: 159k]
  ------------------
  160|   159k|    if (jv_is_valid(p->next)) return "Expected separator between values";
  ------------------
  |  Branch (160:9): [True: 5, False: 159k]
  ------------------
  161|   159k|    push(p, jv_array());
  162|   159k|    break;
  163|       |
  164|   162k|  case '{':
  ------------------
  |  Branch (164:3): [True: 162k, False: 6.90M]
  ------------------
  165|   162k|    if (p->stackpos >= MAX_PARSING_DEPTH) return "Exceeds depth limit for parsing";
  ------------------
  |  |   15|   162k|#define MAX_PARSING_DEPTH (10000)
  ------------------
  |  Branch (165:9): [True: 1, False: 162k]
  ------------------
  166|   162k|    if (jv_is_valid(p->next)) return "Expected separator between values";
  ------------------
  |  Branch (166:9): [True: 7, False: 162k]
  ------------------
  167|   162k|    push(p, jv_object());
  168|   162k|    break;
  169|       |
  170|  37.6k|  case ':':
  ------------------
  |  Branch (170:3): [True: 37.6k, False: 7.02M]
  ------------------
  171|  37.6k|    if (!jv_is_valid(p->next))
  ------------------
  |  Branch (171:9): [True: 10, False: 37.6k]
  ------------------
  172|     10|      return "Expected string key before ':'";
  173|  37.6k|    if (p->stackpos == 0 || jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_OBJECT)
  ------------------
  |  Branch (173:9): [True: 0, False: 37.6k]
  |  Branch (173:29): [True: 2, False: 37.6k]
  ------------------
  174|      2|      return "':' not as part of an object";
  175|  37.6k|    if (jv_get_kind(p->next) != JV_KIND_STRING)
  ------------------
  |  Branch (175:9): [True: 6, False: 37.6k]
  ------------------
  176|      6|      return "Object keys must be strings";
  177|  37.6k|    push(p, p->next);
  178|  37.6k|    p->next = jv_invalid();
  179|  37.6k|    break;
  180|       |
  181|  6.62M|  case ',':
  ------------------
  |  Branch (181:3): [True: 6.62M, False: 438k]
  ------------------
  182|  6.62M|    if (!jv_is_valid(p->next))
  ------------------
  |  Branch (182:9): [True: 18, False: 6.62M]
  ------------------
  183|     18|      return "Expected value before ','";
  184|  6.62M|    if (p->stackpos == 0)
  ------------------
  |  Branch (184:9): [True: 0, False: 6.62M]
  ------------------
  185|      0|      return "',' not as part of an object or array";
  186|  6.62M|    if (jv_get_kind(p->stack[p->stackpos-1]) == JV_KIND_ARRAY) {
  ------------------
  |  Branch (186:9): [True: 6.59M, False: 29.7k]
  ------------------
  187|  6.59M|      p->stack[p->stackpos-1] = jv_array_append(p->stack[p->stackpos-1], p->next);
  188|  6.59M|      p->next = jv_invalid();
  189|  6.59M|    } else if (jv_get_kind(p->stack[p->stackpos-1]) == JV_KIND_STRING) {
  ------------------
  |  Branch (189:16): [True: 29.7k, False: 10]
  ------------------
  190|  29.7k|      assert(p->stackpos > 1 && jv_get_kind(p->stack[p->stackpos-2]) == JV_KIND_OBJECT);
  ------------------
  |  Branch (190:7): [True: 0, False: 29.7k]
  |  Branch (190:7): [True: 0, False: 0]
  |  Branch (190:7): [True: 29.7k, False: 0]
  |  Branch (190:7): [True: 29.7k, False: 0]
  ------------------
  191|  29.7k|      p->stack[p->stackpos-2] = jv_object_set(p->stack[p->stackpos-2],
  192|  29.7k|                                              p->stack[p->stackpos-1], p->next);
  193|  29.7k|      p->stackpos--;
  194|  29.7k|      p->next = jv_invalid();
  195|  29.7k|    } else {
  196|       |      // this case hits on input like {"a", "b"}
  197|     10|      return "Objects must consist of key:value pairs";
  198|     10|    }
  199|  6.62M|    break;
  200|       |
  201|  6.62M|  case ']':
  ------------------
  |  Branch (201:3): [True: 11.5k, False: 7.05M]
  ------------------
  202|  11.5k|    if (p->stackpos == 0 || jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_ARRAY)
  ------------------
  |  Branch (202:9): [True: 13, False: 11.5k]
  |  Branch (202:29): [True: 14, False: 11.5k]
  ------------------
  203|     27|      return "Unmatched ']'";
  204|  11.5k|    if (jv_is_valid(p->next)) {
  ------------------
  |  Branch (204:9): [True: 1.38k, False: 10.1k]
  ------------------
  205|  1.38k|      p->stack[p->stackpos-1] = jv_array_append(p->stack[p->stackpos-1], p->next);
  206|  1.38k|      p->next = jv_invalid();
  207|  10.1k|    } else {
  208|  10.1k|      if (jv_array_length(jv_copy(p->stack[p->stackpos-1])) != 0) {
  ------------------
  |  Branch (208:11): [True: 39, False: 10.0k]
  ------------------
  209|       |        // this case hits on input like [1,2,3,]
  210|     39|        return "Expected another array element";
  211|     39|      }
  212|  10.1k|    }
  213|  11.4k|    jv_free(p->next);
  214|  11.4k|    p->next = p->stack[--p->stackpos];
  215|  11.4k|    break;
  216|       |
  217|  67.7k|  case '}':
  ------------------
  |  Branch (217:3): [True: 67.7k, False: 6.99M]
  ------------------
  218|  67.7k|    if (p->stackpos == 0)
  ------------------
  |  Branch (218:9): [True: 7, False: 67.7k]
  ------------------
  219|      7|      return "Unmatched '}'";
  220|  67.7k|    if (jv_is_valid(p->next)) {
  ------------------
  |  Branch (220:9): [True: 7.17k, False: 60.5k]
  ------------------
  221|  7.17k|      if (jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_STRING)
  ------------------
  |  Branch (221:11): [True: 12, False: 7.16k]
  ------------------
  222|     12|        return "Objects must consist of key:value pairs";
  223|  7.17k|      assert(p->stackpos > 1 && jv_get_kind(p->stack[p->stackpos-2]) == JV_KIND_OBJECT);
  ------------------
  |  Branch (223:7): [True: 0, False: 7.16k]
  |  Branch (223:7): [True: 0, False: 0]
  |  Branch (223:7): [True: 7.16k, False: 0]
  |  Branch (223:7): [True: 7.16k, False: 0]
  ------------------
  224|  7.16k|      p->stack[p->stackpos-2] = jv_object_set(p->stack[p->stackpos-2],
  225|  7.16k|                                              p->stack[p->stackpos-1], p->next);
  226|  7.16k|      p->stackpos--;
  227|  7.16k|      p->next = jv_invalid();
  228|  60.5k|    } else {
  229|  60.5k|      if (jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_OBJECT)
  ------------------
  |  Branch (229:11): [True: 14, False: 60.5k]
  ------------------
  230|     14|        return "Unmatched '}'";
  231|  60.5k|      if (jv_object_length(jv_copy(p->stack[p->stackpos-1])) != 0)
  ------------------
  |  Branch (231:11): [True: 20, False: 60.5k]
  ------------------
  232|     20|        return "Expected another key-value pair";
  233|  60.5k|    }
  234|  67.7k|    jv_free(p->next);
  235|  67.7k|    p->next = p->stack[--p->stackpos];
  236|  67.7k|    break;
  237|  7.06M|  }
  238|  7.06M|  return 0;
  239|  7.06M|}
jv_parse.c:push:
  146|   359k|static void push(struct jv_parser* p, jv v) {
  147|   359k|  assert(p->stackpos <= p->stacklen);
  ------------------
  |  Branch (147:3): [True: 0, False: 359k]
  |  Branch (147:3): [True: 359k, False: 0]
  ------------------
  148|   359k|  if (p->stackpos == p->stacklen) {
  ------------------
  |  Branch (148:7): [True: 1.92k, False: 357k]
  ------------------
  149|  1.92k|    p->stacklen = p->stacklen * 2 + 10;
  150|  1.92k|    p->stack = jv_mem_realloc(p->stack, p->stacklen * sizeof(jv));
  151|  1.92k|  }
  152|   359k|  assert(p->stackpos < p->stacklen);
  ------------------
  |  Branch (152:3): [True: 0, False: 359k]
  |  Branch (152:3): [True: 359k, False: 0]
  ------------------
  153|   359k|  p->stack[p->stackpos++] = v;
  154|   359k|}
jv_parse.c:found_string:
  449|  47.6k|static pfunc found_string(struct jv_parser* p) {
  450|  47.6k|  char* in = p->tokenbuf;
  451|  47.6k|  char* out = p->tokenbuf;
  452|  47.6k|  char* end = p->tokenbuf + p->tokenpos;
  453|       |
  454|  3.25M|  while (in < end) {
  ------------------
  |  Branch (454:10): [True: 3.20M, False: 47.4k]
  ------------------
  455|  3.20M|    char c = *in++;
  456|  3.20M|    if (c == '\\') {
  ------------------
  |  Branch (456:9): [True: 12.0k, False: 3.19M]
  ------------------
  457|  12.0k|      if (in >= end)
  ------------------
  |  Branch (457:11): [True: 0, False: 12.0k]
  ------------------
  458|      0|        return "Expected escape character at end of string";
  459|  12.0k|      c = *in++;
  460|  12.0k|      switch (c) {
  461|  1.75k|      case '\\':
  ------------------
  |  Branch (461:7): [True: 1.75k, False: 10.3k]
  ------------------
  462|  2.78k|      case '"':
  ------------------
  |  Branch (462:7): [True: 1.03k, False: 11.0k]
  ------------------
  463|  3.56k|      case '/': *out++ = c;    break;
  ------------------
  |  Branch (463:7): [True: 777, False: 11.3k]
  ------------------
  464|  2.51k|      case 'b': *out++ = '\b'; break;
  ------------------
  |  Branch (464:7): [True: 2.51k, False: 9.57k]
  ------------------
  465|    250|      case 'f': *out++ = '\f'; break;
  ------------------
  |  Branch (465:7): [True: 250, False: 11.8k]
  ------------------
  466|  1.77k|      case 't': *out++ = '\t'; break;
  ------------------
  |  Branch (466:7): [True: 1.77k, False: 10.3k]
  ------------------
  467|    563|      case 'n': *out++ = '\n'; break;
  ------------------
  |  Branch (467:7): [True: 563, False: 11.5k]
  ------------------
  468|    309|      case 'r': *out++ = '\r'; break;
  ------------------
  |  Branch (468:7): [True: 309, False: 11.7k]
  ------------------
  469|       |
  470|  3.11k|      case 'u':
  ------------------
  |  Branch (470:7): [True: 3.11k, False: 8.97k]
  ------------------
  471|       |        /* ahh, the complicated case */
  472|  3.11k|        if (in + 4 > end)
  ------------------
  |  Branch (472:13): [True: 2, False: 3.11k]
  ------------------
  473|      2|          return "Invalid \\uXXXX escape";
  474|  3.11k|        int hexvalue = unhex4(in);
  475|  3.11k|        if (hexvalue < 0)
  ------------------
  |  Branch (475:13): [True: 27, False: 3.08k]
  ------------------
  476|     27|          return "Invalid characters in \\uXXXX escape";
  477|  3.08k|        unsigned long codepoint = (unsigned long)hexvalue;
  478|  3.08k|        in += 4;
  479|  3.08k|        if (0xD800 <= codepoint && codepoint <= 0xDBFF) {
  ------------------
  |  Branch (479:13): [True: 1.17k, False: 1.91k]
  |  Branch (479:36): [True: 490, False: 684]
  ------------------
  480|       |          /* who thought UTF-16 surrogate pairs were a good idea? */
  481|    490|          if (in + 6 > end || in[0] != '\\' || in[1] != 'u')
  ------------------
  |  Branch (481:15): [True: 12, False: 478]
  |  Branch (481:31): [True: 2, False: 476]
  |  Branch (481:48): [True: 11, False: 465]
  ------------------
  482|     25|            return "Invalid \\uXXXX\\uXXXX surrogate pair escape";
  483|    465|          unsigned long surrogate = unhex4(in+2);
  484|    465|          if (!(0xDC00 <= surrogate && surrogate <= 0xDFFF))
  ------------------
  |  Branch (484:17): [True: 443, False: 22]
  |  Branch (484:40): [True: 414, False: 29]
  ------------------
  485|     51|            return "Invalid \\uXXXX\\uXXXX surrogate pair escape";
  486|    414|          in += 6;
  487|    414|          codepoint = 0x10000 + (((codepoint - 0xD800) << 10)
  488|    414|                                 |(surrogate - 0xDC00));
  489|    414|        }
  490|  3.01k|        if (codepoint > 0x10FFFF)
  ------------------
  |  Branch (490:13): [True: 0, False: 3.01k]
  ------------------
  491|      0|          codepoint = 0xFFFD; // U+FFFD REPLACEMENT CHARACTER
  492|  3.01k|        out += jvp_utf8_encode(codepoint, out);
  493|  3.01k|        break;
  494|       |
  495|      1|      default:
  ------------------
  |  Branch (495:7): [True: 1, False: 12.0k]
  ------------------
  496|      1|        return "Invalid escape";
  497|  12.0k|      }
  498|  3.19M|    } else {
  499|  3.19M|      if (!(c & ~0x1F))
  ------------------
  |  Branch (499:11): [True: 50, False: 3.19M]
  ------------------
  500|     50|        return "Invalid string: control characters from U+0000 through U+001F must be escaped";
  501|  3.19M|      *out++ = c;
  502|  3.19M|    }
  503|  3.20M|  }
  504|  47.4k|  TRY(value(p, jv_string_sized(p->tokenbuf, out - p->tokenbuf)));
  ------------------
  |  |   18|  47.4k|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 22, False: 47.4k]
  |  |  |  Branch (18:74): [Folded, False: 47.4k]
  |  |  ------------------
  ------------------
  505|  47.4k|  p->tokenpos = 0;
  506|  47.4k|  return 0;
  507|  47.4k|}
jv_parse.c:unhex4:
  434|  3.58k|static int unhex4(char* hex) {
  435|  3.58k|  int r = 0;
  436|  17.7k|  for (int i=0; i<4; i++) {
  ------------------
  |  Branch (436:17): [True: 14.2k, False: 3.52k]
  ------------------
  437|  14.2k|    char c = *hex++;
  438|  14.2k|    int n;
  439|  14.2k|    if ('0' <= c && c <= '9') n = c - '0';
  ------------------
  |  Branch (439:9): [True: 14.1k, False: 28]
  |  Branch (439:21): [True: 8.80k, False: 5.39k]
  ------------------
  440|  5.42k|    else if ('a' <= c && c <= 'f') n = c - 'a' + 10;
  ------------------
  |  Branch (440:14): [True: 3.60k, False: 1.82k]
  |  Branch (440:26): [True: 3.59k, False: 8]
  ------------------
  441|  1.82k|    else if ('A' <= c && c <= 'F') n = c - 'A' + 10;
  ------------------
  |  Branch (441:14): [True: 1.79k, False: 34]
  |  Branch (441:26): [True: 1.77k, False: 19]
  ------------------
  442|     53|    else return -1;
  443|  14.1k|    r <<= 4;
  444|  14.1k|    r |= n;
  445|  14.1k|  }
  446|  3.52k|  return r;
  447|  3.58k|}
jv_parse.c:value:
  125|  6.59M|static pfunc value(struct jv_parser* p, jv val) {
  126|  6.59M|  if ((p->flags & JV_PARSE_STREAMING)) {
  ------------------
  |  Branch (126:7): [True: 0, False: 6.59M]
  ------------------
  127|      0|    if (jv_is_valid(p->next) || p->last_seen == JV_LAST_VALUE) {
  ------------------
  |  Branch (127:9): [True: 0, False: 0]
  |  Branch (127:33): [True: 0, False: 0]
  ------------------
  128|      0|      jv_free(val);
  129|      0|      return "Expected separator between values";
  130|      0|    }
  131|      0|    if (p->stacklen > 0)
  ------------------
  |  Branch (131:9): [True: 0, False: 0]
  ------------------
  132|      0|      p->last_seen = JV_LAST_VALUE;
  133|      0|    else
  134|      0|      p->last_seen = JV_LAST_NONE;
  135|  6.59M|  } else {
  136|  6.59M|    if (jv_is_valid(p->next)) {
  ------------------
  |  Branch (136:9): [True: 40, False: 6.59M]
  ------------------
  137|     40|      jv_free(val);
  138|     40|      return "Expected separator between values";
  139|     40|    }
  140|  6.59M|  }
  141|  6.59M|  jv_free(p->next);
  142|  6.59M|  p->next = val;
  143|  6.59M|  return 0;
  144|  6.59M|}
jv_parse.c:make_error:
  747|  1.88k|static jv make_error(struct jv_parser* p, const char *fmt, ...) {
  748|  1.88k|  va_list ap;
  749|  1.88k|  va_start(ap, fmt);
  750|  1.88k|  jv e = jv_string_vfmt(fmt, ap);
  751|  1.88k|  va_end(ap);
  752|  1.88k|  if ((p->flags & JV_PARSE_STREAM_ERRORS))
  ------------------
  |  Branch (752:7): [True: 0, False: 1.88k]
  ------------------
  753|      0|    return JV_ARRAY(e, jv_copy(p->path));
  ------------------
  |  |  120|      0|  JV_ARRAY_IDX(__VA_ARGS__, JV_ARRAY_9, JV_ARRAY_8, JV_ARRAY_7, JV_ARRAY_6, JV_ARRAY_5, JV_ARRAY_4, JV_ARRAY_3, JV_ARRAY_2, JV_ARRAY_1, dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  118|      0|#define JV_ARRAY_IDX(_1,_2,_3,_4,_5,_6,_7,_8,_9,NAME,...) NAME
  |  |  |  |  ------------------
  |  |  |  |  |  |  120|      0|  JV_ARRAY_IDX(__VA_ARGS__, JV_ARRAY_9, JV_ARRAY_8, JV_ARRAY_7, JV_ARRAY_6, JV_ARRAY_5, JV_ARRAY_4, JV_ARRAY_3, JV_ARRAY_2, JV_ARRAY_1, dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  110|      0|#define JV_ARRAY_2(e1,e2) (jv_array_append(JV_ARRAY_1(e1),e2))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  109|      0|#define JV_ARRAY_1(e) (jv_array_append(jv_array(),e))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  754|  1.88k|  return jv_invalid_with_msg(e);
  755|  1.88k|}
jv_parse.c:parser_reset:
   98|  4.93k|static void parser_reset(struct jv_parser* p) {
   99|  4.93k|  if ((p->flags & JV_PARSE_STREAMING)) {
  ------------------
  |  Branch (99:7): [True: 0, False: 4.93k]
  ------------------
  100|      0|    jv_free(p->path);
  101|      0|    p->path = jv_array();
  102|      0|    p->stacklen = 0;
  103|      0|  }
  104|  4.93k|  p->last_seen = JV_LAST_NONE;
  105|  4.93k|  jv_free(p->output);
  106|  4.93k|  p->output = jv_invalid();
  107|  4.93k|  jv_free(p->next);
  108|  4.93k|  p->next = jv_invalid();
  109|   248k|  for (int i=0; i<p->stackpos; i++)
  ------------------
  |  Branch (109:17): [True: 243k, False: 4.93k]
  ------------------
  110|   243k|    jv_free(p->stack[i]);
  111|  4.93k|  p->stackpos = 0;
  112|  4.93k|  p->tokenpos = 0;
  113|  4.93k|  p->st = JV_PARSER_NORMAL;
  114|  4.93k|}
jv_parse.c:check_literal:
  509|  7.47M|static pfunc check_literal(struct jv_parser* p) {
  510|  7.47M|  if (p->tokenpos == 0) return 0;
  ------------------
  |  Branch (510:7): [True: 922k, False: 6.54M]
  ------------------
  511|       |
  512|  6.54M|  const char* pattern = 0;
  513|  6.54M|  int plen;
  514|  6.54M|  jv v;
  515|  6.54M|  switch (p->tokenbuf[0]) {
  ------------------
  |  Branch (515:11): [True: 1.73k, False: 6.54M]
  ------------------
  516|    391|  case 't': pattern = "true"; plen = 4; v = jv_true(); break;
  ------------------
  |  Branch (516:3): [True: 391, False: 6.54M]
  ------------------
  517|    258|  case 'f': pattern = "false"; plen = 5; v = jv_false(); break;
  ------------------
  |  Branch (517:3): [True: 258, False: 6.54M]
  ------------------
  518|     10|  case '\'':
  ------------------
  |  Branch (518:3): [True: 10, False: 6.54M]
  ------------------
  519|     10|    return "Invalid string literal; expected \", but got '";
  520|  1.07k|  case 'n':
  ------------------
  |  Branch (520:3): [True: 1.07k, False: 6.54M]
  ------------------
  521|       |    // if it starts with 'n', it could be a literal "nan"
  522|  1.07k|    if (p->tokenpos > 1 && p->tokenbuf[1] == 'u') {
  ------------------
  |  Branch (522:9): [True: 1.07k, False: 8]
  |  Branch (522:28): [True: 275, False: 796]
  ------------------
  523|    275|      pattern = "null"; plen = 4; v = jv_null();
  524|    275|    }
  525|  6.54M|  }
  526|  6.54M|  if (pattern) {
  ------------------
  |  Branch (526:7): [True: 924, False: 6.54M]
  ------------------
  527|    924|    if (p->tokenpos != plen) return "Invalid literal";
  ------------------
  |  Branch (527:9): [True: 68, False: 856]
  ------------------
  528|  4.48k|    for (int i=0; i<plen; i++)
  ------------------
  |  Branch (528:19): [True: 3.63k, False: 843]
  ------------------
  529|  3.63k|      if (p->tokenbuf[i] != pattern[i])
  ------------------
  |  Branch (529:11): [True: 13, False: 3.62k]
  ------------------
  530|     13|        return "Invalid literal";
  531|    843|    TRY(value(p, v));
  ------------------
  |  |   18|    843|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 2, False: 841]
  |  |  |  Branch (18:74): [Folded, False: 841]
  |  |  ------------------
  ------------------
  532|  6.54M|  } else {
  533|       |    // FIXME: better parser
  534|  6.54M|    p->tokenbuf[p->tokenpos] = 0;
  535|  6.54M|#ifdef USE_DECNUM
  536|  6.54M|    jv number = jv_number_with_literal(p->tokenbuf);
  537|  6.54M|    if (jv_get_kind(number) == JV_KIND_INVALID) {
  ------------------
  |  Branch (537:9): [True: 647, False: 6.54M]
  ------------------
  538|    647|      return "Invalid numeric literal";
  539|    647|    }
  540|  6.54M|    TRY(value(p, number));
  ------------------
  |  |   18|  6.54M|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 16, False: 6.54M]
  |  |  |  Branch (18:74): [Folded, False: 6.54M]
  |  |  ------------------
  ------------------
  541|       |#else
  542|       |    char *end = 0;
  543|       |    double d = jvp_strtod(&p->dtoa, p->tokenbuf, &end);
  544|       |    if (end == 0 || *end != 0) {
  545|       |      return "Invalid numeric literal";
  546|       |    }
  547|       |    TRY(value(p, jv_number(d)));
  548|       |#endif
  549|  6.54M|  }
  550|  6.54M|  p->tokenpos = 0;
  551|  6.54M|  return 0;
  552|  6.54M|}

jvp_utf8_next:
   30|  53.3M|const char* jvp_utf8_next(const char* in, const char* end, int* codepoint_ret) {
   31|  53.3M|  assert(in <= end);
  ------------------
  |  Branch (31:3): [True: 0, False: 53.3M]
  |  Branch (31:3): [True: 53.3M, False: 0]
  ------------------
   32|  53.3M|  if (in == end) {
  ------------------
  |  Branch (32:7): [True: 51.3k, False: 53.3M]
  ------------------
   33|  51.3k|    return 0;
   34|  51.3k|  }
   35|  53.3M|  int codepoint = -1;
   36|  53.3M|  unsigned char first = (unsigned char)in[0];
   37|  53.3M|  int length = utf8_coding_length[first];
   38|  53.3M|  if ((first & 0x80) == 0) {
  ------------------
  |  Branch (38:7): [True: 50.3M, False: 2.97M]
  ------------------
   39|       |    /* Fast-path for ASCII */
   40|  50.3M|    codepoint = first;
   41|  50.3M|    length = 1;
   42|  50.3M|  } else if (length == 0 || length == UTF8_CONTINUATION_BYTE) {
  ------------------
  |  |    1|  2.21M|#define UTF8_CONTINUATION_BYTE ((unsigned char)255)
  ------------------
  |  Branch (42:14): [True: 761k, False: 2.21M]
  |  Branch (42:29): [True: 2.15M, False: 60.0k]
  ------------------
   43|       |    /* Bad single byte - either an invalid byte or an out-of-place continuation byte */
   44|  2.91M|    length = 1;
   45|  2.91M|  } else if (length > end - in) {
  ------------------
  |  Branch (45:14): [True: 2.52k, False: 57.4k]
  ------------------
   46|       |    /* String ends before UTF8 sequence ends */
   47|  2.52k|    length = end - in;
   48|  57.4k|  } else {
   49|  57.4k|    codepoint = ((unsigned)in[0]) & utf8_coding_bits[first];
   50|  76.2k|    for (int i=1; i<length; i++) {
  ------------------
  |  Branch (50:19): [True: 68.5k, False: 7.68k]
  ------------------
   51|  68.5k|      unsigned ch = (unsigned char)in[i];
   52|  68.5k|      if (utf8_coding_length[ch] != UTF8_CONTINUATION_BYTE){
  ------------------
  |  |    1|  68.5k|#define UTF8_CONTINUATION_BYTE ((unsigned char)255)
  ------------------
  |  Branch (52:11): [True: 49.8k, False: 18.7k]
  ------------------
   53|       |        /* Invalid UTF8 sequence - not followed by the right number of continuation bytes */
   54|  49.8k|        codepoint = -1;
   55|  49.8k|        length = i;
   56|  49.8k|        break;
   57|  49.8k|      }
   58|  18.7k|      codepoint = (codepoint << 6) | (ch & 0x3f);
   59|  18.7k|    }
   60|  57.4k|    if (codepoint < utf8_first_codepoint[length]) {
  ------------------
  |  Branch (60:9): [True: 49.8k, False: 7.68k]
  ------------------
   61|       |      /* Overlong UTF8 sequence */
   62|  49.8k|      codepoint = -1;
   63|  49.8k|    }
   64|  57.4k|    if (0xD800 <= codepoint && codepoint <= 0xDFFF) {
  ------------------
  |  Branch (64:9): [True: 5.41k, False: 52.0k]
  |  Branch (64:32): [True: 460, False: 4.95k]
  ------------------
   65|       |      /* Surrogate codepoints can't be encoded in UTF8 */
   66|    460|      codepoint = -1;
   67|    460|    }
   68|  57.4k|    if (codepoint > 0x10FFFF) {
  ------------------
  |  Branch (68:9): [True: 343, False: 57.1k]
  ------------------
   69|       |      /* Outside Unicode range */
   70|    343|      codepoint = -1;
   71|    343|    }
   72|  57.4k|  }
   73|  53.3M|  assert(length > 0);
  ------------------
  |  Branch (73:3): [True: 0, False: 53.3M]
  |  Branch (73:3): [True: 53.3M, False: 0]
  ------------------
   74|  53.3M|  *codepoint_ret = codepoint;
   75|  53.3M|  return in + length;
   76|  53.3M|}
jvp_utf8_is_valid:
   78|  51.3k|int jvp_utf8_is_valid(const char* in, const char* end) {
   79|  51.3k|  int codepoint;
   80|  24.8M|  while ((in = jvp_utf8_next(in, end, &codepoint))) {
  ------------------
  |  Branch (80:10): [True: 24.7M, False: 45.4k]
  ------------------
   81|  24.7M|    if (codepoint == -1) return 0;
  ------------------
  |  Branch (81:9): [True: 5.86k, False: 24.7M]
  ------------------
   82|  24.7M|  }
   83|  45.4k|  return 1;
   84|  51.3k|}
jvp_utf8_encode_length:
   94|  28.5M|int jvp_utf8_encode_length(int codepoint) {
   95|  28.5M|  if (codepoint <= 0x7F) return 1;
  ------------------
  |  Branch (95:7): [True: 25.5M, False: 2.97M]
  ------------------
   96|  2.97M|  else if (codepoint <= 0x7FF) return 2;
  ------------------
  |  Branch (96:12): [True: 1.22k, False: 2.97M]
  ------------------
   97|  2.97M|  else if (codepoint <= 0xFFFF) return 3;
  ------------------
  |  Branch (97:12): [True: 2.96M, False: 4.14k]
  ------------------
   98|  4.14k|  else return 4;
   99|  28.5M|}
jvp_utf8_encode:
  101|  28.5M|int jvp_utf8_encode(int codepoint, char* out) {
  102|  28.5M|  assert(codepoint >= 0 && codepoint <= 0x10FFFF);
  ------------------
  |  Branch (102:3): [True: 0, False: 28.5M]
  |  Branch (102:3): [True: 0, False: 0]
  |  Branch (102:3): [True: 28.5M, False: 0]
  |  Branch (102:3): [True: 28.5M, False: 0]
  ------------------
  103|  28.5M|  char* start = out;
  104|  28.5M|  if (codepoint <= 0x7F) {
  ------------------
  |  Branch (104:7): [True: 25.5M, False: 2.97M]
  ------------------
  105|  25.5M|    *out++ = codepoint;
  106|  25.5M|  } else if (codepoint <= 0x7FF) {
  ------------------
  |  Branch (106:14): [True: 1.22k, False: 2.97M]
  ------------------
  107|  1.22k|    *out++ = 0xC0 + ((codepoint & 0x7C0) >> 6);
  108|  1.22k|    *out++ = 0x80 + ((codepoint & 0x03F));
  109|  2.97M|  } else if(codepoint <= 0xFFFF) {
  ------------------
  |  Branch (109:13): [True: 2.96M, False: 4.14k]
  ------------------
  110|  2.96M|    *out++ = 0xE0 + ((codepoint & 0xF000) >> 12);
  111|  2.96M|    *out++ = 0x80 + ((codepoint & 0x0FC0) >> 6);
  112|  2.96M|    *out++ = 0x80 + ((codepoint & 0x003F));
  113|  2.96M|  } else {
  114|  4.14k|    *out++ = 0xF0 + ((codepoint & 0x1C0000) >> 18);
  115|  4.14k|    *out++ = 0x80 + ((codepoint & 0x03F000) >> 12);
  116|  4.14k|    *out++ = 0x80 + ((codepoint & 0x000FC0) >> 6);
  117|  4.14k|    *out++ = 0x80 + ((codepoint & 0x00003F));
  118|  4.14k|  }
  119|  28.5M|  assert(out - start == jvp_utf8_encode_length(codepoint));
  ------------------
  |  Branch (119:3): [True: 0, False: 28.5M]
  |  Branch (119:3): [True: 28.5M, False: 0]
  ------------------
  120|  28.5M|  return out - start;
  121|  28.5M|}

LLVMFuzzerTestOneInput:
    7|  3.05k|int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
    8|       |  // Creat null-terminated string
    9|  3.05k|  char *null_terminated = (char *)malloc(size + 1);
   10|  3.05k|  memcpy(null_terminated, (char *)data, size);
   11|  3.05k|  null_terminated[size] = '\0';
   12|       |
   13|       |  // Fuzzer entrypoint
   14|  3.05k|  jv res = jv_parse(null_terminated);
   15|  3.05k|  jv_free(res);
   16|       |
   17|       |  // Free the null-terminated string
   18|  3.05k|  free(null_terminated);
   19|       |
   20|  3.05k|  return 0;
   21|  3.05k|}

decContextClearStatus:
   54|  6.54M|decContext *decContextClearStatus(decContext *context, uInt mask) {
   55|  6.54M|  context->status&=~mask;
   56|  6.54M|  return context;
   57|  6.54M|  } // decContextClearStatus
decContextDefault:
   72|      1|decContext * decContextDefault(decContext *context, Int kind) {
   73|       |  // set defaults...
   74|      1|  context->digits=9;                         // 9 digits
   75|      1|  context->emax=DEC_MAX_EMAX;                // 9-digit exponents
  ------------------
  |  |   90|      1|  #define DEC_MAX_EMAX   999999999
  ------------------
   76|      1|  context->emin=DEC_MIN_EMIN;                // .. balanced
  ------------------
  |  |   93|      1|  #define DEC_MIN_EMIN  -999999999
  ------------------
   77|      1|  context->round=DEC_ROUND_HALF_UP;          // 0.5 rises
   78|      1|  context->traps=DEC_Errors;                 // all but informational
  ------------------
  |  |  183|      1|  #define DEC_Errors (DEC_IEEE_754_Division_by_zero |                 \
  |  |  ------------------
  |  |  |  |  167|      1|  #define DEC_IEEE_754_Division_by_zero  (DEC_Division_by_zero)
  |  |  |  |  ------------------
  |  |  |  |  |  |  129|      1|    #define DEC_Division_by_zero     0x00000002
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  184|      1|                      DEC_IEEE_754_Invalid_operation |                \
  |  |  ------------------
  |  |  |  |  173|      1|  #define DEC_IEEE_754_Invalid_operation (DEC_Conversion_syntax |     \
  |  |  |  |  ------------------
  |  |  |  |  |  |  128|      1|    #define DEC_Conversion_syntax    0x00000001
  |  |  |  |  ------------------
  |  |  |  |  174|      1|                                          DEC_Division_impossible |   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  130|      1|    #define DEC_Division_impossible  0x00000004
  |  |  |  |  ------------------
  |  |  |  |  175|      1|                                          DEC_Division_undefined |    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  131|      1|    #define DEC_Division_undefined   0x00000008
  |  |  |  |  ------------------
  |  |  |  |  176|      1|                                          DEC_Insufficient_storage |  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  132|      1|    #define DEC_Insufficient_storage 0x00000010 /* [when malloc fails]  */
  |  |  |  |  ------------------
  |  |  |  |  177|      1|                                          DEC_Invalid_context |       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  134|      1|    #define DEC_Invalid_context      0x00000040
  |  |  |  |  ------------------
  |  |  |  |  178|      1|                                          DEC_Invalid_operation)
  |  |  |  |  ------------------
  |  |  |  |  |  |  135|      1|    #define DEC_Invalid_operation    0x00000080
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  185|      1|                      DEC_IEEE_754_Overflow | DEC_IEEE_754_Underflow)
  |  |  ------------------
  |  |  |  |  179|      1|  #define DEC_IEEE_754_Overflow          (DEC_Overflow)
  |  |  |  |  ------------------
  |  |  |  |  |  |  139|      1|    #define DEC_Overflow             0x00000200
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                                     DEC_IEEE_754_Overflow | DEC_IEEE_754_Underflow)
  |  |  ------------------
  |  |  |  |  180|      1|  #define DEC_IEEE_754_Underflow         (DEC_Underflow)
  |  |  |  |  ------------------
  |  |  |  |  |  |  143|      1|    #define DEC_Underflow            0x00002000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   79|      1|  context->status=0;                         // cleared
   80|      1|  context->clamp=0;                          // no clamping
   81|       |  #if DECSUBSET
   82|       |  context->extended=0;                       // cleared
   83|       |  #endif
   84|      1|  switch (kind) {
   85|      1|    case DEC_INIT_BASE:
  ------------------
  |  |  227|      1|  #define DEC_INIT_BASE         0
  ------------------
  |  Branch (85:5): [True: 1, False: 0]
  ------------------
   86|       |      // [use defaults]
   87|      1|      break;
   88|      0|    case DEC_INIT_DECIMAL32:
  ------------------
  |  |  228|      0|  #define DEC_INIT_DECIMAL32   32
  ------------------
  |  Branch (88:5): [True: 0, False: 1]
  ------------------
   89|      0|      context->digits=7;                     // digits
   90|      0|      context->emax=96;                      // Emax
   91|      0|      context->emin=-95;                     // Emin
   92|      0|      context->round=DEC_ROUND_HALF_EVEN;    // 0.5 to nearest even
   93|      0|      context->traps=0;                      // no traps set
   94|      0|      context->clamp=1;                      // clamp exponents
   95|       |      #if DECSUBSET
   96|       |      context->extended=1;                   // set
   97|       |      #endif
   98|      0|      break;
   99|      0|    case DEC_INIT_DECIMAL64:
  ------------------
  |  |  229|      0|  #define DEC_INIT_DECIMAL64   64
  ------------------
  |  Branch (99:5): [True: 0, False: 1]
  ------------------
  100|      0|      context->digits=16;                    // digits
  101|      0|      context->emax=384;                     // Emax
  102|      0|      context->emin=-383;                    // Emin
  103|      0|      context->round=DEC_ROUND_HALF_EVEN;    // 0.5 to nearest even
  104|      0|      context->traps=0;                      // no traps set
  105|      0|      context->clamp=1;                      // clamp exponents
  106|       |      #if DECSUBSET
  107|       |      context->extended=1;                   // set
  108|       |      #endif
  109|      0|      break;
  110|      0|    case DEC_INIT_DECIMAL128:
  ------------------
  |  |  230|      0|  #define DEC_INIT_DECIMAL128 128
  ------------------
  |  Branch (110:5): [True: 0, False: 1]
  ------------------
  111|      0|      context->digits=34;                    // digits
  112|      0|      context->emax=6144;                    // Emax
  113|      0|      context->emin=-6143;                   // Emin
  114|      0|      context->round=DEC_ROUND_HALF_EVEN;    // 0.5 to nearest even
  115|      0|      context->traps=0;                      // no traps set
  116|      0|      context->clamp=1;                      // clamp exponents
  117|       |      #if DECSUBSET
  118|       |      context->extended=1;                   // set
  119|       |      #endif
  120|      0|      break;
  121|       |
  122|      0|    default:                                 // invalid Kind
  ------------------
  |  Branch (122:5): [True: 0, False: 1]
  ------------------
  123|       |      // use defaults, and ..
  124|      0|      decContextSetStatus(context, DEC_Invalid_operation); // trap
  ------------------
  |  |  135|      0|    #define DEC_Invalid_operation    0x00000080
  ------------------
  125|      1|    }
  126|       |
  127|      1|  return context;} // decContextDefault
decContextSetStatus:
  211|  36.9k|decContext * decContextSetStatus(decContext *context, uInt status) {
  212|  36.9k|  context->status|=status;
  213|  36.9k|  if (status & context->traps) raise(SIGFPE);
  ------------------
  |  Branch (213:7): [True: 0, False: 36.9k]
  ------------------
  214|  36.9k|  return context;} // decContextSetStatus

decNumberFromString:
  479|  6.54M|                                decContext *set) {
  480|  6.54M|  Int   exponent=0;                // working exponent [assume 0]
  ------------------
  |  |   92|  6.54M|  #define Int    int32_t
  ------------------
  481|  6.54M|  uByte bits=0;                    // working flags [assume +ve]
  ------------------
  |  |   89|  6.54M|  #define uByte  uint8_t
  ------------------
  482|  6.54M|  Unit  *res;                      // where result will be built
  ------------------
  |  |   94|  6.54M|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  6.54M|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
  483|  6.54M|  Unit  resbuff[SD2U(DECBUFFER+9)];// local buffer in case need temporary
  ------------------
  |  |   94|  6.54M|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  6.54M|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
  484|       |                                   // [+9 allows for ln() constants]
  485|  6.54M|  Unit  *allocres=NULL;            // -> allocated result, iff allocated
  ------------------
  |  |   94|  6.54M|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  6.54M|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
  486|  6.54M|  Int   d=0;                       // count of digits found in decimal part
  ------------------
  |  |   92|  6.54M|  #define Int    int32_t
  ------------------
  487|  6.54M|  const char *dotchar=NULL;        // where dot was found
  488|  6.54M|  const char *cfirst=chars;        // -> first character of decimal part
  489|  6.54M|  const char *last=NULL;           // -> last digit of decimal part
  490|  6.54M|  const char *c;                   // work
  491|  6.54M|  Unit  *up;                       // ..
  ------------------
  |  |   94|  6.54M|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  6.54M|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
  492|  6.54M|  #if DECDPUN>1
  493|  6.54M|  Int   cut, out;                  // ..
  ------------------
  |  |   92|  6.54M|  #define Int    int32_t
  ------------------
  494|  6.54M|  #endif
  495|  6.54M|  Int   residue;                   // rounding residue
  ------------------
  |  |   92|  6.54M|  #define Int    int32_t
  ------------------
  496|  6.54M|  uInt  status=0;                  // error code
  ------------------
  |  |   93|  6.54M|  #define uInt   uint32_t
  ------------------
  497|       |
  498|       |  #if DECCHECK
  499|       |  if (decCheckOperands(DECUNRESU, DECUNUSED, DECUNUSED, set))
  500|       |    return decNumberZero(dn);
  501|       |  #endif
  502|       |
  503|  6.54M|  do {                             // status & malloc protection
  504|  41.4M|    for (c=chars;; c++) {          // -> input character
  505|  41.4M|      if (*c>='0' && *c<='9') {    // test for Arabic digit
  ------------------
  |  Branch (505:11): [True: 34.9M, False: 6.51M]
  |  Branch (505:22): [True: 34.8M, False: 47.0k]
  ------------------
  506|  34.8M|        last=c;
  507|  34.8M|        d++;                       // count of real digits
  508|  34.8M|        continue;                  // still in decimal part
  509|  34.8M|        }
  510|  6.56M|      if (*c=='.' && dotchar==NULL) { // first '.'
  ------------------
  |  Branch (510:11): [True: 8.62k, False: 6.55M]
  |  Branch (510:22): [True: 8.61k, False: 2]
  ------------------
  511|  8.61k|        dotchar=c;                 // record offset into decimal part
  512|  8.61k|        if (c==cfirst) cfirst++;   // first digit must follow
  ------------------
  |  Branch (512:13): [True: 1.42k, False: 7.19k]
  ------------------
  513|  8.61k|        continue;}
  514|  6.55M|      if (c==chars) {              // first in string...
  ------------------
  |  Branch (514:11): [True: 8.50k, False: 6.54M]
  ------------------
  515|  8.50k|        if (*c=='-') {             // valid - sign
  ------------------
  |  Branch (515:13): [True: 358, False: 8.14k]
  ------------------
  516|    358|          cfirst++;
  517|    358|          bits=DECNEG;
  ------------------
  |  |   31|    358|  #define DECNEG    0x80      /* Sign; 1=negative, 0=positive or zero */
  ------------------
  518|    358|          continue;}
  519|  8.14k|        if (*c=='+') {             // valid + sign
  ------------------
  |  Branch (519:13): [True: 5.28k, False: 2.86k]
  ------------------
  520|  5.28k|          cfirst++;
  521|  5.28k|          continue;}
  522|  8.14k|        }
  523|       |      // *c is not a digit, or a valid +, -, or '.'
  524|  6.54M|      break;
  525|  6.55M|      } // c
  526|       |
  527|  6.54M|    if (last==NULL) {              // no digits yet
  ------------------
  |  Branch (527:9): [True: 2.89k, False: 6.54M]
  ------------------
  528|  2.89k|      status=DEC_Conversion_syntax;// assume the worst
  ------------------
  |  |  128|  2.89k|    #define DEC_Conversion_syntax    0x00000001
  ------------------
  529|  2.89k|      if (*c=='\0') break;         // and no more to come...
  ------------------
  |  Branch (529:11): [True: 25, False: 2.86k]
  ------------------
  530|       |      #if DECSUBSET
  531|       |      // if subset then infinities and NaNs are not allowed
  532|       |      if (!set->extended) break;   // hopeless
  533|       |      #endif
  534|       |      // Infinities and NaNs are possible, here
  535|  2.86k|      if (dotchar!=NULL) break;    // .. unless had a dot
  ------------------
  |  Branch (535:11): [True: 3, False: 2.86k]
  ------------------
  536|  2.86k|      decNumberZero(dn);           // be optimistic
  537|  2.86k|      if (decBiStr(c, "infinity", "INFINITY")
  ------------------
  |  Branch (537:11): [True: 288, False: 2.57k]
  ------------------
  538|  2.57k|       || decBiStr(c, "inf", "INF")) {
  ------------------
  |  Branch (538:11): [True: 325, False: 2.24k]
  ------------------
  539|    613|        dn->bits=bits | DECINF;
  ------------------
  |  |   32|    613|  #define DECINF    0x40      /* 1=Infinity                           */
  ------------------
  540|    613|        status=0;                  // is OK
  541|    613|        break; // all done
  542|    613|        }
  543|       |      // a NaN expected
  544|       |      // 2003.09.10 NaNs are now permitted to have a sign
  545|  2.24k|      dn->bits=bits | DECNAN;      // assume simple NaN
  ------------------
  |  |   33|  2.24k|  #define DECNAN    0x20      /* 1=NaN                                */
  ------------------
  546|  2.24k|      if (*c=='s' || *c=='S') {    // looks like an sNaN
  ------------------
  |  Branch (546:11): [True: 195, False: 2.05k]
  |  Branch (546:22): [True: 206, False: 1.84k]
  ------------------
  547|    401|        c++;
  548|    401|        dn->bits=bits | DECSNAN;
  ------------------
  |  |   34|    401|  #define DECSNAN   0x10      /* 1=sNaN                               */
  ------------------
  549|    401|        }
  550|  2.24k|      if (*c!='n' && *c!='N') break;    // check caseless "NaN"
  ------------------
  |  Branch (550:11): [True: 1.20k, False: 1.04k]
  |  Branch (550:22): [True: 362, False: 839]
  ------------------
  551|  1.88k|      c++;
  552|  1.88k|      if (*c!='a' && *c!='A') break;    // ..
  ------------------
  |  Branch (552:11): [True: 563, False: 1.32k]
  |  Branch (552:22): [True: 53, False: 510]
  ------------------
  553|  1.83k|      c++;
  554|  1.83k|      if (*c!='n' && *c!='N') break;    // ..
  ------------------
  |  Branch (554:11): [True: 1.03k, False: 800]
  |  Branch (554:22): [True: 40, False: 994]
  ------------------
  555|  1.79k|      c++;
  556|       |      // now either nothing, or nnnn payload, expected
  557|       |      // -> start of integer and skip leading 0s [including plain 0]
  558|  2.14k|      for (cfirst=c; *cfirst=='0';) cfirst++;
  ------------------
  |  Branch (558:22): [True: 352, False: 1.79k]
  ------------------
  559|  1.79k|      if (*cfirst=='\0') {         // "NaN" or "sNaN", maybe with all 0s
  ------------------
  |  Branch (559:11): [True: 1.72k, False: 70]
  ------------------
  560|  1.72k|        status=0;                  // it's good
  561|  1.72k|        break;                     // ..
  562|  1.72k|        }
  563|       |      // something other than 0s; setup last and d as usual [no dots]
  564|  2.92M|      for (c=cfirst;; c++, d++) {
  565|  2.92M|        if (*c<'0' || *c>'9') break; // test for Arabic digit
  ------------------
  |  Branch (565:13): [True: 62, False: 2.92M]
  |  Branch (565:23): [True: 8, False: 2.92M]
  ------------------
  566|  2.92M|        last=c;
  567|  2.92M|        }
  568|     70|      if (*c!='\0') break;         // not all digits
  ------------------
  |  Branch (568:11): [True: 23, False: 47]
  ------------------
  569|     47|      if (d>set->digits-1) {
  ------------------
  |  Branch (569:11): [True: 0, False: 47]
  ------------------
  570|       |        // [NB: payload in a decNumber can be full length unless
  571|       |        // clamped, in which case can only be digits-1]
  572|      0|        if (set->clamp) break;
  ------------------
  |  Branch (572:13): [True: 0, False: 0]
  ------------------
  573|      0|        if (d>set->digits) break;
  ------------------
  |  Branch (573:13): [True: 0, False: 0]
  ------------------
  574|      0|        } // too many digits?
  575|       |      // good; drop through to convert the integer to coefficient
  576|     47|      status=0;                    // syntax is OK
  577|     47|      bits=dn->bits;               // for copy-back
  578|     47|      } // last==NULL
  579|       |
  580|  6.54M|     else if (*c!='\0') {          // more to process...
  ------------------
  |  Branch (580:15): [True: 44.4k, False: 6.50M]
  ------------------
  581|       |      // had some digits; exponent is only valid sequence now
  582|  44.4k|      Flag nege;                   // 1=negative exponent
  ------------------
  |  |   87|  44.4k|  #define Flag   uint8_t
  ------------------
  583|  44.4k|      const char *firstexp;        // -> first significant exponent digit
  584|  44.4k|      status=DEC_Conversion_syntax;// assume the worst
  ------------------
  |  |  128|  44.4k|    #define DEC_Conversion_syntax    0x00000001
  ------------------
  585|  44.4k|      uInt expa=0;                 // accumulator for exponent
  ------------------
  |  |   93|  44.4k|  #define uInt   uint32_t
  ------------------
  586|  44.4k|      if (*c!='e' && *c!='E') break;
  ------------------
  |  Branch (586:11): [True: 41.9k, False: 2.50k]
  |  Branch (586:22): [True: 36, False: 41.9k]
  ------------------
  587|       |      /* Found 'e' or 'E' -- now process explicit exponent */
  588|       |      // 1998.07.11: sign no longer required
  589|  44.4k|      nege=0;
  590|  44.4k|      c++;                         // to (possible) sign
  591|  44.4k|      if (*c=='-') {nege=1; c++;}
  ------------------
  |  Branch (591:11): [True: 23.2k, False: 21.1k]
  ------------------
  592|  21.1k|       else if (*c=='+') c++;
  ------------------
  |  Branch (592:17): [True: 842, False: 20.3k]
  ------------------
  593|  44.4k|      if (*c=='\0') break;
  ------------------
  |  Branch (593:11): [True: 25, False: 44.4k]
  ------------------
  594|       |
  595|  44.8k|      for (; *c=='0' && *(c+1)!='\0';) c++;  // strip insignificant zeros
  ------------------
  |  Branch (595:14): [True: 693, False: 44.1k]
  |  Branch (595:25): [True: 459, False: 234]
  ------------------
  596|  44.4k|      firstexp=c;                            // save exponent digit place
  597|  2.62M|      for (; ;c++) {
  598|  2.62M|        if (*c<'0' || *c>'9') break;         // not a digit
  ------------------
  |  Branch (598:13): [True: 44.3k, False: 2.57M]
  |  Branch (598:23): [True: 9, False: 2.57M]
  ------------------
  599|  2.57M|        expa=X10(expa)+(Int)*c-(Int)'0';
  ------------------
  |  |  163|  2.57M|  #define X10(i)  (((i)<<1)+((i)<<3))
  ------------------
  600|  2.57M|        } // c
  601|       |      // if not now on a '\0', *c must not be a digit
  602|  44.4k|      if (*c!='\0') break;
  ------------------
  |  Branch (602:11): [True: 33, False: 44.3k]
  ------------------
  603|       |
  604|       |      // (this next test must be after the syntax checks)
  605|       |      // if it was too long the exponent may have wrapped, so check
  606|       |      // carefully and set it to a certain overflow if wrap possible
  607|  44.3k|      if (c>=firstexp+9+1) {
  ------------------
  |  Branch (607:11): [True: 36.2k, False: 8.09k]
  ------------------
  608|  36.2k|        if (c>firstexp+9+1 || *firstexp>'1') expa=DECNUMMAXE*2;
  ------------------
  |  |  183|  11.1k|  #define DECNUMMAXE 999999999  /* maximum adjusted exponent ditto    */
  ------------------
  |  Branch (608:13): [True: 10.5k, False: 25.7k]
  |  Branch (608:31): [True: 570, False: 25.1k]
  ------------------
  609|       |        // [up to 1999999999 is OK, for example 1E-1000000998]
  610|  36.2k|        }
  611|  44.3k|      exponent=(Int)expa;               // save exponent
  612|  44.3k|      if (nege) exponent=-exponent;     // was negative
  ------------------
  |  Branch (612:11): [True: 23.2k, False: 21.1k]
  ------------------
  613|  44.3k|      status=0;                         // is OK
  614|  44.3k|      } // stuff after digits
  615|       |
  616|       |    // Here when whole string has been inspected; syntax is good
  617|       |    // cfirst->first digit (never dot), last->last digit (ditto)
  618|       |
  619|       |    // strip leading zeros/dot [leave final 0 if all 0's]
  620|  6.54M|    if (*cfirst=='0') {                 // [cfirst has stepped over .]
  ------------------
  |  Branch (620:9): [True: 2.53M, False: 4.01M]
  ------------------
  621|  2.57M|      for (c=cfirst; c<last; c++, cfirst++) {
  ------------------
  |  Branch (621:22): [True: 37.8k, False: 2.53M]
  ------------------
  622|  37.8k|        if (*c=='.') continue;          // ignore dots
  ------------------
  |  Branch (622:13): [True: 5.21k, False: 32.6k]
  ------------------
  623|  32.6k|        if (*c!='0') break;             // non-zero found
  ------------------
  |  Branch (623:13): [True: 750, False: 31.9k]
  ------------------
  624|  31.9k|        d--;                            // 0 stripped
  625|  31.9k|        } // c
  626|       |      #if DECSUBSET
  627|       |      // make a rapid exit for easy zeros if !extended
  628|       |      if (*cfirst=='0' && !set->extended) {
  629|       |        decNumberZero(dn);              // clean result
  630|       |        break;                          // [could be return]
  631|       |        }
  632|       |      #endif
  633|  2.53M|      } // at least one leading 0
  634|       |
  635|       |    // Handle decimal point...
  636|  6.54M|    if (dotchar!=NULL && dotchar<last)  // non-trailing '.' found?
  ------------------
  |  Branch (636:9): [True: 8.60k, False: 6.53M]
  |  Branch (636:26): [True: 8.32k, False: 281]
  ------------------
  637|  8.32k|      exponent-=(last-dotchar);         // adjust exponent
  638|       |    // [we can now ignore the .]
  639|       |
  640|       |    // OK, the digits string is good.  Assemble in the decNumber, or in
  641|       |    // a temporary units array if rounding is needed
  642|  6.54M|    if (d<=set->digits) res=dn->lsu;    // fits into supplied decNumber
  ------------------
  |  Branch (642:9): [True: 6.54M, False: 0]
  ------------------
  643|      0|     else {                             // rounding needed
  644|      0|      Int needbytes=D2U(d)*sizeof(Unit);// bytes needed
  ------------------
  |  |   92|      0|  #define Int    int32_t
  ------------------
                    Int needbytes=D2U(d)*sizeof(Unit);// bytes needed
  ------------------
  |  |  264|      0|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|      0|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|      0|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|      0|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  645|      0|      res=resbuff;                      // assume use local buffer
  646|      0|      if (needbytes>(Int)sizeof(resbuff)) { // too big for local
  ------------------
  |  Branch (646:11): [True: 0, False: 0]
  ------------------
  647|      0|        allocres=(Unit *)malloc(needbytes);
  648|      0|        if (allocres==NULL) {status|=DEC_Insufficient_storage; break;}
  ------------------
  |  |  132|      0|    #define DEC_Insufficient_storage 0x00000010 /* [when malloc fails]  */
  ------------------
  |  Branch (648:13): [True: 0, False: 0]
  ------------------
  649|      0|        res=allocres;
  650|      0|        }
  651|      0|      }
  652|       |    // res now -> number lsu, buffer, or allocated storage for Unit array
  653|       |
  654|       |    // Place the coefficient into the selected Unit array
  655|       |    // [this is often 70% of the cost of this function when DECDPUN>1]
  656|  6.54M|    #if DECDPUN>1
  657|  6.54M|    out=0;                         // accumulator
  658|  6.54M|    up=res+D2U(d)-1;               // -> msu
  ------------------
  |  |  264|  6.54M|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|  6.54M|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    938|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    938|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 6.54M, False: 938]
  |  |  ------------------
  ------------------
  659|  6.54M|    cut=d-(up-res)*DECDPUN;        // digits in top unit
  ------------------
  |  |   43|  6.54M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  660|  37.0M|    for (c=cfirst;; c++) {         // along the digits
  661|  37.0M|      if (*c=='.') continue;       // ignore '.' [don't decrement cut]
  ------------------
  |  Branch (661:11): [True: 1.69k, False: 37.0M]
  ------------------
  662|  37.0M|      out=X10(out)+(Int)*c-(Int)'0';
  ------------------
  |  |  163|  37.0M|  #define X10(i)  (((i)<<1)+((i)<<3))
  ------------------
  663|  37.0M|      if (c==last) break;          // done [never get to trailing '.']
  ------------------
  |  Branch (663:11): [True: 6.54M, False: 30.5M]
  ------------------
  664|  30.5M|      cut--;
  665|  30.5M|      if (cut>0) continue;         // more for this unit
  ------------------
  |  Branch (665:11): [True: 20.4M, False: 10.1M]
  ------------------
  666|  10.1M|      *up=(Unit)out;               // write unit
  667|  10.1M|      up--;                        // prepare for unit below..
  668|  10.1M|      cut=DECDPUN;                 // ..
  ------------------
  |  |   43|  10.1M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  669|  10.1M|      out=0;                       // ..
  670|  10.1M|      } // c
  671|  6.54M|    *up=(Unit)out;                 // write lsu
  672|       |
  673|       |    #else
  674|       |    // DECDPUN==1
  675|       |    up=res;                        // -> lsu
  676|       |    for (c=last; c>=cfirst; c--) { // over each character, from least
  677|       |      if (*c=='.') continue;       // ignore . [don't step up]
  678|       |      *up=(Unit)((Int)*c-(Int)'0');
  679|       |      up++;
  680|       |      } // c
  681|       |    #endif
  682|       |
  683|  6.54M|    dn->bits=bits;
  684|  6.54M|    dn->exponent=exponent;
  685|  6.54M|    dn->digits=d;
  686|       |
  687|       |    // if not in number (too long) shorten into the number
  688|  6.54M|    if (d>set->digits) {
  ------------------
  |  Branch (688:9): [True: 0, False: 6.54M]
  ------------------
  689|      0|      residue=0;
  690|      0|      decSetCoeff(dn, set, res, d, &residue, &status);
  691|       |      // always check for overflow or subnormal and round as needed
  692|      0|      decFinalize(dn, set, &residue, &status);
  693|      0|      }
  694|  6.54M|     else { // no rounding, but may still have overflow or subnormal
  695|       |      // [these tests are just for performance; finalize repeats them]
  696|  6.54M|      if ((dn->exponent-1<set->emin-dn->digits)
  ------------------
  |  Branch (696:11): [True: 19.9k, False: 6.52M]
  ------------------
  697|  6.52M|       || (dn->exponent-1>set->emax-set->digits)) {
  ------------------
  |  Branch (697:11): [True: 17.0k, False: 6.50M]
  ------------------
  698|  36.9k|        residue=0;
  699|  36.9k|        decFinalize(dn, set, &residue, &status);
  700|  36.9k|        }
  701|  6.54M|      }
  702|       |    // decNumberShow(dn);
  703|  6.54M|    } while(0);                         // [for break]
  ------------------
  |  Branch (703:13): [Folded, False: 6.54M]
  ------------------
  704|       |
  705|  6.54M|  if (allocres!=NULL) free(allocres);   // drop any storage used
  ------------------
  |  Branch (705:7): [True: 0, False: 6.54M]
  ------------------
  706|  6.54M|  if (status!=0) decStatus(dn, status, set);
  ------------------
  |  Branch (706:7): [True: 36.9k, False: 6.51M]
  ------------------
  707|  6.54M|  return dn;
  708|  6.54M|  } /* decNumberFromString */
decNumberZero:
 3588|  19.5k|decNumber * decNumberZero(decNumber *dn) {
 3589|       |
 3590|       |  #if DECCHECK
 3591|       |  if (decCheckOperands(dn, DECUNUSED, DECUNUSED, DECUNCONT)) return dn;
 3592|       |  #endif
 3593|       |
 3594|  19.5k|  dn->bits=0;
 3595|  19.5k|  dn->exponent=0;
 3596|  19.5k|  dn->digits=1;
 3597|  19.5k|  dn->lsu[0]=0;
 3598|  19.5k|  return dn;
 3599|  19.5k|  } // decNumberZero
decNumber.c:decUnitAddSub:
 6339|  2.47k|                         Unit *c, Int m) {
 6340|  2.47k|  const Unit *alsu=a;              // A lsu [need to remember it]
 6341|  2.47k|  Unit *clsu=c;                    // C ditto
  ------------------
  |  |   94|  2.47k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  2.47k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6342|  2.47k|  Unit *minC;                      // low water mark for C
  ------------------
  |  |   94|  2.47k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  2.47k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6343|  2.47k|  Unit *maxC;                      // high water mark for C
  ------------------
  |  |   94|  2.47k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  2.47k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6344|  2.47k|  eInt carry=0;                    // carry integer (could be Long)
  ------------------
  |  |  203|  2.47k|  #define eInt  Int           // extended integer
  |  |  ------------------
  |  |  |  |   92|  2.47k|  #define Int    int32_t
  |  |  ------------------
  ------------------
 6345|  2.47k|  Int  add;                        // work
  ------------------
  |  |   92|  2.47k|  #define Int    int32_t
  ------------------
 6346|  2.47k|  #if DECDPUN<=4                   // myriadal, millenary, etc.
 6347|  2.47k|  Int  est;                        // estimated quotient
  ------------------
  |  |   92|  2.47k|  #define Int    int32_t
  ------------------
 6348|  2.47k|  #endif
 6349|       |
 6350|       |  #if DECTRACE
 6351|       |  if (alength<1 || blength<1)
 6352|       |    printf("decUnitAddSub: alen blen m %ld %ld [%ld]\n", alength, blength, m);
 6353|       |  #endif
 6354|       |
 6355|  2.47k|  maxC=c+alength;                  // A is usually the longer
 6356|  2.47k|  minC=c+blength;                  // .. and B the shorter
 6357|  2.47k|  if (bshift!=0) {                 // B is shifted; low As copy across
  ------------------
  |  Branch (6357:7): [True: 0, False: 2.47k]
  ------------------
 6358|      0|    minC+=bshift;
 6359|       |    // if in place [common], skip copy unless there's a gap [rare]
 6360|      0|    if (a==c && bshift<=alength) {
  ------------------
  |  Branch (6360:9): [True: 0, False: 0]
  |  Branch (6360:17): [True: 0, False: 0]
  ------------------
 6361|      0|      c+=bshift;
 6362|      0|      a+=bshift;
 6363|      0|      }
 6364|      0|     else for (; c<clsu+bshift; a++, c++) {  // copy needed
  ------------------
  |  Branch (6364:18): [True: 0, False: 0]
  ------------------
 6365|      0|      if (a<alsu+alength) *c=*a;
  ------------------
  |  Branch (6365:11): [True: 0, False: 0]
  ------------------
 6366|      0|       else *c=0;
 6367|      0|      }
 6368|      0|    }
 6369|  2.47k|  if (minC>maxC) { // swap
  ------------------
  |  Branch (6369:7): [True: 0, False: 2.47k]
  ------------------
 6370|      0|    Unit *hold=minC;
  ------------------
  |  |   94|      0|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|      0|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6371|      0|    minC=maxC;
 6372|      0|    maxC=hold;
 6373|      0|    }
 6374|       |
 6375|       |  // For speed, do the addition as two loops; the first where both A
 6376|       |  // and B contribute, and the second (if necessary) where only one or
 6377|       |  // other of the numbers contribute.
 6378|       |  // Carry handling is the same (i.e., duplicated) in each case.
 6379|  4.94k|  for (; c<minC; c++) {
  ------------------
  |  Branch (6379:10): [True: 2.47k, False: 2.47k]
  ------------------
 6380|  2.47k|    carry+=*a;
 6381|  2.47k|    a++;
 6382|  2.47k|    carry+=((eInt)*b)*m;                // [special-casing m=1/-1
 6383|  2.47k|    b++;                                // here is not a win]
 6384|       |    // here carry is new Unit of digits; it could be +ve or -ve
 6385|  2.47k|    if ((ueInt)carry<=DECDPUNMAX) {     // fastpath 0-DECDPUNMAX
  ------------------
  |  |  209|  2.47k|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6385:9): [True: 2.16k, False: 306]
  ------------------
 6386|  2.16k|      *c=(Unit)carry;
 6387|  2.16k|      carry=0;
 6388|  2.16k|      continue;
 6389|  2.16k|      }
 6390|       |    #if DECDPUN==4                           // use divide-by-multiply
 6391|       |      if (carry>=0) {
 6392|       |        est=(((ueInt)carry>>11)*53687)>>18;
 6393|       |        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder
 6394|       |        carry=est;                           // likely quotient [89%]
 6395|       |        if (*c<DECDPUNMAX+1) continue;       // estimate was correct
 6396|       |        carry++;
 6397|       |        *c-=DECDPUNMAX+1;
 6398|       |        continue;
 6399|       |        }
 6400|       |      // negative case
 6401|       |      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive
 6402|       |      est=(((ueInt)carry>>11)*53687)>>18;
 6403|       |      *c=(Unit)(carry-est*(DECDPUNMAX+1));
 6404|       |      carry=est-(DECDPUNMAX+1);              // correctly negative
 6405|       |      if (*c<DECDPUNMAX+1) continue;         // was OK
 6406|       |      carry++;
 6407|       |      *c-=DECDPUNMAX+1;
 6408|       |    #elif DECDPUN==3
 6409|    306|      if (carry>=0) {
  ------------------
  |  Branch (6409:11): [True: 306, False: 0]
  ------------------
 6410|    306|        est=(((ueInt)carry>>3)*16777)>>21;
 6411|    306|        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder
  ------------------
  |  |  209|    306|    #define DECDPUNMAX 999
  ------------------
 6412|    306|        carry=est;                           // likely quotient [99%]
 6413|    306|        if (*c<DECDPUNMAX+1) continue;       // estimate was correct
  ------------------
  |  |  209|    306|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6413:13): [True: 0, False: 306]
  ------------------
 6414|    306|        carry++;
 6415|    306|        *c-=DECDPUNMAX+1;
  ------------------
  |  |  209|    306|    #define DECDPUNMAX 999
  ------------------
 6416|    306|        continue;
 6417|    306|        }
 6418|       |      // negative case
 6419|      0|      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
                    carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
 6420|      0|      est=(((ueInt)carry>>3)*16777)>>21;
 6421|      0|      *c=(Unit)(carry-est*(DECDPUNMAX+1));
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
 6422|      0|      carry=est-(DECDPUNMAX+1);              // correctly negative
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
 6423|      0|      if (*c<DECDPUNMAX+1) continue;         // was OK
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6423:11): [True: 0, False: 0]
  ------------------
 6424|      0|      carry++;
 6425|      0|      *c-=DECDPUNMAX+1;
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
 6426|       |    #elif DECDPUN<=2
 6427|       |      // Can use QUOT10 as carry <= 4 digits
 6428|       |      if (carry>=0) {
 6429|       |        est=QUOT10(carry, DECDPUN);
 6430|       |        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder
 6431|       |        carry=est;                           // quotient
 6432|       |        continue;
 6433|       |        }
 6434|       |      // negative case
 6435|       |      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive
 6436|       |      est=QUOT10(carry, DECDPUN);
 6437|       |      *c=(Unit)(carry-est*(DECDPUNMAX+1));
 6438|       |      carry=est-(DECDPUNMAX+1);              // correctly negative
 6439|       |    #else
 6440|       |      // remainder operator is undefined if negative, so must test
 6441|       |      if ((ueInt)carry<(DECDPUNMAX+1)*2) {   // fastpath carry +1
 6442|       |        *c=(Unit)(carry-(DECDPUNMAX+1));     // [helps additions]
 6443|       |        carry=1;
 6444|       |        continue;
 6445|       |        }
 6446|       |      if (carry>=0) {
 6447|       |        *c=(Unit)(carry%(DECDPUNMAX+1));
 6448|       |        carry=carry/(DECDPUNMAX+1);
 6449|       |        continue;
 6450|       |        }
 6451|       |      // negative case
 6452|       |      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive
 6453|       |      *c=(Unit)(carry%(DECDPUNMAX+1));
 6454|       |      carry=carry/(DECDPUNMAX+1)-(DECDPUNMAX+1);
 6455|       |    #endif
 6456|      0|    } // c
 6457|       |
 6458|       |  // now may have one or other to complete
 6459|       |  // [pretest to avoid loop setup/shutdown]
 6460|  2.46M|  if (c<maxC) for (; c<maxC; c++) {
  ------------------
  |  Branch (6460:7): [True: 1.26k, False: 1.20k]
  |  Branch (6460:22): [True: 2.46M, False: 1.26k]
  ------------------
 6461|  2.46M|    if (a<alsu+alength) {               // still in A
  ------------------
  |  Branch (6461:9): [True: 2.46M, False: 0]
  ------------------
 6462|  2.46M|      carry+=*a;
 6463|  2.46M|      a++;
 6464|  2.46M|      }
 6465|      0|     else {                             // inside B
 6466|      0|      carry+=((eInt)*b)*m;
 6467|      0|      b++;
 6468|      0|      }
 6469|       |    // here carry is new Unit of digits; it could be +ve or -ve and
 6470|       |    // magnitude up to DECDPUNMAX squared
 6471|  2.46M|    if ((ueInt)carry<=DECDPUNMAX) {     // fastpath 0-DECDPUNMAX
  ------------------
  |  |  209|  2.46M|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6471:9): [True: 1.42M, False: 1.04M]
  ------------------
 6472|  1.42M|      *c=(Unit)carry;
 6473|  1.42M|      carry=0;
 6474|  1.42M|      continue;
 6475|  1.42M|      }
 6476|       |    // result for this unit is negative or >DECDPUNMAX
 6477|       |    #if DECDPUN==4                           // use divide-by-multiply
 6478|       |      if (carry>=0) {
 6479|       |        est=(((ueInt)carry>>11)*53687)>>18;
 6480|       |        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder
 6481|       |        carry=est;                           // likely quotient [79.7%]
 6482|       |        if (*c<DECDPUNMAX+1) continue;       // estimate was correct
 6483|       |        carry++;
 6484|       |        *c-=DECDPUNMAX+1;
 6485|       |        continue;
 6486|       |        }
 6487|       |      // negative case
 6488|       |      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive
 6489|       |      est=(((ueInt)carry>>11)*53687)>>18;
 6490|       |      *c=(Unit)(carry-est*(DECDPUNMAX+1));
 6491|       |      carry=est-(DECDPUNMAX+1);              // correctly negative
 6492|       |      if (*c<DECDPUNMAX+1) continue;         // was OK
 6493|       |      carry++;
 6494|       |      *c-=DECDPUNMAX+1;
 6495|       |    #elif DECDPUN==3
 6496|  1.04M|      if (carry>=0) {
  ------------------
  |  Branch (6496:11): [True: 1.04M, False: 0]
  ------------------
 6497|  1.04M|        est=(((ueInt)carry>>3)*16777)>>21;
 6498|  1.04M|        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder
  ------------------
  |  |  209|  1.04M|    #define DECDPUNMAX 999
  ------------------
 6499|  1.04M|        carry=est;                           // likely quotient [99%]
 6500|  1.04M|        if (*c<DECDPUNMAX+1) continue;       // estimate was correct
  ------------------
  |  |  209|  1.04M|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6500:13): [True: 0, False: 1.04M]
  ------------------
 6501|  1.04M|        carry++;
 6502|  1.04M|        *c-=DECDPUNMAX+1;
  ------------------
  |  |  209|  1.04M|    #define DECDPUNMAX 999
  ------------------
 6503|  1.04M|        continue;
 6504|  1.04M|        }
 6505|       |      // negative case
 6506|      0|      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
                    carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
 6507|      0|      est=(((ueInt)carry>>3)*16777)>>21;
 6508|      0|      *c=(Unit)(carry-est*(DECDPUNMAX+1));
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
 6509|      0|      carry=est-(DECDPUNMAX+1);              // correctly negative
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
 6510|      0|      if (*c<DECDPUNMAX+1) continue;         // was OK
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6510:11): [True: 0, False: 0]
  ------------------
 6511|      0|      carry++;
 6512|      0|      *c-=DECDPUNMAX+1;
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
 6513|       |    #elif DECDPUN<=2
 6514|       |      if (carry>=0) {
 6515|       |        est=QUOT10(carry, DECDPUN);
 6516|       |        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder
 6517|       |        carry=est;                           // quotient
 6518|       |        continue;
 6519|       |        }
 6520|       |      // negative case
 6521|       |      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive
 6522|       |      est=QUOT10(carry, DECDPUN);
 6523|       |      *c=(Unit)(carry-est*(DECDPUNMAX+1));
 6524|       |      carry=est-(DECDPUNMAX+1);              // correctly negative
 6525|       |    #else
 6526|       |      if ((ueInt)carry<(DECDPUNMAX+1)*2){    // fastpath carry 1
 6527|       |        *c=(Unit)(carry-(DECDPUNMAX+1));
 6528|       |        carry=1;
 6529|       |        continue;
 6530|       |        }
 6531|       |      // remainder operator is undefined if negative, so must test
 6532|       |      if (carry>=0) {
 6533|       |        *c=(Unit)(carry%(DECDPUNMAX+1));
 6534|       |        carry=carry/(DECDPUNMAX+1);
 6535|       |        continue;
 6536|       |        }
 6537|       |      // negative case
 6538|       |      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive
 6539|       |      *c=(Unit)(carry%(DECDPUNMAX+1));
 6540|       |      carry=carry/(DECDPUNMAX+1)-(DECDPUNMAX+1);
 6541|       |    #endif
 6542|      0|    } // c
 6543|       |
 6544|       |  // OK, all A and B processed; might still have carry or borrow
 6545|       |  // return number of Units in the result, negated if a borrow
 6546|  2.47k|  if (carry==0) return c-clsu;     // no carry, so no more to do
  ------------------
  |  Branch (6546:7): [True: 2.47k, False: 0]
  ------------------
 6547|      0|  if (carry>0) {                   // positive carry
  ------------------
  |  Branch (6547:7): [True: 0, False: 0]
  ------------------
 6548|      0|    *c=(Unit)carry;                // place as new unit
 6549|      0|    c++;                           // ..
 6550|      0|    return c-clsu;
 6551|      0|    }
 6552|       |  // -ve carry: it's a borrow; complement needed
 6553|      0|  add=1;                           // temporary carry...
 6554|      0|  for (c=clsu; c<maxC; c++) {
  ------------------
  |  Branch (6554:16): [True: 0, False: 0]
  ------------------
 6555|      0|    add=DECDPUNMAX+add-*c;
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
 6556|      0|    if (add<=DECDPUNMAX) {
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6556:9): [True: 0, False: 0]
  ------------------
 6557|      0|      *c=(Unit)add;
 6558|      0|      add=0;
 6559|      0|      }
 6560|      0|     else {
 6561|      0|      *c=0;
 6562|      0|      add=1;
 6563|      0|      }
 6564|      0|    }
 6565|       |  // add an extra unit iff it would be non-zero
 6566|       |  #if DECTRACE
 6567|       |    printf("UAS borrow: add %ld, carry %ld\n", add, carry);
 6568|       |  #endif
 6569|      0|  if ((add-carry-1)!=0) {
  ------------------
  |  Branch (6569:7): [True: 0, False: 0]
  ------------------
 6570|      0|    *c=(Unit)(add-carry-1);
 6571|      0|    c++;                      // interesting, include it
 6572|      0|    }
 6573|      0|  return clsu-c;              // -ve result indicates borrowed
 6574|      0|  } // decUnitAddSub
decNumber.c:decApplyRound:
 7071|  18.6k|                          uInt *status) {
 7072|  18.6k|  Int  bump;                  // 1 if coefficient needs to be incremented
  ------------------
  |  |   92|  18.6k|  #define Int    int32_t
  ------------------
 7073|       |                              // -1 if coefficient needs to be decremented
 7074|       |
 7075|  18.6k|  if (residue==0) return;     // nothing to apply
  ------------------
  |  Branch (7075:7): [True: 2.95k, False: 15.6k]
  ------------------
 7076|       |
 7077|  15.6k|  bump=0;                     // assume a smooth ride
 7078|       |
 7079|       |  // now decide whether, and how, to round, depending on mode
 7080|  15.6k|  switch (set->round) {
 7081|      0|    case DEC_ROUND_05UP: {    // round zero or five up (for reround)
  ------------------
  |  Branch (7081:5): [True: 0, False: 15.6k]
  ------------------
 7082|       |      // This is the same as DEC_ROUND_DOWN unless there is a
 7083|       |      // positive residue and the lsd of dn is 0 or 5, in which case
 7084|       |      // it is bumped; when residue is <0, the number is therefore
 7085|       |      // bumped down unless the final digit was 1 or 6 (in which
 7086|       |      // case it is bumped down and then up -- a no-op)
 7087|      0|      Int lsd5=*dn->lsu%5;     // get lsd and quintate
  ------------------
  |  |   92|      0|  #define Int    int32_t
  ------------------
 7088|      0|      if (residue<0 && lsd5!=1) bump=-1;
  ------------------
  |  Branch (7088:11): [True: 0, False: 0]
  |  Branch (7088:24): [True: 0, False: 0]
  ------------------
 7089|      0|       else if (residue>0 && lsd5==0) bump=1;
  ------------------
  |  Branch (7089:17): [True: 0, False: 0]
  |  Branch (7089:30): [True: 0, False: 0]
  ------------------
 7090|       |      // [bump==1 could be applied directly; use common path for clarity]
 7091|      0|      break;} // r-05
 7092|       |
 7093|      0|    case DEC_ROUND_DOWN: {
  ------------------
  |  Branch (7093:5): [True: 0, False: 15.6k]
  ------------------
 7094|       |      // no change, except if negative residue
 7095|      0|      if (residue<0) bump=-1;
  ------------------
  |  Branch (7095:11): [True: 0, False: 0]
  ------------------
 7096|      0|      break;} // r-d
 7097|       |
 7098|      0|    case DEC_ROUND_HALF_DOWN: {
  ------------------
  |  Branch (7098:5): [True: 0, False: 15.6k]
  ------------------
 7099|      0|      if (residue>5) bump=1;
  ------------------
  |  Branch (7099:11): [True: 0, False: 0]
  ------------------
 7100|      0|      break;} // r-h-d
 7101|       |
 7102|      0|    case DEC_ROUND_HALF_EVEN: {
  ------------------
  |  Branch (7102:5): [True: 0, False: 15.6k]
  ------------------
 7103|      0|      if (residue>5) bump=1;            // >0.5 goes up
  ------------------
  |  Branch (7103:11): [True: 0, False: 0]
  ------------------
 7104|      0|       else if (residue==5) {           // exactly 0.5000...
  ------------------
  |  Branch (7104:17): [True: 0, False: 0]
  ------------------
 7105|       |        // 0.5 goes up iff [new] lsd is odd
 7106|      0|        if (*dn->lsu & 0x01) bump=1;
  ------------------
  |  Branch (7106:13): [True: 0, False: 0]
  ------------------
 7107|      0|        }
 7108|      0|      break;} // r-h-e
 7109|       |
 7110|  15.6k|    case DEC_ROUND_HALF_UP: {
  ------------------
  |  Branch (7110:5): [True: 15.6k, False: 0]
  ------------------
 7111|  15.6k|      if (residue>=5) bump=1;
  ------------------
  |  Branch (7111:11): [True: 3.59k, False: 12.0k]
  ------------------
 7112|  15.6k|      break;} // r-h-u
 7113|       |
 7114|      0|    case DEC_ROUND_UP: {
  ------------------
  |  Branch (7114:5): [True: 0, False: 15.6k]
  ------------------
 7115|      0|      if (residue>0) bump=1;
  ------------------
  |  Branch (7115:11): [True: 0, False: 0]
  ------------------
 7116|      0|      break;} // r-u
 7117|       |
 7118|      0|    case DEC_ROUND_CEILING: {
  ------------------
  |  Branch (7118:5): [True: 0, False: 15.6k]
  ------------------
 7119|       |      // same as _UP for positive numbers, and as _DOWN for negatives
 7120|       |      // [negative residue cannot occur on 0]
 7121|      0|      if (decNumberIsNegative(dn)) {
  ------------------
  |  |  173|      0|  #define decNumberIsNegative(dn)  (((dn)->bits&DECNEG)!=0)
  |  |  ------------------
  |  |  |  |   31|      0|  #define DECNEG    0x80      /* Sign; 1=negative, 0=positive or zero */
  |  |  ------------------
  |  |  |  Branch (173:36): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 7122|      0|        if (residue<0) bump=-1;
  ------------------
  |  Branch (7122:13): [True: 0, False: 0]
  ------------------
 7123|      0|        }
 7124|      0|       else {
 7125|      0|        if (residue>0) bump=1;
  ------------------
  |  Branch (7125:13): [True: 0, False: 0]
  ------------------
 7126|      0|        }
 7127|      0|      break;} // r-c
 7128|       |
 7129|      0|    case DEC_ROUND_FLOOR: {
  ------------------
  |  Branch (7129:5): [True: 0, False: 15.6k]
  ------------------
 7130|       |      // same as _UP for negative numbers, and as _DOWN for positive
 7131|       |      // [negative residue cannot occur on 0]
 7132|      0|      if (!decNumberIsNegative(dn)) {
  ------------------
  |  |  173|      0|  #define decNumberIsNegative(dn)  (((dn)->bits&DECNEG)!=0)
  |  |  ------------------
  |  |  |  |   31|      0|  #define DECNEG    0x80      /* Sign; 1=negative, 0=positive or zero */
  |  |  ------------------
  ------------------
  |  Branch (7132:11): [True: 0, False: 0]
  ------------------
 7133|      0|        if (residue<0) bump=-1;
  ------------------
  |  Branch (7133:13): [True: 0, False: 0]
  ------------------
 7134|      0|        }
 7135|      0|       else {
 7136|      0|        if (residue>0) bump=1;
  ------------------
  |  Branch (7136:13): [True: 0, False: 0]
  ------------------
 7137|      0|        }
 7138|      0|      break;} // r-f
 7139|       |
 7140|      0|    default: {      // e.g., DEC_ROUND_MAX
  ------------------
  |  Branch (7140:5): [True: 0, False: 15.6k]
  ------------------
 7141|      0|      *status|=DEC_Invalid_context;
  ------------------
  |  |  134|      0|    #define DEC_Invalid_context      0x00000040
  ------------------
 7142|       |      #if DECTRACE || (DECCHECK && DECVERB)
 7143|       |      printf("Unknown rounding mode: %d\n", set->round);
 7144|       |      #endif
 7145|      0|      break;}
 7146|  15.6k|    } // switch
 7147|       |
 7148|       |  // now bump the number, up or down, if need be
 7149|  15.6k|  if (bump==0) return;                       // no action required
  ------------------
  |  Branch (7149:7): [True: 12.0k, False: 3.59k]
  ------------------
 7150|       |
 7151|       |  // Simply use decUnitAddSub unless bumping up and the number is
 7152|       |  // all nines.  In this special case set to 100... explicitly
 7153|       |  // and adjust the exponent by one (as otherwise could overflow
 7154|       |  // the array)
 7155|       |  // Similarly handle all-nines result if bumping down.
 7156|  3.59k|  if (bump>0) {
  ------------------
  |  Branch (7156:7): [True: 3.59k, False: 0]
  ------------------
 7157|  3.59k|    Unit *up;                                // work
  ------------------
  |  |   94|  3.59k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  3.59k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 7158|  3.59k|    uInt count=dn->digits;                   // digits to be checked
  ------------------
  |  |   93|  3.59k|  #define uInt   uint32_t
  ------------------
 7159|  5.62M|    for (up=dn->lsu; ; up++) {
 7160|  5.62M|      if (count<=DECDPUN) {
  ------------------
  |  |   43|  5.62M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (7160:11): [True: 2.53k, False: 5.62M]
  ------------------
 7161|       |        // this is the last Unit (the msu)
 7162|  2.53k|        if (*up!=powers[count]-1) break;     // not still 9s
  ------------------
  |  |  177|  2.53k|#define powers      DECPOWERS      // old internal name
  ------------------
  |  Branch (7162:13): [True: 1.41k, False: 1.12k]
  ------------------
 7163|       |        // here if it, too, is all nines
 7164|  1.12k|        *up=(Unit)powers[count-1];           // here 999 -> 100 etc.
  ------------------
  |  |  177|  1.12k|#define powers      DECPOWERS      // old internal name
  ------------------
 7165|  4.57M|        for (up=up-1; up>=dn->lsu; up--) *up=0; // others all to 0
  ------------------
  |  Branch (7165:23): [True: 4.57M, False: 1.12k]
  ------------------
 7166|  1.12k|        dn->exponent++;                      // and bump exponent
 7167|       |        // [which, very rarely, could cause Overflow...]
 7168|  1.12k|        if ((dn->exponent+dn->digits)>set->emax+1) {
  ------------------
  |  Branch (7168:13): [True: 0, False: 1.12k]
  ------------------
 7169|      0|          decSetOverflow(dn, set, status);
 7170|      0|          }
 7171|  1.12k|        return;                              // done
 7172|  2.53k|        }
 7173|       |      // a full unit to check, with more to come
 7174|  5.62M|      if (*up!=DECDPUNMAX) break;            // not still 9s
  ------------------
  |  |  209|  5.62M|    #define DECDPUNMAX 999
  ------------------
  |  Branch (7174:11): [True: 1.06k, False: 5.62M]
  ------------------
 7175|  5.62M|      count-=DECDPUN;
  ------------------
  |  |   43|  5.62M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 7176|  5.62M|      } // up
 7177|  3.59k|    } // bump>0
 7178|      0|   else {                                    // -1
 7179|       |    // here checking for a pre-bump of 1000... (leading 1, all
 7180|       |    // other digits zero)
 7181|      0|    Unit *up, *sup;                          // work
  ------------------
  |  |   94|      0|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|      0|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 7182|      0|    uInt count=dn->digits;                   // digits to be checked
  ------------------
  |  |   93|      0|  #define uInt   uint32_t
  ------------------
 7183|      0|    for (up=dn->lsu; ; up++) {
 7184|      0|      if (count<=DECDPUN) {
  ------------------
  |  |   43|      0|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (7184:11): [True: 0, False: 0]
  ------------------
 7185|       |        // this is the last Unit (the msu)
 7186|      0|        if (*up!=powers[count-1]) break;     // not 100..
  ------------------
  |  |  177|      0|#define powers      DECPOWERS      // old internal name
  ------------------
  |  Branch (7186:13): [True: 0, False: 0]
  ------------------
 7187|       |        // here if have the 1000... case
 7188|      0|        sup=up;                              // save msu pointer
 7189|      0|        *up=(Unit)powers[count]-1;           // here 100 in msu -> 999
  ------------------
  |  |  177|      0|#define powers      DECPOWERS      // old internal name
  ------------------
 7190|       |        // others all to all-nines, too
 7191|      0|        for (up=up-1; up>=dn->lsu; up--) *up=(Unit)powers[DECDPUN]-1;
  ------------------
  |  |  177|      0|#define powers      DECPOWERS      // old internal name
  ------------------
                      for (up=up-1; up>=dn->lsu; up--) *up=(Unit)powers[DECDPUN]-1;
  ------------------
  |  |   43|      0|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (7191:23): [True: 0, False: 0]
  ------------------
 7192|      0|        dn->exponent--;                      // and bump exponent
 7193|       |
 7194|       |        // iff the number was at the subnormal boundary (exponent=etiny)
 7195|       |        // then the exponent is now out of range, so it will in fact get
 7196|       |        // clamped to etiny and the final 9 dropped.
 7197|       |        // printf(">> emin=%d exp=%d sdig=%d\n", set->emin,
 7198|       |        //        dn->exponent, set->digits);
 7199|      0|        if (dn->exponent+1==set->emin-set->digits+1) {
  ------------------
  |  Branch (7199:13): [True: 0, False: 0]
  ------------------
 7200|      0|          if (count==1 && dn->digits==1) *sup=0;  // here 9 -> 0[.9]
  ------------------
  |  Branch (7200:15): [True: 0, False: 0]
  |  Branch (7200:27): [True: 0, False: 0]
  ------------------
 7201|      0|           else {
 7202|      0|            *sup=(Unit)powers[count-1]-1;    // here 999.. in msu -> 99..
  ------------------
  |  |  177|      0|#define powers      DECPOWERS      // old internal name
  ------------------
 7203|      0|            dn->digits--;
 7204|      0|            }
 7205|      0|          dn->exponent++;
 7206|      0|          *status|=DEC_Underflow | DEC_Subnormal | DEC_Inexact | DEC_Rounded;
  ------------------
  |  |  143|      0|    #define DEC_Underflow            0x00002000
  ------------------
                        *status|=DEC_Underflow | DEC_Subnormal | DEC_Inexact | DEC_Rounded;
  ------------------
  |  |  142|      0|    #define DEC_Subnormal            0x00001000
  ------------------
                        *status|=DEC_Underflow | DEC_Subnormal | DEC_Inexact | DEC_Rounded;
  ------------------
  |  |  133|      0|    #define DEC_Inexact              0x00000020
  ------------------
                        *status|=DEC_Underflow | DEC_Subnormal | DEC_Inexact | DEC_Rounded;
  ------------------
  |  |  141|      0|    #define DEC_Rounded              0x00000800
  ------------------
 7207|      0|          }
 7208|      0|        return;                              // done
 7209|      0|        }
 7210|       |
 7211|       |      // a full unit to check, with more to come
 7212|      0|      if (*up!=0) break;                     // not still 0s
  ------------------
  |  Branch (7212:11): [True: 0, False: 0]
  ------------------
 7213|      0|      count-=DECDPUN;
  ------------------
  |  |   43|      0|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 7214|      0|      } // up
 7215|       |
 7216|      0|    } // bump<0
 7217|       |
 7218|       |  // Actual bump needed.  Do it.
 7219|  2.47k|  decUnitAddSub(dn->lsu, D2U(dn->digits), uarrone, 1, 0, dn->lsu, bump);
  ------------------
  |  |  264|  2.47k|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|  2.47k|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    260|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    260|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 2.21k, False: 260]
  |  |  ------------------
  ------------------
 7220|  2.47k|  } // decApplyRound
decNumber.c:decSetOverflow:
 7348|  16.6k|static void decSetOverflow(decNumber *dn, decContext *set, uInt *status) {
 7349|  16.6k|  Flag needmax=0;                  // result is maximum finite value
  ------------------
  |  |   87|  16.6k|  #define Flag   uint8_t
  ------------------
 7350|  16.6k|  uByte sign=dn->bits&DECNEG;      // clean and save sign bit
  ------------------
  |  |   89|  16.6k|  #define uByte  uint8_t
  ------------------
                uByte sign=dn->bits&DECNEG;      // clean and save sign bit
  ------------------
  |  |   31|  16.6k|  #define DECNEG    0x80      /* Sign; 1=negative, 0=positive or zero */
  ------------------
 7351|       |
 7352|  16.6k|  if (ISZERO(dn)) {                // zero does not overflow magnitude
  ------------------
  |  |  255|  16.6k|  #define ISZERO(dn) decNumberIsZero(dn)     /* now just a local name */
  |  |  ------------------
  |  |  |  |  177|  16.6k|  #define decNumberIsZero(dn)      (*(dn)->lsu==0 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (177:37): [True: 930, False: 15.7k]
  |  |  |  |  ------------------
  |  |  |  |  178|  16.6k|                                    && (dn)->digits==1 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:40): [True: 594, False: 336]
  |  |  |  |  ------------------
  |  |  |  |  179|  16.6k|                                    && (((dn)->bits&DECSPECIAL)==0))
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|    594|  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|    594|  #define DECINF    0x40      /* 1=Infinity                           */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   33|    594|  #define DECNAN    0x20      /* 1=NaN                                */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   34|    594|  #define DECSNAN   0x10      /* 1=sNaN                               */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (179:40): [True: 594, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7353|    594|    Int emax=set->emax;                      // limit value
  ------------------
  |  |   92|    594|  #define Int    int32_t
  ------------------
 7354|    594|    if (set->clamp) emax-=set->digits-1;     // lower if clamping
  ------------------
  |  Branch (7354:9): [True: 0, False: 594]
  ------------------
 7355|    594|    if (dn->exponent>emax) {                 // clamp required
  ------------------
  |  Branch (7355:9): [True: 594, False: 0]
  ------------------
 7356|    594|      dn->exponent=emax;
 7357|    594|      *status|=DEC_Clamped;
  ------------------
  |  |  140|    594|    #define DEC_Clamped              0x00000400
  ------------------
 7358|    594|      }
 7359|    594|    return;
 7360|    594|    }
 7361|       |
 7362|  16.0k|  decNumberZero(dn);
 7363|  16.0k|  switch (set->round) {
 7364|      0|    case DEC_ROUND_DOWN: {
  ------------------
  |  Branch (7364:5): [True: 0, False: 16.0k]
  ------------------
 7365|      0|      needmax=1;                   // never Infinity
 7366|      0|      break;} // r-d
 7367|      0|    case DEC_ROUND_05UP: {
  ------------------
  |  Branch (7367:5): [True: 0, False: 16.0k]
  ------------------
 7368|      0|      needmax=1;                   // never Infinity
 7369|      0|      break;} // r-05
 7370|      0|    case DEC_ROUND_CEILING: {
  ------------------
  |  Branch (7370:5): [True: 0, False: 16.0k]
  ------------------
 7371|      0|      if (sign) needmax=1;         // Infinity if non-negative
  ------------------
  |  Branch (7371:11): [True: 0, False: 0]
  ------------------
 7372|      0|      break;} // r-c
 7373|      0|    case DEC_ROUND_FLOOR: {
  ------------------
  |  Branch (7373:5): [True: 0, False: 16.0k]
  ------------------
 7374|      0|      if (!sign) needmax=1;        // Infinity if negative
  ------------------
  |  Branch (7374:11): [True: 0, False: 0]
  ------------------
 7375|      0|      break;} // r-f
 7376|  16.0k|    default: break;                // Infinity in all other cases
  ------------------
  |  Branch (7376:5): [True: 16.0k, False: 0]
  ------------------
 7377|  16.0k|    }
 7378|  16.0k|  if (needmax) {
  ------------------
  |  Branch (7378:7): [True: 0, False: 16.0k]
  ------------------
 7379|      0|    decSetMaxValue(dn, set);
 7380|      0|    dn->bits=sign;                 // set sign
 7381|      0|    }
 7382|  16.0k|   else dn->bits=sign|DECINF;      // Value is +/-Infinity
  ------------------
  |  |   32|  16.0k|  #define DECINF    0x40      /* 1=Infinity                           */
  ------------------
 7383|  16.0k|  *status|=DEC_Overflow | DEC_Inexact | DEC_Rounded;
  ------------------
  |  |  139|  16.0k|    #define DEC_Overflow             0x00000200
  ------------------
                *status|=DEC_Overflow | DEC_Inexact | DEC_Rounded;
  ------------------
  |  |  133|  16.0k|    #define DEC_Inexact              0x00000020
  ------------------
                *status|=DEC_Overflow | DEC_Inexact | DEC_Rounded;
  ------------------
  |  |  141|  16.0k|    #define DEC_Rounded              0x00000800
  ------------------
 7384|  16.0k|  } // decSetOverflow
decNumber.c:decShiftToMost:
 6685|  1.12k|static Int decShiftToMost(Unit *uar, Int digits, Int shift) {
 6686|  1.12k|  Unit  *target, *source, *first;  // work
  ------------------
  |  |   94|  1.12k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  1.12k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6687|  1.12k|  Int   cut;                       // odd 0's to add
  ------------------
  |  |   92|  1.12k|  #define Int    int32_t
  ------------------
 6688|  1.12k|  uInt  next;                      // work
  ------------------
  |  |   93|  1.12k|  #define uInt   uint32_t
  ------------------
 6689|       |
 6690|  1.12k|  if (shift==0) return digits;     // [fastpath] nothing to do
  ------------------
  |  Branch (6690:7): [True: 0, False: 1.12k]
  ------------------
 6691|  1.12k|  if ((digits+shift)<=DECDPUN) {   // [fastpath] single-unit case
  ------------------
  |  |   43|  1.12k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6691:7): [True: 228, False: 895]
  ------------------
 6692|    228|    *uar=(Unit)(*uar*powers[shift]);
  ------------------
  |  |  177|    228|#define powers      DECPOWERS      // old internal name
  ------------------
 6693|    228|    return digits+shift;
 6694|    228|    }
 6695|       |
 6696|    895|  next=0;                          // all paths
 6697|    895|  source=uar+D2U(digits)-1;        // where msu comes from
  ------------------
  |  |  264|    895|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|    895|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    307|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    307|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 588, False: 307]
  |  |  ------------------
  ------------------
 6698|    895|  target=source+D2U(shift);        // where upper part of first cut goes
  ------------------
  |  |  264|    895|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|    895|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|      0|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|      0|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 895, False: 0]
  |  |  ------------------
  ------------------
 6699|    895|  cut=DECDPUN-MSUDIGITS(shift);    // where to slice
  ------------------
  |  |   43|    895|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
                cut=DECDPUN-MSUDIGITS(shift);    // where to slice
  ------------------
  |  |  271|    895|  #define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN)
  |  |  ------------------
  |  |  |  |  264|    895|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  |  |  ------------------
  |  |  |  |  |  |  249|    895|  #define DECMAXD2U 49
  |  |  |  |  ------------------
  |  |  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  |  |  ------------------
  |  |  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  |  |  ------------------
  |  |  |  |  |  |   43|      0|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (264:21): [True: 895, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 #define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    895|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  ------------------
 6700|    895|  if (cut==0) {                    // unit-boundary case
  ------------------
  |  Branch (6700:7): [True: 0, False: 895]
  ------------------
 6701|      0|    for (; source>=uar; source--, target--) *target=*source;
  ------------------
  |  Branch (6701:12): [True: 0, False: 0]
  ------------------
 6702|      0|    }
 6703|    895|   else {
 6704|    895|    first=uar+D2U(digits+shift)-1; // where msu of source will end up
  ------------------
  |  |  264|    895|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|    895|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    461|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    461|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 434, False: 461]
  |  |  ------------------
  ------------------
 6705|  4.57M|    for (; source>=uar; source--, target--) {
  ------------------
  |  Branch (6705:12): [True: 4.57M, False: 895]
  ------------------
 6706|       |      // split the source Unit and accumulate remainder for next
 6707|  4.57M|      #if DECDPUN<=4
 6708|  4.57M|        uInt quot=QUOT10(*source, cut);
  ------------------
  |  |   93|  4.57M|  #define uInt   uint32_t
  ------------------
                      uInt quot=QUOT10(*source, cut);
  ------------------
  |  |  210|  4.57M|  #define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17)
  ------------------
 6709|  4.57M|        uInt rem=*source-quot*powers[cut];
  ------------------
  |  |   93|  4.57M|  #define uInt   uint32_t
  ------------------
                      uInt rem=*source-quot*powers[cut];
  ------------------
  |  |  177|  4.57M|#define powers      DECPOWERS      // old internal name
  ------------------
 6710|  4.57M|        next+=quot;
 6711|       |      #else
 6712|       |        uInt rem=*source%powers[cut];
 6713|       |        next+=*source/powers[cut];
 6714|       |      #endif
 6715|  4.57M|      if (target<=first) *target=(Unit)next;   // write to target iff valid
  ------------------
  |  Branch (6715:11): [True: 4.57M, False: 669]
  ------------------
 6716|  4.57M|      next=rem*powers[DECDPUN-cut];            // save remainder for next Unit
  ------------------
  |  |  177|  4.57M|#define powers      DECPOWERS      // old internal name
  ------------------
                    next=rem*powers[DECDPUN-cut];            // save remainder for next Unit
  ------------------
  |  |   43|  4.57M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 6717|  4.57M|      }
 6718|    895|    } // shift-move
 6719|       |
 6720|       |  // propagate any partial unit to one below and clear the rest
 6721|  1.79k|  for (; target>=uar; target--) {
  ------------------
  |  Branch (6721:10): [True: 895, False: 895]
  ------------------
 6722|    895|    *target=(Unit)next;
 6723|    895|    next=0;
 6724|    895|    }
 6725|    895|  return digits+shift;
 6726|  1.12k|  } // decShiftToMost
decNumber.c:decSetCoeff:
 6890|  18.6k|                        Int len, Int *residue, uInt *status) {
 6891|  18.6k|  Int   discard;              // number of digits to discard
  ------------------
  |  |   92|  18.6k|  #define Int    int32_t
  ------------------
 6892|  18.6k|  uInt  cut;                  // cut point in Unit
  ------------------
  |  |   93|  18.6k|  #define uInt   uint32_t
  ------------------
 6893|  18.6k|  const Unit *up;             // work
 6894|  18.6k|  Unit  *target;              // ..
  ------------------
  |  |   94|  18.6k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  18.6k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6895|  18.6k|  Int   count;                // ..
  ------------------
  |  |   92|  18.6k|  #define Int    int32_t
  ------------------
 6896|  18.6k|  #if DECDPUN<=4
 6897|  18.6k|  uInt  temp;                 // ..
  ------------------
  |  |   93|  18.6k|  #define uInt   uint32_t
  ------------------
 6898|  18.6k|  #endif
 6899|       |
 6900|  18.6k|  discard=len-set->digits;    // digits to discard
 6901|  18.6k|  if (discard<=0) {           // no digits are being discarded
  ------------------
  |  Branch (6901:7): [True: 0, False: 18.6k]
  ------------------
 6902|      0|    if (dn->lsu!=lsu) {       // copy needed
  ------------------
  |  Branch (6902:9): [True: 0, False: 0]
  ------------------
 6903|       |      // copy the coefficient array to the result number; no shift needed
 6904|      0|      count=len;              // avoids D2U
 6905|      0|      up=lsu;
 6906|      0|      for (target=dn->lsu; count>0; target++, up++, count-=DECDPUN)
  ------------------
  |  |   43|      0|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6906:28): [True: 0, False: 0]
  ------------------
 6907|      0|        *target=*up;
 6908|      0|      dn->digits=len;         // set the new length
 6909|      0|      }
 6910|       |    // dn->exponent and residue are unchanged, record any inexactitude
 6911|      0|    if (*residue!=0) *status|=(DEC_Inexact | DEC_Rounded);
  ------------------
  |  |  133|      0|    #define DEC_Inexact              0x00000020
  ------------------
                  if (*residue!=0) *status|=(DEC_Inexact | DEC_Rounded);
  ------------------
  |  |  141|      0|    #define DEC_Rounded              0x00000800
  ------------------
  |  Branch (6911:9): [True: 0, False: 0]
  ------------------
 6912|      0|    return;
 6913|      0|    }
 6914|       |
 6915|       |  // some digits must be discarded ...
 6916|  18.6k|  dn->exponent+=discard;      // maintain numerical value
 6917|  18.6k|  *status|=DEC_Rounded;       // accumulate Rounded status
  ------------------
  |  |  141|  18.6k|    #define DEC_Rounded              0x00000800
  ------------------
 6918|  18.6k|  if (*residue>1) *residue=1; // previous residue now to right, so reduce
  ------------------
  |  Branch (6918:7): [True: 0, False: 18.6k]
  ------------------
 6919|       |
 6920|  18.6k|  if (discard>len) {          // everything, +1, is being discarded
  ------------------
  |  Branch (6920:7): [True: 11.7k, False: 6.83k]
  ------------------
 6921|       |    // guard digit is 0
 6922|       |    // residue is all the number [NB could be all 0s]
 6923|  11.7k|    if (*residue<=0) {        // not already positive
  ------------------
  |  Branch (6923:9): [True: 11.7k, False: 0]
  ------------------
 6924|  11.7k|      count=len;              // avoids D2U
 6925|   266k|      for (up=lsu; count>0; up++, count-=DECDPUN) if (*up!=0) { // found non-0
  ------------------
  |  |   43|   254k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6925:20): [True: 266k, False: 0]
  |  Branch (6925:55): [True: 11.7k, False: 254k]
  ------------------
 6926|  11.7k|        *residue=1;
 6927|  11.7k|        break;                // no need to check any others
 6928|  11.7k|        }
 6929|  11.7k|      }
 6930|  11.7k|    if (*residue!=0) *status|=DEC_Inexact; // record inexactitude
  ------------------
  |  |  133|  11.7k|    #define DEC_Inexact              0x00000020
  ------------------
  |  Branch (6930:9): [True: 11.7k, False: 0]
  ------------------
 6931|  11.7k|    *dn->lsu=0;               // coefficient will now be 0
 6932|  11.7k|    dn->digits=1;             // ..
 6933|  11.7k|    return;
 6934|  11.7k|    } // total discard
 6935|       |
 6936|       |  // partial discard [most common case]
 6937|       |  // here, at least the first (most significant) discarded digit exists
 6938|       |
 6939|       |  // spin up the number, noting residue during the spin, until get to
 6940|       |  // the Unit with the first discarded digit.  When reach it, extract
 6941|       |  // it and remember its position
 6942|  6.83k|  count=0;
 6943|   497k|  for (up=lsu;; up++) {
 6944|   497k|    count+=DECDPUN;
  ------------------
  |  |   43|   497k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 6945|   497k|    if (count>=discard) break; // full ones all checked
  ------------------
  |  Branch (6945:9): [True: 6.83k, False: 491k]
  ------------------
 6946|   491k|    if (*up!=0) *residue=1;
  ------------------
  |  Branch (6946:9): [True: 66.4k, False: 424k]
  ------------------
 6947|   491k|    } // up
 6948|       |
 6949|       |  // here up -> Unit with first discarded digit
 6950|  6.83k|  cut=discard-(count-DECDPUN)-1;
  ------------------
  |  |   43|  6.83k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 6951|  6.83k|  if (cut==DECDPUN-1) {       // unit-boundary case (fast)
  ------------------
  |  |   43|  6.83k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6951:7): [True: 879, False: 5.95k]
  ------------------
 6952|    879|    Unit half=(Unit)powers[DECDPUN]>>1;
  ------------------
  |  |   94|    879|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|    879|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
                  Unit half=(Unit)powers[DECDPUN]>>1;
  ------------------
  |  |  177|    879|#define powers      DECPOWERS      // old internal name
  ------------------
                  Unit half=(Unit)powers[DECDPUN]>>1;
  ------------------
  |  |   43|    879|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 6953|       |    // set residue directly
 6954|    879|    if (*up>=half) {
  ------------------
  |  Branch (6954:9): [True: 465, False: 414]
  ------------------
 6955|    465|      if (*up>half) *residue=7;
  ------------------
  |  Branch (6955:11): [True: 249, False: 216]
  ------------------
 6956|    216|      else *residue+=5;       // add sticky bit
 6957|    465|      }
 6958|    414|     else { // <half
 6959|    414|      if (*up!=0) *residue=3; // [else is 0, leave as sticky bit]
  ------------------
  |  Branch (6959:11): [True: 215, False: 199]
  ------------------
 6960|    414|      }
 6961|    879|    if (set->digits<=0) {     // special for Quantize/Subnormal :-(
  ------------------
  |  Branch (6961:9): [True: 637, False: 242]
  ------------------
 6962|    637|      *dn->lsu=0;             // .. result is 0
 6963|    637|      dn->digits=1;           // ..
 6964|    637|      }
 6965|    242|     else {                   // shift to least
 6966|    242|      count=set->digits;      // now digits to end up with
 6967|    242|      dn->digits=count;       // set the new length
 6968|    242|      up++;                   // move to next
 6969|       |      // on unit boundary, so shift-down copy loop is simple
 6970|   213k|      for (target=dn->lsu; count>0; target++, up++, count-=DECDPUN)
  ------------------
  |  |   43|   213k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6970:28): [True: 213k, False: 242]
  ------------------
 6971|   213k|        *target=*up;
 6972|    242|      }
 6973|    879|    } // unit-boundary case
 6974|       |
 6975|  5.95k|   else { // discard digit is in low digit(s), and not top digit
 6976|  5.95k|    uInt  discard1;                // first discarded digit
  ------------------
  |  |   93|  5.95k|  #define uInt   uint32_t
  ------------------
 6977|  5.95k|    uInt  quot, rem;               // for divisions
  ------------------
  |  |   93|  5.95k|  #define uInt   uint32_t
  ------------------
 6978|  5.95k|    if (cut==0) quot=*up;          // is at bottom of unit
  ------------------
  |  Branch (6978:9): [True: 5.50k, False: 446]
  ------------------
 6979|    446|     else /* cut>0 */ {            // it's not at bottom of unit
 6980|    446|      #if DECDPUN<=4
 6981|    446|        quot=QUOT10(*up, cut);
  ------------------
  |  |  210|    446|  #define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17)
  ------------------
 6982|    446|        rem=*up-quot*powers[cut];
  ------------------
  |  |  177|    446|#define powers      DECPOWERS      // old internal name
  ------------------
 6983|       |      #else
 6984|       |        rem=*up%powers[cut];
 6985|       |        quot=*up/powers[cut];
 6986|       |      #endif
 6987|    446|      if (rem!=0) *residue=1;
  ------------------
  |  Branch (6987:11): [True: 233, False: 213]
  ------------------
 6988|    446|      }
 6989|       |    // discard digit is now at bottom of quot
 6990|  5.95k|    #if DECDPUN<=4
 6991|  5.95k|      temp=(quot*6554)>>16;        // fast /10
 6992|       |      // Vowels algorithm here not a win (9 instructions)
 6993|  5.95k|      discard1=quot-X10(temp);
  ------------------
  |  |  163|  5.95k|  #define X10(i)  (((i)<<1)+((i)<<3))
  ------------------
 6994|  5.95k|      quot=temp;
 6995|       |    #else
 6996|       |      discard1=quot%10;
 6997|       |      quot=quot/10;
 6998|       |    #endif
 6999|       |    // here, discard1 is the guard digit, and residue is everything
 7000|       |    // else [use mapping array to accumulate residue safely]
 7001|  5.95k|    *residue+=resmap[discard1];
 7002|  5.95k|    cut++;                         // update cut
 7003|       |    // here: up -> Unit of the array with bottom digit
 7004|       |    //       cut is the division point for each Unit
 7005|       |    //       quot holds the uncut high-order digits for the current unit
 7006|  5.95k|    if (set->digits<=0) {          // special for Quantize/Subnormal :-(
  ------------------
  |  Branch (7006:9): [True: 747, False: 5.20k]
  ------------------
 7007|    747|      *dn->lsu=0;                  // .. result is 0
 7008|    747|      dn->digits=1;                // ..
 7009|    747|      }
 7010|  5.20k|     else {                        // shift to least needed
 7011|  5.20k|      count=set->digits;           // now digits to end up with
 7012|  5.20k|      dn->digits=count;            // set the new length
 7013|       |      // shift-copy the coefficient array to the result number
 7014|  7.43M|      for (target=dn->lsu; ; target++) {
 7015|  7.43M|        *target=(Unit)quot;
 7016|  7.43M|        count-=(DECDPUN-cut);
  ------------------
  |  |   43|  7.43M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 7017|  7.43M|        if (count<=0) break;
  ------------------
  |  Branch (7017:13): [True: 4.31k, False: 7.42M]
  ------------------
 7018|  7.42M|        up++;
 7019|  7.42M|        quot=*up;
 7020|  7.42M|        #if DECDPUN<=4
 7021|  7.42M|          quot=QUOT10(quot, cut);
  ------------------
  |  |  210|  7.42M|  #define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17)
  ------------------
 7022|  7.42M|          rem=*up-quot*powers[cut];
  ------------------
  |  |  177|  7.42M|#define powers      DECPOWERS      // old internal name
  ------------------
 7023|       |        #else
 7024|       |          rem=quot%powers[cut];
 7025|       |          quot=quot/powers[cut];
 7026|       |        #endif
 7027|  7.42M|        *target=(Unit)(*target+rem*powers[DECDPUN-cut]);
  ------------------
  |  |  177|  7.42M|#define powers      DECPOWERS      // old internal name
  ------------------
                      *target=(Unit)(*target+rem*powers[DECDPUN-cut]);
  ------------------
  |  |   43|  7.42M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 7028|  7.42M|        count-=cut;
 7029|  7.42M|        if (count<=0) break;
  ------------------
  |  Branch (7029:13): [True: 896, False: 7.42M]
  ------------------
 7030|  7.42M|        } // shift-copy loop
 7031|  5.20k|      } // shift to least
 7032|  5.95k|    } // not unit boundary
 7033|       |
 7034|  6.83k|  if (*residue!=0) *status|=DEC_Inexact; // record inexactitude
  ------------------
  |  |  133|  3.87k|    #define DEC_Inexact              0x00000020
  ------------------
  |  Branch (7034:7): [True: 3.87k, False: 2.95k]
  ------------------
 7035|  6.83k|  return;
 7036|  18.6k|  } // decSetCoeff
decNumber.c:decFinalize:
 7275|  36.9k|                        uInt *status) {
 7276|  36.9k|  Int shift;                            // shift needed if clamping
  ------------------
  |  |   92|  36.9k|  #define Int    int32_t
  ------------------
 7277|  36.9k|  Int tinyexp=set->emin-dn->digits+1;   // precalculate subnormal boundary
  ------------------
  |  |   92|  36.9k|  #define Int    int32_t
  ------------------
 7278|       |
 7279|       |  // Must be careful, here, when checking the exponent as the
 7280|       |  // adjusted exponent could overflow 31 bits [because it may already
 7281|       |  // be up to twice the expected].
 7282|       |
 7283|       |  // First test for subnormal.  This must be done before any final
 7284|       |  // round as the result could be rounded to Nmin or 0.
 7285|  36.9k|  if (dn->exponent<=tinyexp) {          // prefilter
  ------------------
  |  Branch (7285:7): [True: 19.9k, False: 17.0k]
  ------------------
 7286|  19.9k|    Int comp;
  ------------------
  |  |   92|  19.9k|  #define Int    int32_t
  ------------------
 7287|  19.9k|    decNumber nmin;
 7288|       |    // A very nasty case here is dn == Nmin and residue<0
 7289|  19.9k|    if (dn->exponent<tinyexp) {
  ------------------
  |  Branch (7289:9): [True: 19.9k, False: 0]
  ------------------
 7290|       |      // Go handle subnormals; this will apply round if needed.
 7291|  19.9k|      decSetSubnormal(dn, set, residue, status);
 7292|  19.9k|      return;
 7293|  19.9k|      }
 7294|       |    // Equals case: only subnormal if dn=Nmin and negative residue
 7295|      0|    decNumberZero(&nmin);
 7296|      0|    nmin.lsu[0]=1;
 7297|      0|    nmin.exponent=set->emin;
 7298|      0|    comp=decCompare(dn, &nmin, 1);                // (signless compare)
 7299|      0|    if (comp==BADINT) {                           // oops
  ------------------
  |  |  194|      0|#define BADINT  (Int)0x80000000    // most-negative Int; error indicator
  ------------------
  |  Branch (7299:9): [True: 0, False: 0]
  ------------------
 7300|      0|      *status|=DEC_Insufficient_storage;          // abandon...
  ------------------
  |  |  132|      0|    #define DEC_Insufficient_storage 0x00000010 /* [when malloc fails]  */
  ------------------
 7301|      0|      return;
 7302|      0|      }
 7303|      0|    if (*residue<0 && comp==0) {                  // neg residue and dn==Nmin
  ------------------
  |  Branch (7303:9): [True: 0, False: 0]
  |  Branch (7303:23): [True: 0, False: 0]
  ------------------
 7304|      0|      decApplyRound(dn, set, *residue, status);   // might force down
 7305|      0|      decSetSubnormal(dn, set, residue, status);
 7306|      0|      return;
 7307|      0|      }
 7308|      0|    }
 7309|       |
 7310|       |  // now apply any pending round (this could raise overflow).
 7311|  17.0k|  if (*residue!=0) decApplyRound(dn, set, *residue, status);
  ------------------
  |  Branch (7311:7): [True: 0, False: 17.0k]
  ------------------
 7312|       |
 7313|       |  // Check for overflow [redundant in the 'rare' case] or clamp
 7314|  17.0k|  if (dn->exponent<=set->emax-set->digits+1) return;   // neither needed
  ------------------
  |  Branch (7314:7): [True: 0, False: 17.0k]
  ------------------
 7315|       |
 7316|       |
 7317|       |  // here when might have an overflow or clamp to do
 7318|  17.0k|  if (dn->exponent>set->emax-dn->digits+1) {           // too big
  ------------------
  |  Branch (7318:7): [True: 16.6k, False: 331]
  ------------------
 7319|  16.6k|    decSetOverflow(dn, set, status);
 7320|  16.6k|    return;
 7321|  16.6k|    }
 7322|       |  // here when the result is normal but in clamp range
 7323|    331|  if (!set->clamp) return;
  ------------------
  |  Branch (7323:7): [True: 331, False: 0]
  ------------------
 7324|       |
 7325|       |  // here when need to apply the IEEE exponent clamp (fold-down)
 7326|      0|  shift=dn->exponent-(set->emax-set->digits+1);
 7327|       |
 7328|       |  // shift coefficient (if non-zero)
 7329|      0|  if (!ISZERO(dn)) {
  ------------------
  |  |  255|      0|  #define ISZERO(dn) decNumberIsZero(dn)     /* now just a local name */
  |  |  ------------------
  |  |  |  |  177|      0|  #define decNumberIsZero(dn)      (*(dn)->lsu==0 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (177:37): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  178|      0|                                    && (dn)->digits==1 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:40): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      0|                                    && (((dn)->bits&DECSPECIAL)==0))
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|      0|  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|      0|  #define DECINF    0x40      /* 1=Infinity                           */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   33|      0|  #define DECNAN    0x20      /* 1=NaN                                */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   34|      0|  #define DECSNAN   0x10      /* 1=sNaN                               */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (179:40): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7330|      0|    dn->digits=decShiftToMost(dn->lsu, dn->digits, shift);
 7331|      0|    }
 7332|      0|  dn->exponent-=shift;   // adjust the exponent to match
 7333|      0|  *status|=DEC_Clamped;  // and record the dirty deed
  ------------------
  |  |  140|      0|    #define DEC_Clamped              0x00000400
  ------------------
 7334|      0|  return;
 7335|    331|  } // decFinalize
decNumber.c:decSetSubnormal:
 7429|  19.9k|                            uInt *status) {
 7430|  19.9k|  decContext workset;         // work
 7431|  19.9k|  Int        etiny, adjust;   // ..
  ------------------
  |  |   92|  19.9k|  #define Int    int32_t
  ------------------
 7432|       |
 7433|       |  #if DECSUBSET
 7434|       |  // simple set to zero and 'hard underflow' for subset
 7435|       |  if (!set->extended) {
 7436|       |    decNumberZero(dn);
 7437|       |    // always full overflow
 7438|       |    *status|=DEC_Underflow | DEC_Subnormal | DEC_Inexact | DEC_Rounded;
 7439|       |    return;
 7440|       |    }
 7441|       |  #endif
 7442|       |
 7443|       |  // Full arithmetic -- allow subnormals, rounded to minimum exponent
 7444|       |  // (Etiny) if needed
 7445|  19.9k|  etiny=set->emin-(set->digits-1);      // smallest allowed exponent
 7446|       |
 7447|  19.9k|  if ISZERO(dn) {                       // value is zero
  ------------------
  |  |  255|  19.9k|  #define ISZERO(dn) decNumberIsZero(dn)     /* now just a local name */
  |  |  ------------------
  |  |  |  |  177|  19.9k|  #define decNumberIsZero(dn)      (*(dn)->lsu==0 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (177:37): [True: 1.01k, False: 18.9k]
  |  |  |  |  ------------------
  |  |  |  |  178|  19.9k|                                    && (dn)->digits==1 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:40): [True: 742, False: 271]
  |  |  |  |  ------------------
  |  |  |  |  179|  19.9k|                                    && (((dn)->bits&DECSPECIAL)==0))
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|    742|  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|    742|  #define DECINF    0x40      /* 1=Infinity                           */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   33|    742|  #define DECNAN    0x20      /* 1=NaN                                */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   34|    742|  #define DECSNAN   0x10      /* 1=sNaN                               */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (179:40): [True: 742, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7448|       |    // residue can never be non-zero here
 7449|       |    #if DECCHECK
 7450|       |      if (*residue!=0) {
 7451|       |        printf("++ Subnormal 0 residue %ld\n", (LI)*residue);
 7452|       |        *status|=DEC_Invalid_operation;
 7453|       |        }
 7454|       |    #endif
 7455|    742|    if (dn->exponent<etiny) {           // clamp required
  ------------------
  |  Branch (7455:9): [True: 498, False: 244]
  ------------------
 7456|    498|      dn->exponent=etiny;
 7457|    498|      *status|=DEC_Clamped;
  ------------------
  |  |  140|    498|    #define DEC_Clamped              0x00000400
  ------------------
 7458|    498|      }
 7459|    742|    return;
 7460|    742|    }
 7461|       |
 7462|  19.1k|  *status|=DEC_Subnormal;               // have a non-zero subnormal
  ------------------
  |  |  142|  19.1k|    #define DEC_Subnormal            0x00001000
  ------------------
 7463|  19.1k|  adjust=etiny-dn->exponent;            // calculate digits to remove
 7464|  19.1k|  if (adjust<=0) {                      // not out of range; unrounded
  ------------------
  |  Branch (7464:7): [True: 561, False: 18.6k]
  ------------------
 7465|       |    // residue can never be non-zero here, except in the Nmin-residue
 7466|       |    // case (which is a subnormal result), so can take fast-path here
 7467|       |    // it may already be inexact (from setting the coefficient)
 7468|    561|    if (*status&DEC_Inexact) *status|=DEC_Underflow;
  ------------------
  |  |  133|    561|    #define DEC_Inexact              0x00000020
  ------------------
                  if (*status&DEC_Inexact) *status|=DEC_Underflow;
  ------------------
  |  |  143|      0|    #define DEC_Underflow            0x00002000
  ------------------
  |  Branch (7468:9): [True: 0, False: 561]
  ------------------
 7469|    561|    return;
 7470|    561|    }
 7471|       |
 7472|       |  // adjust>0, so need to rescale the result so exponent becomes Etiny
 7473|       |  // [this code is similar to that in rescale]
 7474|  18.6k|  workset=*set;                         // clone rounding, etc.
 7475|  18.6k|  workset.digits=dn->digits-adjust;     // set requested length
 7476|  18.6k|  workset.emin-=adjust;                 // and adjust emin to match
 7477|       |  // [note that the latter can be <1, here, similar to Rescale case]
 7478|  18.6k|  decSetCoeff(dn, &workset, dn->lsu, dn->digits, residue, status);
 7479|  18.6k|  decApplyRound(dn, &workset, *residue, status);
 7480|       |
 7481|       |  // Use 754 default rule: Underflow is set iff Inexact
 7482|       |  // [independent of whether trapped]
 7483|  18.6k|  if (*status&DEC_Inexact) *status|=DEC_Underflow;
  ------------------
  |  |  133|  18.6k|    #define DEC_Inexact              0x00000020
  ------------------
                if (*status&DEC_Inexact) *status|=DEC_Underflow;
  ------------------
  |  |  143|  15.6k|    #define DEC_Underflow            0x00002000
  ------------------
  |  Branch (7483:7): [True: 15.6k, False: 2.95k]
  ------------------
 7484|       |
 7485|       |  // if rounded up a 999s case, exponent will be off by one; adjust
 7486|       |  // back if so [it will fit, because it was shortened earlier]
 7487|  18.6k|  if (dn->exponent>etiny) {
  ------------------
  |  Branch (7487:7): [True: 1.12k, False: 17.5k]
  ------------------
 7488|  1.12k|    dn->digits=decShiftToMost(dn->lsu, dn->digits, 1);
 7489|  1.12k|    dn->exponent--;                     // (re)adjust the exponent.
 7490|  1.12k|    }
 7491|       |
 7492|       |  // if rounded to zero, it is by definition clamped...
 7493|  18.6k|  if (ISZERO(dn)) *status|=DEC_Clamped;
  ------------------
  |  |  255|  18.6k|  #define ISZERO(dn) decNumberIsZero(dn)     /* now just a local name */
  |  |  ------------------
  |  |  |  |  177|  18.6k|  #define decNumberIsZero(dn)      (*(dn)->lsu==0 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (177:37): [True: 13.2k, False: 5.36k]
  |  |  |  |  ------------------
  |  |  |  |  178|  18.6k|                                    && (dn)->digits==1 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:40): [True: 12.0k, False: 1.23k]
  |  |  |  |  ------------------
  |  |  |  |  179|  18.6k|                                    && (((dn)->bits&DECSPECIAL)==0))
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|  12.0k|  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|  12.0k|  #define DECINF    0x40      /* 1=Infinity                           */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   33|  12.0k|  #define DECNAN    0x20      /* 1=NaN                                */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   34|  12.0k|  #define DECSNAN   0x10      /* 1=sNaN                               */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (179:40): [True: 12.0k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                if (ISZERO(dn)) *status|=DEC_Clamped;
  ------------------
  |  |  140|  12.0k|    #define DEC_Clamped              0x00000400
  ------------------
 7494|  18.6k|  } // decSetSubnormal
decNumber.c:decBiStr:
 7667|  5.43k|static Flag decBiStr(const char *targ, const char *str1, const char *str2) {
 7668|  9.83k|  for (;;targ++, str1++, str2++) {
 7669|  9.83k|    if (*targ!=*str1 && *targ!=*str2) return 0;
  ------------------
  |  Branch (7669:9): [True: 7.02k, False: 2.80k]
  |  Branch (7669:25): [True: 4.82k, False: 2.20k]
  ------------------
 7670|       |    // *targ has a match in one (or both, if terminator)
 7671|  5.00k|    if (*targ=='\0') break;
  ------------------
  |  Branch (7671:9): [True: 613, False: 4.39k]
  ------------------
 7672|  5.00k|    } // forever
 7673|    613|  return 1;
 7674|  5.43k|  } // decBiStr
decNumber.c:decStatus:
 7741|  36.9k|static void decStatus(decNumber *dn, uInt status, decContext *set) {
 7742|  36.9k|  if (status & DEC_NaNs) {              // error status -> NaN
  ------------------
  |  |  187|  36.9k|  #define DEC_NaNs    DEC_IEEE_754_Invalid_operation
  |  |  ------------------
  |  |  |  |  173|  36.9k|  #define DEC_IEEE_754_Invalid_operation (DEC_Conversion_syntax |     \
  |  |  |  |  ------------------
  |  |  |  |  |  |  128|  36.9k|    #define DEC_Conversion_syntax    0x00000001
  |  |  |  |  ------------------
  |  |  |  |  174|  36.9k|                                          DEC_Division_impossible |   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  130|  36.9k|    #define DEC_Division_impossible  0x00000004
  |  |  |  |  ------------------
  |  |  |  |  175|  36.9k|                                          DEC_Division_undefined |    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  131|  36.9k|    #define DEC_Division_undefined   0x00000008
  |  |  |  |  ------------------
  |  |  |  |  176|  36.9k|                                          DEC_Insufficient_storage |  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  132|  36.9k|    #define DEC_Insufficient_storage 0x00000010 /* [when malloc fails]  */
  |  |  |  |  ------------------
  |  |  |  |  177|  36.9k|                                          DEC_Invalid_context |       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  134|  36.9k|    #define DEC_Invalid_context      0x00000040
  |  |  |  |  ------------------
  |  |  |  |  178|  36.9k|                                          DEC_Invalid_operation)
  |  |  |  |  ------------------
  |  |  |  |  |  |  135|  36.9k|    #define DEC_Invalid_operation    0x00000080
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (7742:7): [True: 600, False: 36.3k]
  ------------------
 7743|       |    // if cause was an sNaN, clear and propagate [NaN is already set up]
 7744|    600|    if (status & DEC_sNaN) status&=~DEC_sNaN;
  ------------------
  |  |  193|    600|#define DEC_sNaN     0x40000000    // local status: sNaN signal
  ------------------
                  if (status & DEC_sNaN) status&=~DEC_sNaN;
  ------------------
  |  |  193|      0|#define DEC_sNaN     0x40000000    // local status: sNaN signal
  ------------------
  |  Branch (7744:9): [True: 0, False: 600]
  ------------------
 7745|    600|     else {
 7746|    600|      decNumberZero(dn);                // other error: clean throughout
 7747|    600|      dn->bits=DECNAN;                  // and make a quiet NaN
  ------------------
  |  |   33|    600|  #define DECNAN    0x20      /* 1=NaN                                */
  ------------------
 7748|    600|      }
 7749|    600|    }
 7750|  36.9k|  decContextSetStatus(set, status);     // [may not return]
 7751|  36.9k|  return;
 7752|  36.9k|  } // decStatus

