jv_get_kind:
  102|  66.6M|jv_kind jv_get_kind(jv x) {
  103|  66.6M|  return JVP_KIND(x);
  ------------------
  |  |   90|  66.6M|#define JVP_KIND(j)   (JVP_FLAGS(j) & KIND_MASK)
  |  |  ------------------
  |  |  |  |   89|  66.6M|#define JVP_FLAGS(j)  ((j).kind_flags)
  |  |  ------------------
  |  |               #define JVP_KIND(j)   (JVP_FLAGS(j) & KIND_MASK)
  |  |  ------------------
  |  |  |  |   77|  66.6M|#define KIND_MASK   0xF
  |  |  ------------------
  ------------------
  104|  66.6M|}
jv_true:
  126|    406|jv jv_true(void) {
  127|    406|  return JV_TRUE;
  128|    406|}
jv_false:
  130|    260|jv jv_false(void) {
  131|    260|  return JV_FALSE;
  132|    260|}
jv_null:
  134|    258|jv jv_null(void) {
  135|    258|  return JV_NULL;
  136|    258|}
jv_invalid_with_msg:
  153|  4.08k|jv jv_invalid_with_msg(jv err) {
  154|  4.08k|  jvp_invalid* i = jv_mem_alloc(sizeof(jvp_invalid));
  155|  4.08k|  i->refcnt = JV_REFCNT_INIT;
  156|  4.08k|  i->errmsg = err;
  157|       |
  158|  4.08k|  jv x = {JVP_FLAGS_INVALID_MSG, 0, 0, 0, {&i->refcnt}};
  ------------------
  |  |  146|  4.08k|#define JVP_FLAGS_INVALID_MSG   JVP_MAKE_FLAGS(JV_KIND_INVALID, JVP_PAYLOAD_ALLOCATED)
  |  |  ------------------
  |  |  |  |   87|  4.08k|#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   77|  4.08k|#define KIND_MASK   0xF
  |  |  |  |  ------------------
  |  |  |  |               #define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   78|  4.08k|#define PFLAGS_MASK 0xF0
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  159|  4.08k|  return x;
  160|  4.08k|}
jv_invalid:
  162|  5.74M|jv jv_invalid(void) {
  163|  5.74M|  return JV_INVALID;
  164|  5.74M|}
jv_invalid_get_msg:
  166|  2.04k|jv jv_invalid_get_msg(jv inv) {
  167|  2.04k|  assert(JVP_HAS_KIND(inv, JV_KIND_INVALID));
  ------------------
  |  Branch (167:3): [True: 0, False: 2.04k]
  |  Branch (167:3): [True: 2.04k, False: 0]
  ------------------
  168|       |
  169|  2.04k|  jv x;
  170|  2.04k|  if (JVP_HAS_FLAGS(inv, JVP_FLAGS_INVALID_MSG)) {
  ------------------
  |  |   92|  2.04k|#define JVP_HAS_FLAGS(j, flags) (JVP_FLAGS(j) == flags)
  |  |  ------------------
  |  |  |  |   89|  2.04k|#define JVP_FLAGS(j)  ((j).kind_flags)
  |  |  ------------------
  |  |  |  Branch (92:33): [True: 2.04k, False: 0]
  |  |  ------------------
  ------------------
  171|  2.04k|    x = jv_copy(((jvp_invalid*)inv.u.ptr)->errmsg);
  172|  2.04k|  }
  173|      0|  else {
  174|      0|    x = jv_null();
  175|      0|  }
  176|       |
  177|  2.04k|  jv_free(inv);
  178|  2.04k|  return x;
  179|  2.04k|}
jv_invalid_has_msg:
  181|  5.10k|int jv_invalid_has_msg(jv inv) {
  182|  5.10k|  assert(JVP_HAS_KIND(inv, JV_KIND_INVALID));
  ------------------
  |  Branch (182:3): [True: 0, False: 5.10k]
  |  Branch (182:3): [True: 5.10k, False: 0]
  ------------------
  183|  5.10k|  int r = JVP_HAS_FLAGS(inv, JVP_FLAGS_INVALID_MSG);
  ------------------
  |  |   92|  5.10k|#define JVP_HAS_FLAGS(j, flags) (JVP_FLAGS(j) == flags)
  |  |  ------------------
  |  |  |  |   89|  5.10k|#define JVP_FLAGS(j)  ((j).kind_flags)
  |  |  ------------------
  ------------------
  184|  5.10k|  jv_free(inv);
  185|  5.10k|  return r;
  186|  5.10k|}
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|  5.55M|jv jv_number_with_literal(const char * literal) {
  669|  5.55M|  return jvp_literal_number_new(literal);
  670|  5.55M|}
jv_number:
  673|  1.85k|jv jv_number(double x) {
  674|  1.85k|  jv j = {
  675|  1.85k|#ifdef USE_DECNUM
  676|  1.85k|    JVP_FLAGS_NUMBER_NATIVE,
  ------------------
  |  |  205|  1.85k|#define JVP_FLAGS_NUMBER_NATIVE       JVP_MAKE_FLAGS(JV_KIND_NUMBER, JVP_MAKE_PFLAGS(JVP_NUMBER_NATIVE, 0))
  |  |  ------------------
  |  |  |  |   87|  3.71k|#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   77|  1.85k|#define KIND_MASK   0xF
  |  |  |  |  ------------------
  |  |  |  |               #define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   78|  1.85k|#define PFLAGS_MASK 0xF0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:61): [Folded, False: 1.85k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  677|       |#else
  678|       |    JV_KIND_NUMBER,
  679|       |#endif
  680|  1.85k|    0, 0, 0, {.number = x}
  681|  1.85k|  };
  682|  1.85k|  return j;
  683|  1.85k|}
jv_array_sized:
  982|   270k|jv jv_array_sized(int n) {
  983|   270k|  return jvp_array_new(n);
  984|   270k|}
jv_array:
  986|   270k|jv jv_array(void) {
  987|   270k|  return jv_array_sized(16);
  988|   270k|}
jv_array_length:
  990|  5.61M|int jv_array_length(jv j) {
  991|  5.61M|  assert(JVP_HAS_KIND(j, JV_KIND_ARRAY));
  ------------------
  |  Branch (991:3): [True: 0, False: 5.61M]
  |  Branch (991:3): [True: 5.61M, False: 0]
  ------------------
  992|  5.61M|  int len = jvp_array_length(j);
  993|  5.61M|  jv_free(j);
  994|  5.61M|  return len;
  995|  5.61M|}
jv_array_set:
 1010|  5.60M|jv jv_array_set(jv j, int idx, jv val) {
 1011|  5.60M|  assert(JVP_HAS_KIND(j, JV_KIND_ARRAY));
  ------------------
  |  Branch (1011:3): [True: 0, False: 5.60M]
  |  Branch (1011:3): [True: 5.60M, False: 0]
  ------------------
 1012|       |
 1013|  5.60M|  if (idx < 0)
  ------------------
  |  Branch (1013:7): [True: 0, False: 5.60M]
  ------------------
 1014|      0|    idx = jvp_array_length(j) + idx;
 1015|  5.60M|  if (idx < 0) {
  ------------------
  |  Branch (1015:7): [True: 0, False: 5.60M]
  ------------------
 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|  5.60M|  if (idx > (INT_MAX >> 2) - jvp_array_offset(j)) {
  ------------------
  |  Branch (1020:7): [True: 0, False: 5.60M]
  ------------------
 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|  5.60M|  jv* slot = jvp_array_write(&j, idx);
 1027|  5.60M|  jv_free(*slot);
 1028|  5.60M|  *slot = val;
 1029|  5.60M|  return j;
 1030|  5.60M|}
jv_array_append:
 1032|  5.60M|jv jv_array_append(jv j, jv val) {
 1033|       |  // copy/free of val,j coalesced
 1034|  5.60M|  return jv_array_set(j, jv_array_length(jv_copy(j)), val);
 1035|  5.60M|}
jv_string_sized:
 1312|  52.2k|jv jv_string_sized(const char* str, int len) {
 1313|  52.2k|  return
 1314|  52.2k|    jvp_utf8_is_valid(str, str+len) ?
  ------------------
  |  Branch (1314:5): [True: 48.4k, False: 3.77k]
  ------------------
 1315|  48.4k|    jvp_string_new(str, len) :
 1316|  52.2k|    jvp_string_copy_replace_bad(str, len);
 1317|  52.2k|}
jv_string:
 1323|     91|jv jv_string(const char* str) {
 1324|     91|  return jv_string_sized(str, strlen(str));
 1325|     91|}
jv_string_value:
 1481|  2.04k|const char* jv_string_value(jv j) {
 1482|  2.04k|  assert(JVP_HAS_KIND(j, JV_KIND_STRING));
  ------------------
  |  Branch (1482:3): [True: 0, False: 2.04k]
  |  Branch (1482:3): [True: 2.04k, False: 0]
  ------------------
 1483|  2.04k|  return jvp_string_ptr(j)->data;
 1484|  2.04k|}
jv_string_vfmt:
 1563|  3.99k|jv jv_string_vfmt(const char* fmt, va_list ap) {
 1564|  3.99k|  int size = 1024;
 1565|  4.40k|  while (1) {
  ------------------
  |  Branch (1565:10): [True: 4.40k, Folded]
  ------------------
 1566|  4.40k|    char* buf = jv_mem_alloc(size);
 1567|  4.40k|    va_list ap2;
 1568|  4.40k|    va_copy(ap2, ap);
 1569|  4.40k|    int n = vsnprintf(buf, size, fmt, ap2);
 1570|  4.40k|    va_end(ap2);
 1571|       |    /*
 1572|       |     * NOTE: here we support old vsnprintf()s that return -1 because the
 1573|       |     * buffer is too small.
 1574|       |     */
 1575|  4.40k|    if (n >= 0 && n < size) {
  ------------------
  |  Branch (1575:9): [True: 4.40k, False: 0]
  |  Branch (1575:19): [True: 3.99k, False: 411]
  ------------------
 1576|  3.99k|      jv ret = jv_string_sized(buf, n);
 1577|  3.99k|      jv_mem_free(buf);
 1578|  3.99k|      return ret;
 1579|  3.99k|    } else {
 1580|    411|      jv_mem_free(buf);
 1581|    411|      size = (n > 0) ? /* standard */ (n * 2) : /* not standard */ (size * 2);
  ------------------
  |  Branch (1581:14): [True: 411, False: 0]
  ------------------
 1582|    411|    }
 1583|  4.40k|  }
 1584|  3.99k|}
jv_string_fmt:
 1586|  2.04k|jv jv_string_fmt(const char* fmt, ...) {
 1587|  2.04k|  va_list args;
 1588|  2.04k|  va_start(args, fmt);
 1589|  2.04k|  jv res = jv_string_vfmt(fmt, args);
 1590|       |  va_end(args);
 1591|  2.04k|  return res;
 1592|  2.04k|}
jv_object:
 1849|   176k|jv jv_object(void) {
 1850|   176k|  return jvp_object_new(8);
 1851|   176k|}
jv_object_set:
 1878|  37.4k|jv jv_object_set(jv object, jv key, jv value) {
 1879|  37.4k|  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));
  ------------------
  |  Branch (1879:3): [True: 0, False: 37.4k]
  |  Branch (1879:3): [True: 37.4k, False: 0]
  ------------------
 1880|  37.4k|  assert(JVP_HAS_KIND(key, JV_KIND_STRING));
  ------------------
  |  Branch (1880:3): [True: 0, False: 37.4k]
  |  Branch (1880:3): [True: 37.4k, False: 0]
  ------------------
 1881|       |  // copy/free of object, key, value coalesced
 1882|  37.4k|  jv* slot;
 1883|  37.4k|  if (!jvp_object_write(&object, key, &slot)) {
  ------------------
  |  Branch (1883:7): [True: 0, False: 37.4k]
  ------------------
 1884|      0|    jv_free(object);
 1885|      0|    jv_free(value);
 1886|      0|    return jv_invalid_with_msg(jv_string("Object too big"));
 1887|      0|  }
 1888|  37.4k|  jv_free(*slot);
 1889|  37.4k|  *slot = value;
 1890|  37.4k|  return object;
 1891|  37.4k|}
jv_object_length:
 1901|  63.8k|int jv_object_length(jv object) {
 1902|  63.8k|  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));
  ------------------
  |  Branch (1902:3): [True: 0, False: 63.8k]
  |  Branch (1902:3): [True: 63.8k, False: 0]
  ------------------
 1903|  63.8k|  int n = jvp_object_length(object);
 1904|  63.8k|  jv_free(object);
 1905|  63.8k|  return n;
 1906|  63.8k|}
jv_copy:
 2002|  20.2M|jv jv_copy(jv j) {
 2003|  20.2M|  if (JVP_IS_ALLOCATED(j)) {
  ------------------
  |  |   95|  20.2M|#define JVP_IS_ALLOCATED(j) (j.kind_flags & JVP_PAYLOAD_ALLOCATED)
  |  |  ------------------
  |  |  |  Branch (95:29): [True: 20.2M, False: 5.22k]
  |  |  ------------------
  ------------------
 2004|  20.2M|    jvp_refcnt_inc(j.u.ptr);
 2005|  20.2M|  }
 2006|  20.2M|  return j;
 2007|  20.2M|}
jv_free:
 2014|  17.4M|void jv_free(jv j) {
 2015|  17.4M|  jv* pending = NULL;
 2016|  17.4M|  size_t len = 0, cap = 0;
 2017|  37.5M|  while (1) {
  ------------------
  |  Branch (2017:10): [True: 37.5M, Folded]
  ------------------
 2018|  37.5M|    switch (JVP_KIND(j)) {
  ------------------
  |  |   90|  37.5M|#define JVP_KIND(j)   (JVP_FLAGS(j) & KIND_MASK)
  |  |  ------------------
  |  |  |  |   89|  37.5M|#define JVP_FLAGS(j)  ((j).kind_flags)
  |  |  ------------------
  |  |               #define JVP_KIND(j)   (JVP_FLAGS(j) & KIND_MASK)
  |  |  ------------------
  |  |  |  |   77|  37.5M|#define KIND_MASK   0xF
  |  |  ------------------
  |  |  |  Branch (90:23): [True: 31.9M, False: 5.60M]
  |  |  ------------------
  ------------------
 2019|  5.90M|      case JV_KIND_ARRAY:
  ------------------
  |  Branch (2019:7): [True: 5.90M, False: 31.6M]
  ------------------
 2020|  5.90M|        if (jvp_refcnt_dec(j.u.ptr)) {
  ------------------
  |  Branch (2020:13): [True: 272k, False: 5.62M]
  ------------------
 2021|   272k|          jvp_array* arr = jvp_array_ptr(j);
 2022|   272k|          if (len + arr->length > cap) {
  ------------------
  |  Branch (2022:15): [True: 3.20k, False: 269k]
  ------------------
 2023|  3.20k|            cap = (len + arr->length) * 2;
 2024|  3.20k|            pending = jv_mem_realloc(pending, cap * sizeof(jv));
 2025|  3.20k|          }
 2026|  20.4M|          for (int i = 0; i < arr->length; i++)
  ------------------
  |  Branch (2026:27): [True: 20.1M, False: 272k]
  ------------------
 2027|  20.1M|            pending[len++] = arr->elements[i];
 2028|   272k|          jv_mem_free(arr);
 2029|   272k|        }
 2030|  5.90M|        break;
 2031|   394k|      case JV_KIND_OBJECT:
  ------------------
  |  Branch (2031:7): [True: 394k, False: 37.1M]
  ------------------
 2032|   394k|        if (jvp_refcnt_dec(j.u.ptr)) {
  ------------------
  |  Branch (2032:13): [True: 176k, False: 218k]
  ------------------
 2033|   176k|          int sz = jvp_object_size(j);
 2034|   176k|          if (len + sz > cap) {
  ------------------
  |  Branch (2034:15): [True: 105k, False: 70.4k]
  ------------------
 2035|   105k|            cap = (len + sz) * 2;
 2036|   105k|            pending = jv_mem_realloc(pending, cap * sizeof(jv));
 2037|   105k|          }
 2038|  1.61M|          for (int i = 0; i < sz; i++) {
  ------------------
  |  Branch (2038:27): [True: 1.43M, False: 176k]
  ------------------
 2039|  1.43M|            struct object_slot* slot = jvp_object_get_slot(j, i);
 2040|  1.43M|            if (jv_get_kind(slot->string) != JV_KIND_NULL) {
  ------------------
  |  Branch (2040:17): [True: 35.1k, False: 1.40M]
  ------------------
 2041|  35.1k|              jvp_string_free(slot->string);
 2042|  35.1k|              pending[len++] = slot->value;
 2043|  35.1k|            }
 2044|  1.43M|          }
 2045|   176k|          jv_mem_free(jvp_object_ptr(j));
 2046|   176k|        }
 2047|   394k|        break;
 2048|  5.74M|      case JV_KIND_INVALID:
  ------------------
  |  Branch (2048:7): [True: 5.74M, False: 31.8M]
  ------------------
 2049|  5.74M|        if (JVP_HAS_FLAGS(j, JVP_FLAGS_INVALID_MSG) && jvp_refcnt_dec(j.u.ptr)) {
  ------------------
  |  |   92|  11.4M|#define JVP_HAS_FLAGS(j, flags) (JVP_FLAGS(j) == flags)
  |  |  ------------------
  |  |  |  |   89|  5.74M|#define JVP_FLAGS(j)  ((j).kind_flags)
  |  |  ------------------
  |  |  |  Branch (92:33): [True: 8.09k, False: 5.73M]
  |  |  ------------------
  ------------------
  |  Branch (2049:56): [True: 4.08k, False: 4.01k]
  ------------------
 2050|  4.08k|          if (len + 1 > cap) {
  ------------------
  |  Branch (2050:15): [True: 4.08k, False: 0]
  ------------------
 2051|  4.08k|            cap = (len + 1) * 2;
 2052|  4.08k|            pending = jv_mem_realloc(pending, cap * sizeof(jv));
 2053|  4.08k|          }
 2054|  4.08k|          pending[len++] = ((jvp_invalid*)j.u.ptr)->errmsg;
 2055|  4.08k|          jv_mem_free(j.u.ptr);
 2056|  4.08k|        }
 2057|  5.74M|        break;
 2058|  18.8k|      case JV_KIND_STRING:
  ------------------
  |  Branch (2058:7): [True: 18.8k, False: 37.5M]
  ------------------
 2059|  18.8k|        jvp_string_free(j);
 2060|  18.8k|        break;
 2061|  19.9M|      case JV_KIND_NUMBER:
  ------------------
  |  Branch (2061:7): [True: 19.9M, False: 17.6M]
  ------------------
 2062|  19.9M|        jvp_number_free(j);
 2063|  19.9M|        break;
 2064|  37.5M|    }
 2065|  37.5M|    if (len == 0) break;
  ------------------
  |  Branch (2065:9): [True: 17.4M, False: 20.1M]
  ------------------
 2066|  20.1M|    j = pending[--len];
 2067|  20.1M|  }
 2068|  17.4M|  jv_mem_free(pending);
 2069|  17.4M|}
jv.c:jvp_literal_number_new:
  572|  5.55M|static jv jvp_literal_number_new(const char * literal) {
  573|  5.55M|  size_t len = strlen(literal);
  574|  5.55M|  if (len > DEC_MAX_DIGITS)
  ------------------
  |  |   88|  5.55M|  #define DEC_MAX_DIGITS 999999999
  ------------------
  |  Branch (574:7): [True: 0, False: 5.55M]
  ------------------
  575|      0|    return JV_INVALID;
  576|  5.55M|  jvp_literal_number* n = jvp_literal_number_alloc(len);
  577|       |
  578|  5.55M|  decContext *ctx = DEC_CONTEXT();
  ------------------
  |  |  487|  5.55M|#define DEC_CONTEXT() tsd_dec_ctx_get(&dec_ctx_key)
  ------------------
  579|  5.55M|  decContextClearStatus(ctx, DEC_Conversion_syntax);
  ------------------
  |  |  128|  5.55M|    #define DEC_Conversion_syntax    0x00000001
  ------------------
  580|  5.55M|  decNumberFromString(&n->num_decimal, literal, ctx);
  581|       |
  582|  5.55M|  if (ctx->status & DEC_Conversion_syntax) {
  ------------------
  |  |  128|  5.55M|    #define DEC_Conversion_syntax    0x00000001
  ------------------
  |  Branch (582:7): [True: 586, False: 5.55M]
  ------------------
  583|    586|    jv_mem_free(n);
  584|    586|    return JV_INVALID;
  585|    586|  }
  586|  5.55M|  if (decNumberIsNaN(&n->num_decimal)) {
  ------------------
  |  |  172|  5.55M|  #define decNumberIsNaN(dn)       (((dn)->bits&(DECNAN|DECSNAN))!=0)
  |  |  ------------------
  |  |  |  |   33|  5.55M|  #define DECNAN    0x20      /* 1=NaN                                */
  |  |  ------------------
  |  |                 #define decNumberIsNaN(dn)       (((dn)->bits&(DECNAN|DECSNAN))!=0)
  |  |  ------------------
  |  |  |  |   34|  5.55M|  #define DECSNAN   0x10      /* 1=sNaN                               */
  |  |  ------------------
  |  |  |  Branch (172:36): [True: 1.90k, False: 5.55M]
  |  |  ------------------
  ------------------
  587|       |    // Reject NaN with payload.
  588|  1.90k|    if (n->num_decimal.digits > 1 || *n->num_decimal.lsu != 0) {
  ------------------
  |  Branch (588:9): [True: 44, False: 1.85k]
  |  Branch (588:38): [True: 1, False: 1.85k]
  ------------------
  589|     45|      jv_mem_free(n);
  590|     45|      return JV_INVALID;
  591|     45|    }
  592|  1.85k|    jv_mem_free(n);
  593|  1.85k|    return jv_number(NAN);
  594|  1.90k|  }
  595|       |
  596|  5.55M|  jv r = {JVP_FLAGS_NUMBER_LITERAL, 0, 0, 0, {&n->refcnt}};
  ------------------
  |  |  206|  5.55M|#define JVP_FLAGS_NUMBER_LITERAL      JVP_MAKE_FLAGS(JV_KIND_NUMBER, JVP_MAKE_PFLAGS(JVP_NUMBER_DECIMAL, 1))
  |  |  ------------------
  |  |  |  |   87|  11.1M|#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   77|  5.55M|#define KIND_MASK   0xF
  |  |  |  |  ------------------
  |  |  |  |               #define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   78|  5.55M|#define PFLAGS_MASK 0xF0
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (87:61): [True: 5.55M, Folded]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  597|  5.55M|  return r;
  598|  5.55M|}
jv.c:jvp_literal_number_ptr:
  547|  5.55M|static jvp_literal_number* jvp_literal_number_ptr(jv j) {
  548|  5.55M|  assert(JVP_HAS_FLAGS(j, JVP_FLAGS_NUMBER_LITERAL));
  ------------------
  |  Branch (548:3): [True: 0, Folded]
  |  Branch (548:3): [True: 0, False: 5.55M]
  |  Branch (548:3): [True: 5.55M, Folded]
  |  Branch (548:3): [True: 5.55M, False: 0]
  ------------------
  549|  5.55M|  return (jvp_literal_number*)j.u.ptr;
  550|  5.55M|}
jv.c:jvp_literal_number_alloc:
  557|  5.55M|static jvp_literal_number* jvp_literal_number_alloc(unsigned literal_length) {
  558|       |  /* The number of units needed is ceil(DECNUMDIGITS/DECDPUN)         */
  559|  5.55M|  int units = ((literal_length+DECDPUN-1)/DECDPUN);
  ------------------
  |  |   43|  5.55M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
                int units = ((literal_length+DECDPUN-1)/DECDPUN);
  ------------------
  |  |   43|  5.55M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  560|       |
  561|  5.55M|  jvp_literal_number* n = jv_mem_alloc(
  562|  5.55M|    sizeof(jvp_literal_number)
  563|  5.55M|    + sizeof(decNumberUnit) * units
  564|  5.55M|  );
  565|       |
  566|  5.55M|  n->refcnt = JV_REFCNT_INIT;
  567|  5.55M|  n->num_double = NAN;
  568|       |  n->literal_data = NULL;
  569|  5.55M|  return n;
  570|  5.55M|}
jv.c:tsd_dec_ctx_get:
  504|  5.55M|static decContext* tsd_dec_ctx_get(pthread_key_t *key) {
  505|  5.55M|  pthread_once(&dec_ctx_once, jv_tsd_dec_ctx_init); // cannot fail
  506|  5.55M|  decContext *ctx = (decContext*)pthread_getspecific(*key);
  507|  5.55M|  if (ctx) {
  ------------------
  |  Branch (507:7): [True: 5.55M, False: 1]
  ------------------
  508|  5.55M|    return ctx;
  509|  5.55M|  }
  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,
  ------------------
  |  |   49|      1|  ({ __typeof__ (a) _a = (a); \
  |  |   50|      1|   __typeof__ (b) _b = (b); \
  |  |   51|      1|   _a < _b ? _a : _b; })
  |  |  ------------------
  |  |  |  Branch (51: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|   270k|static jv jvp_array_new(unsigned size) {
  841|   270k|  jv r = {JVP_FLAGS_ARRAY, 0, 0, 0, {&jvp_array_alloc(size)->refcnt}};
  ------------------
  |  |  813|   270k|#define JVP_FLAGS_ARRAY   JVP_MAKE_FLAGS(JV_KIND_ARRAY, JVP_PAYLOAD_ALLOCATED)
  |  |  ------------------
  |  |  |  |   87|   270k|#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   77|   270k|#define KIND_MASK   0xF
  |  |  |  |  ------------------
  |  |  |  |               #define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   78|   270k|#define PFLAGS_MASK 0xF0
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  842|   270k|  return r;
  843|   270k|}
jv.c:jvp_array_alloc:
  832|   272k|static jvp_array* jvp_array_alloc(unsigned size) {
  833|   272k|  jvp_array* a = jv_mem_alloc(sizeof(jvp_array) + sizeof(jv) * size);
  834|   272k|  a->refcnt.count = 1;
  835|   272k|  a->length = 0;
  836|   272k|  a->alloc_length = size;
  837|   272k|  return a;
  838|   272k|}
jv.c:jvp_array_length:
  845|  20.1M|static int jvp_array_length(jv a) {
  846|  20.1M|  assert(JVP_HAS_KIND(a, JV_KIND_ARRAY));
  ------------------
  |  Branch (846:3): [True: 0, False: 20.1M]
  |  Branch (846:3): [True: 20.1M, False: 0]
  ------------------
  847|  20.1M|  return a.size;
  848|  20.1M|}
jv.c:jvp_array_offset:
  850|  25.7M|static int jvp_array_offset(jv a) {
  851|  25.7M|  assert(JVP_HAS_KIND(a, JV_KIND_ARRAY));
  ------------------
  |  Branch (851:3): [True: 0, False: 25.7M]
  |  Branch (851:3): [True: 25.7M, False: 0]
  ------------------
  852|  25.7M|  return a.offset;
  853|  25.7M|}
jv.c:jvp_array_write:
  866|  5.60M|static jv* jvp_array_write(jv* a, int i) {
  867|  5.60M|  assert(i >= 0);
  ------------------
  |  Branch (867:3): [True: 0, False: 5.60M]
  |  Branch (867:3): [True: 5.60M, False: 0]
  ------------------
  868|  5.60M|  jvp_array* array = jvp_array_ptr(*a);
  869|       |
  870|  5.60M|  int pos = i + jvp_array_offset(*a);
  871|  5.60M|  if (pos < array->alloc_length && jvp_refcnt_unshared(a->u.ptr)) {
  ------------------
  |  Branch (871:7): [True: 5.60M, False: 2.25k]
  |  Branch (871:36): [True: 5.60M, False: 0]
  ------------------
  872|       |    // use existing array space
  873|  11.2M|    for (int j = array->length; j <= pos; j++) {
  ------------------
  |  Branch (873:33): [True: 5.60M, False: 5.60M]
  ------------------
  874|  5.60M|      array->elements[j] = JV_NULL;
  875|  5.60M|    }
  876|  5.60M|    array->length = imax(pos + 1, array->length);
  877|  5.60M|    a->size = imax(i + 1, a->size);
  878|  5.60M|    return &array->elements[pos];
  879|  5.60M|  } else {
  880|       |    // allocate a new array
  881|  2.25k|    int new_length = imax(i + 1, jvp_array_length(*a));
  882|  2.25k|    jvp_array* new_array = jvp_array_alloc(ARRAY_SIZE_ROUND_UP(new_length));
  ------------------
  |  |  812|  2.25k|#define ARRAY_SIZE_ROUND_UP(n) (((n)*3)/2)
  ------------------
  883|  2.25k|    int j;
  884|  14.5M|    for (j = 0; j < jvp_array_length(*a); j++) {
  ------------------
  |  Branch (884:17): [True: 14.5M, False: 2.25k]
  ------------------
  885|  14.5M|      new_array->elements[j] =
  886|  14.5M|        jv_copy(array->elements[j + jvp_array_offset(*a)]);
  887|  14.5M|    }
  888|  4.50k|    for (; j < new_length; j++) {
  ------------------
  |  Branch (888:12): [True: 2.25k, False: 2.25k]
  ------------------
  889|  2.25k|      new_array->elements[j] = JV_NULL;
  890|  2.25k|    }
  891|  2.25k|    new_array->length = new_length;
  892|  2.25k|    jv_free(*a);
  893|  2.25k|    jv new_jv = {JVP_FLAGS_ARRAY, 0, 0, new_length, {&new_array->refcnt}};
  ------------------
  |  |  813|  2.25k|#define JVP_FLAGS_ARRAY   JVP_MAKE_FLAGS(JV_KIND_ARRAY, JVP_PAYLOAD_ALLOCATED)
  |  |  ------------------
  |  |  |  |   87|  2.25k|#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   77|  2.25k|#define KIND_MASK   0xF
  |  |  |  |  ------------------
  |  |  |  |               #define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   78|  2.25k|#define PFLAGS_MASK 0xF0
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  894|  2.25k|    *a = new_jv;
  895|  2.25k|    return &new_array->elements[i];
  896|  2.25k|  }
  897|  5.60M|}
jv.c:jvp_refcnt_unshared:
   72|  5.64M|static int jvp_refcnt_unshared(jv_refcnt* c) {
   73|  5.64M|  assert(c->count > 0);
  ------------------
  |  Branch (73:3): [True: 0, False: 5.64M]
  |  Branch (73:3): [True: 5.64M, False: 0]
  ------------------
   74|  5.64M|  return c->count == 1;
   75|  5.64M|}
jv.c:imax:
  815|  11.2M|static int imax(int a, int b) {
  816|  11.2M|  if (a>b) return a;
  ------------------
  |  Branch (816:7): [True: 11.2M, False: 0]
  ------------------
  817|      0|  else return b;
  818|  11.2M|}
jv.c:jvp_string_new:
 1141|  48.4k|static jv jvp_string_new(const char* data, uint32_t length) {
 1142|  48.4k|  jvp_string* s = jvp_string_alloc(length);
 1143|  48.4k|  s->length_hashed = length << 1;
 1144|  48.4k|  if (data != NULL)
  ------------------
  |  Branch (1144:7): [True: 48.4k, False: 0]
  ------------------
 1145|  48.4k|    memcpy(s->data, data, length);
 1146|  48.4k|  s->data[length] = 0;
 1147|  48.4k|  jv r = {JVP_FLAGS_STRING, 0, 0, 0, {&s->refcnt}};
  ------------------
  |  | 1087|  48.4k|#define JVP_FLAGS_STRING  JVP_MAKE_FLAGS(JV_KIND_STRING, JVP_PAYLOAD_ALLOCATED)
  |  |  ------------------
  |  |  |  |   87|  48.4k|#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   77|  48.4k|#define KIND_MASK   0xF
  |  |  |  |  ------------------
  |  |  |  |               #define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   78|  48.4k|#define PFLAGS_MASK 0xF0
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1148|  48.4k|  return r;
 1149|  48.4k|}
jv.c:jvp_string_alloc:
 1104|  52.2k|static jvp_string* jvp_string_alloc(uint32_t size) {
 1105|  52.2k|  jvp_string* s = jv_mem_alloc(sizeof(jvp_string) + size + 1);
 1106|  52.2k|  s->refcnt.count = 1;
 1107|  52.2k|  s->alloc_length = size;
 1108|  52.2k|  return s;
 1109|  52.2k|}
jv.c:jvp_string_copy_replace_bad:
 1112|  3.77k|static jv jvp_string_copy_replace_bad(const char* data, uint32_t length) {
 1113|  3.77k|  const char* end = data + length;
 1114|  3.77k|  const char* i = data;
 1115|       |
 1116|       |  // worst case: all bad bytes, each becomes a 3-byte U+FFFD
 1117|  3.77k|  uint64_t maxlength = (uint64_t)length * 3 + 1;
 1118|  3.77k|  if (maxlength >= INT_MAX) {
  ------------------
  |  Branch (1118:7): [True: 0, False: 3.77k]
  ------------------
 1119|      0|    return jv_invalid_with_msg(jv_string("String too long"));
 1120|      0|  }
 1121|       |
 1122|  3.77k|  jvp_string* s = jvp_string_alloc(maxlength);
 1123|  3.77k|  char* out = s->data;
 1124|  3.77k|  int c = 0;
 1125|       |
 1126|  35.6M|  while ((i = jvp_utf8_next(i, end, &c))) {
  ------------------
  |  Branch (1126:10): [True: 35.6M, False: 3.77k]
  ------------------
 1127|  35.6M|    if (c == -1) {
  ------------------
  |  Branch (1127:9): [True: 4.26M, False: 31.3M]
  ------------------
 1128|  4.26M|      c = 0xFFFD; // U+FFFD REPLACEMENT CHARACTER
 1129|  4.26M|    }
 1130|  35.6M|    out += jvp_utf8_encode(c, out);
 1131|  35.6M|    assert(out < s->data + maxlength);
  ------------------
  |  Branch (1131:5): [True: 0, False: 35.6M]
  |  Branch (1131:5): [True: 35.6M, False: 0]
  ------------------
 1132|  35.6M|  }
 1133|  3.77k|  length = out - s->data;
 1134|  3.77k|  s->data[length] = 0;
 1135|  3.77k|  s->length_hashed = length << 1;
 1136|  3.77k|  jv r = {JVP_FLAGS_STRING, 0, 0, 0, {&s->refcnt}};
  ------------------
  |  | 1087|  3.77k|#define JVP_FLAGS_STRING  JVP_MAKE_FLAGS(JV_KIND_STRING, JVP_PAYLOAD_ALLOCATED)
  |  |  ------------------
  |  |  |  |   87|  3.77k|#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   77|  3.77k|#define KIND_MASK   0xF
  |  |  |  |  ------------------
  |  |  |  |               #define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   78|  3.77k|#define PFLAGS_MASK 0xF0
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1137|  3.77k|  return r;
 1138|  3.77k|}
jv.c:jvp_string_length:
 1168|  44.4k|static uint32_t jvp_string_length(jvp_string* s) {
 1169|  44.4k|  return s->length_hashed >> 1;
 1170|  44.4k|}
jv.c:jvp_string_ptr:
 1099|   260k|static jvp_string* jvp_string_ptr(jv a) {
 1100|   260k|  assert(JVP_HAS_KIND(a, JV_KIND_STRING));
  ------------------
  |  Branch (1100:3): [True: 0, False: 260k]
  |  Branch (1100:3): [True: 260k, False: 0]
  ------------------
 1101|   260k|  return (jvp_string*)a.u.ptr;
 1102|   260k|}
jv.c:jvp_string_hash:
 1240|   197k|static uint32_t jvp_string_hash(jv jstr) {
 1241|   197k|  jvp_string* str = jvp_string_ptr(jstr);
 1242|   197k|  if (str->length_hashed & 1)
  ------------------
  |  Branch (1242:7): [True: 160k, False: 37.4k]
  ------------------
 1243|   160k|    return str->hash;
 1244|       |
 1245|       |  /* The following is based on MurmurHash3.
 1246|       |     MurmurHash3 was written by Austin Appleby, and is placed
 1247|       |     in the public domain. */
 1248|       |
 1249|  37.4k|  const uint8_t* data = (const uint8_t*)str->data;
 1250|  37.4k|  int len = (int)jvp_string_length(str);
 1251|  37.4k|  const int nblocks = len / 4;
 1252|       |
 1253|  37.4k|  uint32_t h1 = jvp_hash_seed();
 1254|       |
 1255|  37.4k|  const uint32_t c1 = 0xcc9e2d51;
 1256|  37.4k|  const uint32_t c2 = 0x1b873593;
 1257|  37.4k|  const uint32_t* blocks = (const uint32_t *)(data + nblocks*4);
 1258|       |
 1259|  1.41M|  for(int i = -nblocks; i; i++) {
  ------------------
  |  Branch (1259:25): [True: 1.37M, False: 37.4k]
  ------------------
 1260|  1.37M|    uint32_t k1 = blocks[i]; //FIXME: endianness/alignment
 1261|       |
 1262|  1.37M|    k1 *= c1;
 1263|  1.37M|    k1 = rotl32(k1,15);
 1264|  1.37M|    k1 *= c2;
 1265|       |
 1266|  1.37M|    h1 ^= k1;
 1267|  1.37M|    h1 = rotl32(h1,13);
 1268|  1.37M|    h1 = h1*5+0xe6546b64;
 1269|  1.37M|  }
 1270|       |
 1271|  37.4k|  const uint8_t* tail = (const uint8_t*)(data + nblocks*4);
 1272|       |
 1273|  37.4k|  uint32_t k1 = 0;
 1274|       |
 1275|  37.4k|  switch(len & 3) {
  ------------------
  |  Branch (1275:10): [True: 28.2k, False: 9.20k]
  ------------------
 1276|  7.47k|  case 3: k1 ^= tail[2] << 16;
  ------------------
  |  Branch (1276:3): [True: 7.47k, False: 30.0k]
  ------------------
 1277|  7.47k|          JQ_FALLTHROUGH;
  ------------------
  |  |   14|  7.47k|# define JQ_FALLTHROUGH __attribute__((fallthrough))
  ------------------
 1278|  14.4k|  case 2: k1 ^= tail[1] << 8;
  ------------------
  |  Branch (1278:3): [True: 6.93k, False: 30.5k]
  ------------------
 1279|  14.4k|          JQ_FALLTHROUGH;
  ------------------
  |  |   14|  14.4k|# define JQ_FALLTHROUGH __attribute__((fallthrough))
  ------------------
 1280|  28.2k|  case 1: k1 ^= tail[0];
  ------------------
  |  Branch (1280:3): [True: 13.8k, False: 23.6k]
  ------------------
 1281|  28.2k|          k1 *= c1; k1 = rotl32(k1,15); k1 *= c2; h1 ^= k1;
 1282|  37.4k|  }
 1283|       |
 1284|  37.4k|  h1 ^= len;
 1285|       |
 1286|  37.4k|  h1 ^= h1 >> 16;
 1287|  37.4k|  h1 *= 0x85ebca6b;
 1288|  37.4k|  h1 ^= h1 >> 13;
 1289|  37.4k|  h1 *= 0xc2b2ae35;
 1290|  37.4k|  h1 ^= h1 >> 16;
 1291|       |
 1292|  37.4k|  str->length_hashed |= 1;
 1293|  37.4k|  str->hash = h1;
 1294|       |
 1295|  37.4k|  return h1;
 1296|  37.4k|}
jv.c:jvp_hash_seed:
 1231|  37.4k|static uint32_t jvp_hash_seed(void) {
 1232|  37.4k|  pthread_once(&hash_seed_once, jvp_hash_seed_init);
 1233|  37.4k|  return hash_seed;
 1234|  37.4k|}
jv.c:jvp_hash_seed_init:
 1211|      1|static void jvp_hash_seed_init(void) {
 1212|      1|  uint32_t seed;
 1213|       |#if defined(HAVE_ARC4RANDOM)
 1214|       |  seed = arc4random();
 1215|       |#elif defined(HAVE_GETENTROPY)
 1216|      1|  if (getentropy(&seed, sizeof(seed)) != 0)
  ------------------
  |  Branch (1216:7): [True: 0, False: 1]
  ------------------
 1217|      0|    seed = (uint32_t)getpid() ^ (uint32_t)time(NULL);
 1218|       |#else
 1219|       |  int fd = open("/dev/urandom", O_RDONLY);
 1220|       |  if (fd >= 0) {
 1221|       |    if (read(fd, &seed, sizeof(seed)) != 4)
 1222|       |      seed = (uint32_t)getpid() ^ (uint32_t)time(NULL);
 1223|       |    close(fd);
 1224|       |  } else {
 1225|       |    seed = (uint32_t)getpid() ^ (uint32_t)time(NULL);
 1226|       |  }
 1227|       |#endif
 1228|      1|  hash_seed = seed;
 1229|      1|}
jv.c:rotl32:
 1236|  2.77M|static uint32_t rotl32 (uint32_t x, int8_t r){
 1237|  2.77M|  return (x << r) | (x >> (32 - r));
 1238|  2.77M|}
jv.c:jvp_object_new:
 1615|   178k|static jv jvp_object_new(int size) {
 1616|       |  // Allocates an object of (size) slots and (size*2) hash buckets.
 1617|       |
 1618|       |  // size must be a power of two
 1619|   178k|  assert(size > 0 && (size & (size - 1)) == 0);
  ------------------
  |  Branch (1619:3): [True: 0, False: 178k]
  |  Branch (1619:3): [True: 0, False: 0]
  |  Branch (1619:3): [True: 178k, False: 0]
  |  Branch (1619:3): [True: 178k, False: 0]
  ------------------
 1620|       |
 1621|   178k|  jvp_object* obj = jv_mem_alloc(sizeof(jvp_object) +
 1622|   178k|                                 sizeof(struct object_slot) * size +
 1623|   178k|                                 sizeof(int) * (size * 2));
 1624|   178k|  obj->refcnt.count = 1;
 1625|  1.64M|  for (int i=0; i<size; i++) {
  ------------------
  |  Branch (1625:17): [True: 1.46M, False: 178k]
  ------------------
 1626|  1.46M|    obj->elements[i].next = i - 1;
 1627|  1.46M|    obj->elements[i].string = JV_NULL;
 1628|  1.46M|    obj->elements[i].hash = 0;
 1629|  1.46M|    obj->elements[i].value = JV_NULL;
 1630|  1.46M|  }
 1631|   178k|  obj->next_free = 0;
 1632|   178k|  int* hashbuckets = (int*)(&obj->elements[size]);
 1633|  3.10M|  for (int i=0; i<size*2; i++) {
  ------------------
  |  Branch (1633:17): [True: 2.92M, False: 178k]
  ------------------
 1634|  2.92M|    hashbuckets[i] = -1;
 1635|  2.92M|  }
 1636|   178k|  jv r = {JVP_FLAGS_OBJECT, 0, 0, size, {&obj->refcnt}};
  ------------------
  |  | 1598|   178k|#define JVP_FLAGS_OBJECT  JVP_MAKE_FLAGS(JV_KIND_OBJECT, JVP_PAYLOAD_ALLOCATED)
  |  |  ------------------
  |  |  |  |   87|   178k|#define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   77|   178k|#define KIND_MASK   0xF
  |  |  |  |  ------------------
  |  |  |  |               #define JVP_MAKE_FLAGS(kind, pflags) ((kind & KIND_MASK) | (pflags & PFLAGS_MASK))
  |  |  |  |  ------------------
  |  |  |  |  |  |   78|   178k|#define PFLAGS_MASK 0xF0
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1637|   178k|  return r;
 1638|   178k|}
jv.c:jvp_object_find_bucket:
 1659|  67.5k|static int* jvp_object_find_bucket(jv object, jv key) {
 1660|  67.5k|  return jvp_object_buckets(object) + (jvp_object_mask(object) & jvp_string_hash(key));
 1661|  67.5k|}
jv.c:jvp_object_buckets:
 1655|  67.5k|static int* jvp_object_buckets(jv o) {
 1656|  67.5k|  return (int*)(&jvp_object_ptr(o)->elements[o.size]);
 1657|  67.5k|}
jv.c:jvp_object_mask:
 1645|  67.5k|static uint32_t jvp_object_mask(jv o) {
 1646|  67.5k|  assert(JVP_HAS_KIND(o, JV_KIND_OBJECT));
  ------------------
  |  Branch (1646:3): [True: 0, False: 67.5k]
  |  Branch (1646:3): [True: 67.5k, False: 0]
  ------------------
 1647|  67.5k|  return (o.size * 2) - 1;
 1648|  67.5k|}
jv.c:jvp_object_find_slot:
 1673|  67.5k|static struct object_slot* jvp_object_find_slot(jv object, jv keystr, int* bucket) {
 1674|  67.5k|  uint32_t hash = jvp_string_hash(keystr);
 1675|  67.5k|  for (struct object_slot* curr = jvp_object_get_slot(object, *bucket);
 1676|  75.6k|       curr;
  ------------------
  |  Branch (1676:8): [True: 10.4k, False: 65.2k]
  ------------------
 1677|  67.5k|       curr = jvp_object_next_slot(object, curr)) {
 1678|  10.4k|    if (curr->hash == hash && jvp_string_equal(keystr, curr->string)) {
  ------------------
  |  Branch (1678:9): [True: 2.31k, False: 8.09k]
  |  Branch (1678:31): [True: 2.31k, False: 0]
  ------------------
 1679|  2.31k|      return curr;
 1680|  2.31k|    }
 1681|  10.4k|  }
 1682|  65.2k|  return 0;
 1683|  67.5k|}
jv.c:jvp_string_equal:
 1299|  2.31k|static int jvp_string_equal(jv a, jv b) {
 1300|  2.31k|  assert(JVP_HAS_KIND(a, JV_KIND_STRING));
  ------------------
  |  Branch (1300:3): [True: 0, False: 2.31k]
  |  Branch (1300:3): [True: 2.31k, False: 0]
  ------------------
 1301|  2.31k|  assert(JVP_HAS_KIND(b, JV_KIND_STRING));
  ------------------
  |  Branch (1301:3): [True: 0, False: 2.31k]
  |  Branch (1301:3): [True: 2.31k, False: 0]
  ------------------
 1302|  2.31k|  jvp_string* stra = jvp_string_ptr(a);
 1303|  2.31k|  jvp_string* strb = jvp_string_ptr(b);
 1304|  2.31k|  if (jvp_string_length(stra) != jvp_string_length(strb)) return 0;
  ------------------
  |  Branch (1304:7): [True: 0, False: 2.31k]
  ------------------
 1305|  2.31k|  return memcmp(stra->data, strb->data, jvp_string_length(stra)) == 0;
 1306|  2.31k|}
jv.c:jvp_object_next_slot:
 1669|  8.09k|static struct object_slot* jvp_object_next_slot(jv object, struct object_slot* slot) {
 1670|  8.09k|  return jvp_object_get_slot(object, slot->next);
 1671|  8.09k|}
jv.c:jvp_object_write:
 1755|  37.4k|static int jvp_object_write(jv* object, jv key, jv **valpp) {
 1756|  37.4k|  *object = jvp_object_unshare(*object);
 1757|  37.4k|  int* bucket = jvp_object_find_bucket(*object, key);
 1758|  37.4k|  struct object_slot* slot = jvp_object_find_slot(*object, key, bucket);
 1759|  37.4k|  if (slot) {
  ------------------
  |  Branch (1759:7): [True: 2.31k, False: 35.1k]
  ------------------
 1760|       |    // already has the key
 1761|  2.31k|    jvp_string_free(key);
 1762|  2.31k|    *valpp = &slot->value;
 1763|  2.31k|    return 1;
 1764|  2.31k|  }
 1765|  35.1k|  slot = jvp_object_add_slot(*object, key, bucket);
 1766|  35.1k|  if (slot) {
  ------------------
  |  Branch (1766:7): [True: 32.8k, False: 2.35k]
  ------------------
 1767|  32.8k|    slot->value = jv_invalid();
 1768|  32.8k|  } else {
 1769|  2.35k|    if (!jvp_object_rehash(object)) {
  ------------------
  |  Branch (1769:9): [True: 0, False: 2.35k]
  ------------------
 1770|      0|      jvp_string_free(key);
 1771|      0|      *valpp = NULL;
 1772|      0|      return 0;
 1773|      0|    }
 1774|  2.35k|    bucket = jvp_object_find_bucket(*object, key);
 1775|  2.35k|    assert(!jvp_object_find_slot(*object, key, bucket));
  ------------------
  |  Branch (1775:5): [True: 0, False: 2.35k]
  |  Branch (1775:5): [True: 2.35k, False: 0]
  ------------------
 1776|  2.35k|    slot = jvp_object_add_slot(*object, key, bucket);
 1777|  2.35k|    assert(slot);
  ------------------
  |  Branch (1777:5): [True: 0, False: 2.35k]
  |  Branch (1777:5): [True: 2.35k, False: 0]
  ------------------
 1778|  2.35k|    slot->value = jv_invalid();
 1779|  2.35k|  }
 1780|  35.1k|  *valpp = &slot->value;
 1781|  35.1k|  return 1;
 1782|  35.1k|}
jv.c:jvp_object_unshare:
 1729|  37.4k|static jv jvp_object_unshare(jv object) {
 1730|  37.4k|  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));
  ------------------
  |  Branch (1730:3): [True: 0, False: 37.4k]
  |  Branch (1730:3): [True: 37.4k, False: 0]
  ------------------
 1731|  37.4k|  if (jvp_refcnt_unshared(object.u.ptr))
  ------------------
  |  Branch (1731:7): [True: 37.4k, False: 0]
  ------------------
 1732|  37.4k|    return object;
 1733|       |
 1734|      0|  jv new_object = jvp_object_new(jvp_object_size(object));
 1735|      0|  jvp_object_ptr(new_object)->next_free = jvp_object_ptr(object)->next_free;
 1736|      0|  for (int i=0; i<jvp_object_size(new_object); i++) {
  ------------------
  |  Branch (1736:17): [True: 0, False: 0]
  ------------------
 1737|      0|    struct object_slot* old_slot = jvp_object_get_slot(object, i);
 1738|      0|    struct object_slot* new_slot = jvp_object_get_slot(new_object, i);
 1739|      0|    *new_slot = *old_slot;
 1740|      0|    if (jv_get_kind(old_slot->string) != JV_KIND_NULL) {
  ------------------
  |  Branch (1740:9): [True: 0, False: 0]
  ------------------
 1741|      0|      new_slot->string = jv_copy(old_slot->string);
 1742|      0|      new_slot->value = jv_copy(old_slot->value);
 1743|      0|    }
 1744|      0|  }
 1745|       |
 1746|      0|  int* old_buckets = jvp_object_buckets(object);
 1747|      0|  int* new_buckets = jvp_object_buckets(new_object);
 1748|      0|  memcpy(new_buckets, old_buckets, sizeof(int) * jvp_object_size(new_object)*2);
 1749|       |
 1750|      0|  jv_free(object);
 1751|      0|  assert(jvp_refcnt_unshared(new_object.u.ptr));
  ------------------
  |  Branch (1751:3): [True: 0, False: 0]
  |  Branch (1751:3): [True: 0, False: 0]
  ------------------
 1752|      0|  return new_object;
 1753|      0|}
jv.c:jvp_object_add_slot:
 1685|  65.2k|static struct object_slot* jvp_object_add_slot(jv object, jv key, int* bucket) {
 1686|  65.2k|  jvp_object* o = jvp_object_ptr(object);
 1687|  65.2k|  int newslot_idx = o->next_free;
 1688|  65.2k|  if (newslot_idx == jvp_object_size(object)) return 0;
  ------------------
  |  Branch (1688:7): [True: 2.35k, False: 62.8k]
  ------------------
 1689|  62.8k|  struct object_slot* newslot = jvp_object_get_slot(object, newslot_idx);
 1690|  62.8k|  o->next_free++;
 1691|  62.8k|  newslot->next = *bucket;
 1692|  62.8k|  *bucket = newslot_idx;
 1693|  62.8k|  newslot->hash = jvp_string_hash(key);
 1694|  62.8k|  newslot->string = key;
 1695|  62.8k|  return newslot;
 1696|  65.2k|}
jv.c:jvp_object_rehash:
 1706|  2.35k|static int jvp_object_rehash(jv *objectp) {
 1707|  2.35k|  jv object = *objectp;
 1708|  2.35k|  assert(JVP_HAS_KIND(object, JV_KIND_OBJECT));
  ------------------
  |  Branch (1708:3): [True: 0, False: 2.35k]
  |  Branch (1708:3): [True: 2.35k, False: 0]
  ------------------
 1709|  2.35k|  assert(jvp_refcnt_unshared(object.u.ptr));
  ------------------
  |  Branch (1709:3): [True: 0, False: 2.35k]
  |  Branch (1709:3): [True: 2.35k, False: 0]
  ------------------
 1710|  2.35k|  int size = jvp_object_size(object);
 1711|  2.35k|  if (size > INT_MAX >> 2)
  ------------------
  |  Branch (1711:7): [True: 0, False: 2.35k]
  ------------------
 1712|      0|    return 0;
 1713|  2.35k|  jv new_object = jvp_object_new(size * 2);
 1714|  30.0k|  for (int i=0; i<size; i++) {
  ------------------
  |  Branch (1714:17): [True: 27.6k, False: 2.35k]
  ------------------
 1715|  27.6k|    struct object_slot* slot = jvp_object_get_slot(object, i);
 1716|  27.6k|    if (jv_get_kind(slot->string) == JV_KIND_NULL) continue;
  ------------------
  |  Branch (1716:9): [True: 0, False: 27.6k]
  ------------------
 1717|  27.6k|    int* new_bucket = jvp_object_find_bucket(new_object, slot->string);
 1718|  27.6k|    assert(!jvp_object_find_slot(new_object, slot->string, new_bucket));
  ------------------
  |  Branch (1718:5): [True: 0, False: 27.6k]
  |  Branch (1718:5): [True: 27.6k, False: 0]
  ------------------
 1719|  27.6k|    struct object_slot* new_slot = jvp_object_add_slot(new_object, slot->string, new_bucket);
 1720|  27.6k|    assert(new_slot);
  ------------------
  |  Branch (1720:5): [True: 0, False: 27.6k]
  |  Branch (1720:5): [True: 27.6k, False: 0]
  ------------------
 1721|  27.6k|    new_slot->value = slot->value;
 1722|  27.6k|  }
 1723|       |  // references are transported, just drop the old table
 1724|  2.35k|  jv_mem_free(jvp_object_ptr(object));
 1725|  2.35k|  *objectp = new_object;
 1726|  2.35k|  return 1;
 1727|  2.35k|}
jv.c:jvp_object_length:
 1805|  63.8k|static int jvp_object_length(jv object) {
 1806|  63.8k|  int n = 0;
 1807|   575k|  for (int i=0; i<jvp_object_size(object); i++) {
  ------------------
  |  Branch (1807:17): [True: 511k, False: 63.8k]
  ------------------
 1808|   511k|    struct object_slot* slot = jvp_object_get_slot(object, i);
 1809|   511k|    if (jv_get_kind(slot->string) != JV_KIND_NULL) n++;
  ------------------
  |  Branch (1809:9): [True: 712, False: 510k]
  ------------------
 1810|   511k|  }
 1811|  63.8k|  return n;
 1812|  63.8k|}
jv.c:jvp_object_size:
 1650|  2.86M|static int jvp_object_size(jv o) {
 1651|  2.86M|  assert(JVP_HAS_KIND(o, JV_KIND_OBJECT));
  ------------------
  |  Branch (1651:3): [True: 0, False: 2.86M]
  |  Branch (1651:3): [True: 2.86M, False: 0]
  ------------------
 1652|  2.86M|  return o.size;
 1653|  2.86M|}
jv.c:jvp_object_get_slot:
 1663|  2.11M|static struct object_slot* jvp_object_get_slot(jv object, int slot) {
 1664|  2.11M|  assert(slot == -1 || (slot >= 0 && slot < jvp_object_size(object)));
  ------------------
  |  Branch (1664:3): [True: 0, False: 0]
  |  Branch (1664:3): [True: 0, False: 0]
  |  Branch (1664:3): [True: 2.11M, False: 0]
  |  Branch (1664:3): [True: 2.04M, False: 0]
  |  Branch (1664:3): [True: 2.04M, False: 0]
  |  Branch (1664:3): [True: 65.2k, False: 2.04M]
  ------------------
 1665|  2.11M|  if (slot == -1) return 0;
  ------------------
  |  Branch (1665:7): [True: 65.2k, False: 2.04M]
  ------------------
 1666|  2.04M|  else return &jvp_object_ptr(object)->elements[slot];
 1667|  2.11M|}
jv.c:jvp_refcnt_inc:
   63|  20.2M|static void jvp_refcnt_inc(jv_refcnt* c) {
   64|  20.2M|  c->count++;
   65|  20.2M|}
jv.c:jvp_refcnt_dec:
   67|  26.2M|static int jvp_refcnt_dec(jv_refcnt* c) {
   68|  26.2M|  c->count--;
   69|  26.2M|  return c->count == 0;
   70|  26.2M|}
jv.c:jvp_array_ptr:
  827|  5.87M|static jvp_array* jvp_array_ptr(jv a) {
  828|  5.87M|  assert(JVP_HAS_KIND(a, JV_KIND_ARRAY));
  ------------------
  |  Branch (828:3): [True: 0, False: 5.87M]
  |  Branch (828:3): [True: 5.87M, False: 0]
  ------------------
  829|  5.87M|  return (jvp_array*)a.u.ptr;
  830|  5.87M|}
jv.c:jvp_string_free:
 1161|  56.3k|static void jvp_string_free(jv js) {
 1162|  56.3k|  jvp_string* s = jvp_string_ptr(js);
 1163|  56.3k|  if (jvp_refcnt_dec(&s->refcnt)) {
  ------------------
  |  Branch (1163:7): [True: 52.2k, False: 4.14k]
  ------------------
 1164|  52.2k|    jv_mem_free(s);
 1165|  52.2k|  }
 1166|  56.3k|}
jv.c:jvp_object_ptr:
 1640|  2.35M|static jvp_object* jvp_object_ptr(jv o) {
 1641|  2.35M|  assert(JVP_HAS_KIND(o, JV_KIND_OBJECT));
  ------------------
  |  Branch (1641:3): [True: 0, False: 2.35M]
  |  Branch (1641:3): [True: 2.35M, False: 0]
  ------------------
 1642|  2.35M|  return (jvp_object*)o.u.ptr;
 1643|  2.35M|}
jv.c:jvp_number_free:
  685|  19.9M|static void jvp_number_free(jv j) {
  686|  19.9M|  assert(JVP_HAS_KIND(j, JV_KIND_NUMBER));
  ------------------
  |  Branch (686:3): [True: 0, False: 19.9M]
  |  Branch (686:3): [True: 19.9M, False: 0]
  ------------------
  687|  19.9M|#ifdef USE_DECNUM
  688|  19.9M|  if (JVP_HAS_FLAGS(j, JVP_FLAGS_NUMBER_LITERAL) && jvp_refcnt_dec(j.u.ptr)) {
  ------------------
  |  |   92|  39.8M|#define JVP_HAS_FLAGS(j, flags) (JVP_FLAGS(j) == flags)
  |  |  ------------------
  |  |  |  |   89|  19.9M|#define JVP_FLAGS(j)  ((j).kind_flags)
  |  |  ------------------
  |  |  |  Branch (92:33): [True: 19.9M, False: 4.79k]
  |  |  |  Branch (92:50): [True: 19.9M, Folded]
  |  |  ------------------
  ------------------
  |  Branch (688:53): [True: 5.55M, False: 14.3M]
  ------------------
  689|  5.55M|    jvp_literal_number* n = jvp_literal_number_ptr(j);
  690|  5.55M|    if (n->literal_data) {
  ------------------
  |  Branch (690:9): [True: 0, False: 5.55M]
  ------------------
  691|      0|      jv_mem_free(n->literal_data);
  692|      0|    }
  693|  5.55M|    jv_mem_free(n);
  694|  5.55M|  }
  695|  19.9M|#endif
  696|  19.9M|}

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

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

jvp_dtoa_context_init:
  522|  3.09k|void jvp_dtoa_context_init(struct dtoa_context* C) {
  523|  3.09k|  int i;
  524|  27.8k|  for (i=0; i<(int)(sizeof(C->freelist)/sizeof(C->freelist[0])); i++) {
  ------------------
  |  Branch (524:13): [True: 24.7k, False: 3.09k]
  ------------------
  525|  24.7k|    C->freelist[i] = 0;
  526|  24.7k|  }
  527|  3.09k|  C->p5s = 0;
  528|  3.09k|}
jvp_dtoa_context_free:
  569|  3.09k|void jvp_dtoa_context_free(struct dtoa_context* C) {
  570|  3.09k|  int k;
  571|  3.09k|  while (C->p5s) {
  ------------------
  |  Branch (571:10): [True: 0, False: 3.09k]
  ------------------
  572|      0|    Bigint* p5 = C->p5s;
  573|      0|    C->p5s = p5->next;
  574|      0|    Bfree(C, p5);
  575|      0|  }
  576|  27.8k|  for (k=0; k<(int)(sizeof(C->freelist)/sizeof(C->freelist[0])); k++) {
  ------------------
  |  Branch (576:13): [True: 24.7k, False: 3.09k]
  ------------------
  577|  24.7k|    while (C->freelist[k]) {
  ------------------
  |  Branch (577:12): [True: 0, False: 24.7k]
  ------------------
  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.7k|  }
  583|  3.09k|}

jv_parser_set_buf:
  740|  3.09k|void jv_parser_set_buf(struct jv_parser* p, const char* buf, int length, int is_partial) {
  741|  3.09k|  assert((p->curr_buf == 0 || p->curr_buf_pos == p->curr_buf_length)
  ------------------
  |  Branch (741:3): [True: 3.09k, False: 0]
  |  Branch (741:3): [True: 0, False: 0]
  |  Branch (741:3): [True: 0, False: 0]
  |  Branch (741:3): [True: 3.09k, False: 0]
  |  Branch (741:3): [True: 0, False: 0]
  |  Branch (741:3): [True: 3.09k, False: 0]
  ------------------
  742|  3.09k|         && "previous buffer not exhausted");
  743|  6.21k|  while (length > 0 && p->bom_strip_position < sizeof(UTF8_BOM)) {
  ------------------
  |  Branch (743:10): [True: 6.21k, False: 4]
  |  Branch (743:24): [True: 3.12k, False: 3.09k]
  ------------------
  744|  3.12k|    if ((unsigned char)*buf == UTF8_BOM[p->bom_strip_position]) {
  ------------------
  |  Branch (744:9): [True: 29, False: 3.09k]
  ------------------
  745|       |      // matched a BOM character
  746|     29|      buf++;
  747|     29|      length--;
  748|     29|      p->bom_strip_position++;
  749|  3.09k|    } else {
  750|  3.09k|      if (p->bom_strip_position == 0) {
  ------------------
  |  Branch (750:11): [True: 3.07k, False: 19]
  ------------------
  751|       |        // no BOM in this document
  752|  3.07k|        p->bom_strip_position = sizeof(UTF8_BOM);
  753|  3.07k|      } else {
  754|       |        // malformed BOM (prefix present, rest missing)
  755|     19|        p->bom_strip_position = 0xff;
  756|     19|      }
  757|  3.09k|    }
  758|  3.12k|  }
  759|  3.09k|  p->curr_buf = buf;
  760|  3.09k|  p->curr_buf_length = length;
  761|  3.09k|  p->curr_buf_pos = 0;
  762|  3.09k|  p->curr_buf_is_partial = is_partial;
  763|  3.09k|}
jv_parser_next:
  777|  4.66k|jv jv_parser_next(struct jv_parser* p) {
  778|  4.66k|  if (p->eof)
  ------------------
  |  Branch (778:7): [True: 806, False: 3.86k]
  ------------------
  779|    806|    return jv_invalid();
  780|  3.86k|  if (!p->curr_buf)
  ------------------
  |  Branch (780:7): [True: 0, False: 3.86k]
  ------------------
  781|      0|    return jv_invalid(); // Need a buffer
  782|  3.86k|  if (p->bom_strip_position == 0xff) {
  ------------------
  |  Branch (782:7): [True: 19, False: 3.84k]
  ------------------
  783|     19|    if (!(p->flags & JV_PARSE_SEQ))
  ------------------
  |  Branch (783:9): [True: 19, False: 0]
  ------------------
  784|     19|      return jv_invalid_with_msg(jv_string("Malformed BOM"));
  785|      0|    p->st =JV_PARSER_WAITING_FOR_RS;
  786|      0|    parser_reset(p);
  787|      0|  }
  788|  3.84k|  jv value = jv_invalid();
  789|  3.84k|  if ((p->flags & JV_PARSE_STREAMING) && stream_check_done(p, &value))
  ------------------
  |  Branch (789:7): [True: 0, False: 3.84k]
  |  Branch (789:42): [True: 0, False: 0]
  ------------------
  790|      0|    return value;
  791|  3.84k|  char ch;
  792|  3.84k|  presult msg = 0;
  793|  70.2M|  while (!msg && p->curr_buf_pos < p->curr_buf_length) {
  ------------------
  |  Branch (793:10): [True: 70.2M, False: 1.19k]
  |  Branch (793:18): [True: 70.1M, False: 2.64k]
  ------------------
  794|  70.1M|    ch = p->curr_buf[p->curr_buf_pos++];
  795|  70.1M|    if (p->st == JV_PARSER_WAITING_FOR_RS) {
  ------------------
  |  Branch (795:9): [True: 0, False: 70.1M]
  ------------------
  796|      0|      if (ch == '\n') {
  ------------------
  |  Branch (796:11): [True: 0, False: 0]
  ------------------
  797|      0|        p->line++;
  798|      0|        p->column = 0;
  799|      0|      } else {
  800|      0|        p->column++;
  801|      0|      }
  802|      0|      if (ch == '\036')
  ------------------
  |  Branch (802:11): [True: 0, False: 0]
  ------------------
  803|      0|        p->st = JV_PARSER_NORMAL;
  804|      0|      continue; // need to resync, wait for RS
  805|      0|    }
  806|  70.1M|    msg = scan(p, ch, &value);
  807|  70.1M|  }
  808|  3.84k|  if (msg == OK) {
  ------------------
  |  Branch (808:7): [True: 786, False: 3.05k]
  ------------------
  809|    786|    return value;
  810|  3.05k|  } else if (msg) {
  ------------------
  |  Branch (810:14): [True: 411, False: 2.64k]
  ------------------
  811|    411|    jv_free(value);
  812|    411|    if (ch != '\036' && (p->flags & JV_PARSE_SEQ)) {
  ------------------
  |  Branch (812:9): [True: 411, False: 0]
  |  Branch (812:25): [True: 0, False: 411]
  ------------------
  813|       |      // Skip to the next RS
  814|      0|      p->st = JV_PARSER_WAITING_FOR_RS;
  815|      0|      value = make_error(p, "%s at line %d, column %d (need RS to resync)", msg, p->line, p->column);
  816|      0|      parser_reset(p);
  817|      0|      return value;
  818|      0|    }
  819|    411|    value = make_error(p, "%s at line %d, column %d", msg, p->line, p->column);
  820|    411|    parser_reset(p);
  821|    411|    if (!(p->flags & JV_PARSE_SEQ)) {
  ------------------
  |  Branch (821:9): [True: 411, False: 0]
  ------------------
  822|       |      // We're not parsing a JSON text sequence; throw this buffer away.
  823|       |      // XXX We should fail permanently here.
  824|    411|      p->curr_buf = 0;
  825|    411|      p->curr_buf_pos = 0;
  826|    411|    } // Else ch must be RS; don't clear buf so we can start parsing again after this ch
  827|    411|    return value;
  828|  2.64k|  } else if (p->curr_buf_is_partial) {
  ------------------
  |  Branch (828:14): [True: 0, False: 2.64k]
  ------------------
  829|      0|    assert(p->curr_buf_pos == p->curr_buf_length);
  ------------------
  |  Branch (829:5): [True: 0, False: 0]
  |  Branch (829:5): [True: 0, False: 0]
  ------------------
  830|       |    // need another buffer
  831|      0|    return jv_invalid();
  832|  2.64k|  } else {
  833|       |    // at EOF
  834|  2.64k|    p->eof = 1;
  835|  2.64k|    assert(p->curr_buf_pos == p->curr_buf_length);
  ------------------
  |  Branch (835:5): [True: 0, False: 2.64k]
  |  Branch (835:5): [True: 2.64k, False: 0]
  ------------------
  836|  2.64k|    jv_free(value);
  837|  2.64k|    if (p->st == JV_PARSER_WAITING_FOR_RS)
  ------------------
  |  Branch (837:9): [True: 0, False: 2.64k]
  ------------------
  838|      0|      return make_error(p, "Unfinished abandoned text at EOF at line %d, column %d", p->line, p->column);
  839|  2.64k|    if (p->st != JV_PARSER_NORMAL) {
  ------------------
  |  Branch (839:9): [True: 101, False: 2.54k]
  ------------------
  840|    101|      value = make_error(p, "Unfinished string at EOF at line %d, column %d", p->line, p->column);
  841|    101|      parser_reset(p);
  842|    101|      p->st = JV_PARSER_WAITING_FOR_RS;
  843|    101|      return value;
  844|    101|    }
  845|  2.54k|    if ((msg = check_literal(p))) {
  ------------------
  |  Branch (845:9): [True: 700, False: 1.84k]
  ------------------
  846|    700|      value = make_error(p, "%s at EOF at line %d, column %d", msg, p->line, p->column);
  847|    700|      parser_reset(p);
  848|    700|      p->st = JV_PARSER_WAITING_FOR_RS;
  849|    700|      return value;
  850|    700|    }
  851|  1.84k|    if (((p->flags & JV_PARSE_STREAMING) && p->stacklen != 0) ||
  ------------------
  |  Branch (851:10): [True: 0, False: 1.84k]
  |  Branch (851:45): [True: 0, False: 0]
  ------------------
  852|  1.84k|        (!(p->flags & JV_PARSE_STREAMING) && p->stackpos != 0)) {
  ------------------
  |  Branch (852:10): [True: 1.84k, False: 0]
  |  Branch (852:46): [True: 739, False: 1.10k]
  ------------------
  853|    739|      value = make_error(p, "Unfinished JSON term at EOF at line %d, column %d", p->line, p->column);
  854|    739|      parser_reset(p);
  855|    739|      p->st = JV_PARSER_WAITING_FOR_RS;
  856|    739|      return value;
  857|    739|    }
  858|       |    // p->next is either invalid (nothing here, but no syntax error)
  859|       |    // or valid (this is the value). either way it's the thing to return
  860|  1.10k|    if ((p->flags & JV_PARSE_STREAMING) && jv_is_valid(p->next)) {
  ------------------
  |  Branch (860:9): [True: 0, False: 1.10k]
  |  Branch (860:44): [True: 0, False: 0]
  ------------------
  861|      0|      value = JV_ARRAY(jv_copy(p->path), p->next); // except in streaming mode we've got to make it [path,value]
  ------------------
  |  |  111|      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__)
  |  |  ------------------
  |  |  |  |  109|      0|#define JV_ARRAY_IDX(_1,_2,_3,_4,_5,_6,_7,_8,_9,NAME,...) NAME
  |  |  |  |  ------------------
  |  |  |  |  |  |  111|      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__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  101|      0|#define JV_ARRAY_2(e1,e2) (jv_array_append(JV_ARRAY_1(e1),e2))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  100|      0|#define JV_ARRAY_1(e) (jv_array_append(jv_array(),e))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  862|  1.10k|    } else {
  863|  1.10k|      value = p->next;
  864|  1.10k|    }
  865|  1.10k|    p->next = jv_invalid();
  866|  1.10k|    if ((p->flags & JV_PARSE_SEQ) && !p->last_ch_was_ws && jv_get_kind(value) == JV_KIND_NUMBER) {
  ------------------
  |  Branch (866:9): [True: 0, False: 1.10k]
  |  Branch (866:38): [True: 0, False: 0]
  |  Branch (866:60): [True: 0, False: 0]
  ------------------
  867|      0|      jv_free(value);
  868|      0|      return make_error(p, "Potentially truncated top-level numeric value at EOF at line %d, column %d", p->line, p->column);
  869|      0|    }
  870|  1.10k|    return value;
  871|  1.10k|  }
  872|  3.84k|}
jv_parse_sized_custom_flags:
  874|  3.09k|jv jv_parse_sized_custom_flags(const char* string, int length, int flags) {
  875|  3.09k|  struct jv_parser parser;
  876|  3.09k|  parser_init(&parser, flags);
  877|  3.09k|  jv_parser_set_buf(&parser, string, length, 0);
  878|  3.09k|  jv value = jv_parser_next(&parser);
  879|  3.09k|  if (jv_is_valid(value)) {
  ------------------
  |  Branch (879:7): [True: 1.57k, False: 1.52k]
  ------------------
  880|  1.57k|    jv next = jv_parser_next(&parser);
  881|  1.57k|    if (jv_is_valid(next)) {
  ------------------
  |  Branch (881:9): [True: 35, False: 1.53k]
  ------------------
  882|       |      // multiple JSON values, we only wanted one
  883|     35|      jv_free(value);
  884|     35|      jv_free(next);
  885|     35|      value = jv_invalid_with_msg(jv_string("Unexpected extra JSON values"));
  886|  1.53k|    } else if (jv_invalid_has_msg(jv_copy(next))) {
  ------------------
  |  Branch (886:16): [True: 482, False: 1.05k]
  ------------------
  887|       |      // parser error after the first JSON value
  888|    482|      jv_free(value);
  889|    482|      value = next;
  890|  1.05k|    } else {
  891|       |      // a single valid JSON value
  892|  1.05k|      jv_free(next);
  893|  1.05k|    }
  894|  1.57k|  } else if (jv_invalid_has_msg(jv_copy(value))) {
  ------------------
  |  Branch (894:14): [True: 1.48k, False: 37]
  ------------------
  895|       |    // parse error, we'll return it
  896|  1.48k|  } else {
  897|       |    // no value at all
  898|     37|    jv_free(value);
  899|     37|    value = jv_invalid_with_msg(jv_string("Expected JSON value"));
  900|     37|  }
  901|  3.09k|  parser_free(&parser);
  902|       |
  903|  3.09k|  if (!jv_is_valid(value) && jv_invalid_has_msg(jv_copy(value))) {
  ------------------
  |  Branch (903:7): [True: 2.04k, False: 1.05k]
  |  Branch (903:30): [True: 2.04k, False: 0]
  ------------------
  904|  2.04k|    jv msg = jv_invalid_get_msg(value);
  905|  2.04k|    value = jv_invalid_with_msg(jv_string_fmt("%s (while parsing '%.*s')",
  906|  2.04k|                                              jv_string_value(msg),
  907|  2.04k|                                              length,
  908|  2.04k|                                              string));
  909|  2.04k|    jv_free(msg);
  910|  2.04k|  }
  911|  3.09k|  return value;
  912|  3.09k|}
jv_parse_sized:
  914|  3.09k|jv jv_parse_sized(const char* string, int length) {
  915|  3.09k|  return jv_parse_sized_custom_flags(string, length, 0);
  916|  3.09k|}
jv_parse:
  918|  3.09k|jv jv_parse(const char* string) {
  919|  3.09k|  return jv_parse_sized(string, strlen(string));
  920|  3.09k|}
jv_parse.c:parser_init:
   70|  3.09k|static void parser_init(struct jv_parser* p, int flags) {
   71|  3.09k|  p->flags = flags;
   72|  3.09k|  if ((p->flags & JV_PARSE_STREAMING)) {
  ------------------
  |  Branch (72:7): [True: 0, False: 3.09k]
  ------------------
   73|      0|    p->path = jv_array();
   74|  3.09k|  } else {
   75|  3.09k|    p->path = jv_invalid();
   76|  3.09k|    p->flags &= ~(JV_PARSE_STREAM_ERRORS);
   77|  3.09k|  }
   78|  3.09k|  p->stack = 0;
   79|  3.09k|  p->stacklen = p->stackpos = 0;
   80|  3.09k|  p->last_seen = JV_LAST_NONE;
   81|  3.09k|  p->output = jv_invalid();
   82|  3.09k|  p->next = jv_invalid();
   83|  3.09k|  p->tokenlen = 256;
   84|  3.09k|  p->tokenbuf = jv_mem_alloc(p->tokenlen);
   85|  3.09k|  p->tokenpos = 0;
   86|  3.09k|  if ((p->flags & JV_PARSE_SEQ))
  ------------------
  |  Branch (86:7): [True: 0, False: 3.09k]
  ------------------
   87|      0|    p->st = JV_PARSER_WAITING_FOR_RS;
   88|  3.09k|  else
   89|  3.09k|    p->st = JV_PARSER_NORMAL;
   90|  3.09k|  p->eof = 0;
   91|  3.09k|  p->curr_buf = 0;
   92|  3.09k|  p->curr_buf_length = p->curr_buf_pos = p->curr_buf_is_partial = 0;
   93|  3.09k|  p->bom_strip_position = 0;
   94|  3.09k|  p->last_ch_was_ws = 0;
   95|  3.09k|  p->line = 1;
   96|  3.09k|  p->column = 0;
   97|  3.09k|  jvp_dtoa_context_init(&p->dtoa);
   98|  3.09k|}
jv_parse.c:parser_free:
  118|  3.09k|static void parser_free(struct jv_parser* p) {
  119|  3.09k|  parser_reset(p);
  120|  3.09k|  jv_free(p->path);
  121|  3.09k|  jv_free(p->output);
  122|  3.09k|  jv_mem_free(p->stack);
  123|  3.09k|  jv_mem_free(p->tokenbuf);
  124|  3.09k|  jvp_dtoa_context_free(&p->dtoa);
  125|  3.09k|}
jv_parse.c:parser_reset:
  100|  5.04k|static void parser_reset(struct jv_parser* p) {
  101|  5.04k|  if ((p->flags & JV_PARSE_STREAMING)) {
  ------------------
  |  Branch (101:7): [True: 0, False: 5.04k]
  ------------------
  102|      0|    jv_free(p->path);
  103|      0|    p->path = jv_array();
  104|      0|    p->stacklen = 0;
  105|      0|  }
  106|  5.04k|  p->last_seen = JV_LAST_NONE;
  107|  5.04k|  jv_free(p->output);
  108|  5.04k|  p->output = jv_invalid();
  109|  5.04k|  jv_free(p->next);
  110|  5.04k|  p->next = jv_invalid();
  111|   372k|  for (int i=0; i<p->stackpos; i++)
  ------------------
  |  Branch (111:17): [True: 367k, False: 5.04k]
  ------------------
  112|   367k|    jv_free(p->stack[i]);
  113|  5.04k|  p->stackpos = 0;
  114|  5.04k|  p->tokenpos = 0;
  115|  5.04k|  p->st = JV_PARSER_NORMAL;
  116|  5.04k|}
jv_parse.c:scan:
  654|  70.1M|static pfunc scan(struct jv_parser* p, char ch, jv* out) {
  655|  70.1M|  p->column++;
  656|  70.1M|  if (ch == '\n') {
  ------------------
  |  Branch (656:7): [True: 36.4k, False: 70.1M]
  ------------------
  657|  36.4k|    p->line++;
  658|  36.4k|    p->column = 0;
  659|  36.4k|  }
  660|  70.1M|  if ((p->flags & JV_PARSE_SEQ)
  ------------------
  |  Branch (660:7): [True: 0, False: 70.1M]
  ------------------
  661|      0|      && ch == '\036' /* ASCII RS; see draft-ietf-json-sequence-07 */) {
  ------------------
  |  Branch (661:10): [True: 0, False: 0]
  ------------------
  662|      0|    if (check_truncation(p)) {
  ------------------
  |  |  649|      0|   (((p)->flags & JV_PARSE_STREAMING) ? stream_seq_check_truncation((p)) : seq_check_truncation((p)))
  |  |  ------------------
  |  |  |  Branch (649:4): [True: 0, False: 0]
  |  |  |  Branch (649:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  663|      0|      if (check_literal(p) == 0 && is_top_num(p))
  ------------------
  |  |  652|      0|   (((p)->flags & JV_PARSE_STREAMING) ? stream_is_top_num((p)) : parse_is_top_num((p)))
  |  |  ------------------
  |  |  |  Branch (652:4): [True: 0, False: 0]
  |  |  |  Branch (652:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (663:11): [True: 0, False: 0]
  ------------------
  664|      0|        return "Potentially truncated top-level numeric value";
  665|      0|      return "Truncated value";
  666|      0|    }
  667|      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]
  |  |  ------------------
  ------------------
  668|      0|    if (p->st == JV_PARSER_NORMAL && check_done(p, out))
  ------------------
  |  |  643|      0|   (((p)->flags & JV_PARSE_STREAMING) ? stream_check_done((p), (o)) : parse_check_done((p), (o)))
  |  |  ------------------
  |  |  |  Branch (643:4): [True: 0, False: 0]
  |  |  |  Branch (643:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (668:9): [True: 0, False: 0]
  ------------------
  669|      0|      return OK;
  670|       |    // shouldn't happen?
  671|      0|    assert(!jv_is_valid(*out));
  ------------------
  |  Branch (671:5): [True: 0, False: 0]
  |  Branch (671:5): [True: 0, False: 0]
  ------------------
  672|      0|    parser_reset(p);
  673|      0|    jv_free(*out);
  674|      0|    *out = jv_invalid();
  675|      0|    return OK;
  676|      0|  }
  677|  70.1M|  presult answer = 0;
  678|  70.1M|  p->last_ch_was_ws = 0;
  679|  70.1M|  if (p->st == JV_PARSER_NORMAL) {
  ------------------
  |  Branch (679:7): [True: 56.5M, False: 13.6M]
  ------------------
  680|  56.5M|    chclass cls = classify(ch);
  681|  56.5M|    if (cls == WHITESPACE)
  ------------------
  |  Branch (681:9): [True: 346k, False: 56.1M]
  ------------------
  682|   346k|      p->last_ch_was_ws = 1;
  683|  56.5M|    if (cls != LITERAL) {
  ------------------
  |  Branch (683:9): [True: 6.59M, False: 49.9M]
  ------------------
  684|  6.59M|      TRY(check_literal(p));
  ------------------
  |  |   18|  6.59M|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 40, False: 6.59M]
  |  |  |  Branch (18:74): [Folded, False: 6.59M]
  |  |  ------------------
  ------------------
  685|  6.59M|      if (check_done(p, out)) answer = OK;
  ------------------
  |  |  643|  6.59M|   (((p)->flags & JV_PARSE_STREAMING) ? stream_check_done((p), (o)) : parse_check_done((p), (o)))
  |  |  ------------------
  |  |  |  Branch (643:4): [True: 375, False: 6.59M]
  |  |  |  Branch (643:5): [True: 0, False: 6.59M]
  |  |  ------------------
  ------------------
  686|  6.59M|    }
  687|  56.5M|    switch (cls) {
  ------------------
  |  Branch (687:13): [True: 56.5M, False: 0]
  ------------------
  688|  49.9M|    case LITERAL:
  ------------------
  |  Branch (688:5): [True: 49.9M, False: 6.59M]
  ------------------
  689|  49.9M|      TRY(tokenadd(p, ch));
  ------------------
  |  |   18|  49.9M|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 0, False: 49.9M]
  |  |  |  Branch (18:74): [Folded, False: 49.9M]
  |  |  ------------------
  ------------------
  690|  49.9M|      break;
  691|  49.9M|    case WHITESPACE:
  ------------------
  |  Branch (691:5): [True: 346k, False: 56.1M]
  ------------------
  692|   346k|      break;
  693|  48.4k|    case QUOTE:
  ------------------
  |  Branch (693:5): [True: 48.4k, False: 56.4M]
  ------------------
  694|  48.4k|      p->st = JV_PARSER_STRING;
  695|  48.4k|      break;
  696|  6.19M|    case STRUCTURE:
  ------------------
  |  Branch (696:5): [True: 6.19M, False: 50.3M]
  ------------------
  697|  6.19M|      TRY(token(p, ch));
  ------------------
  |  |   18|  12.3M|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:37): [True: 0, False: 6.19M]
  |  |  |  Branch (18:45): [True: 175, False: 6.19M]
  |  |  |  Branch (18:74): [Folded, False: 6.19M]
  |  |  ------------------
  ------------------
  698|  6.19M|      break;
  699|  6.19M|    case INVALID:
  ------------------
  |  Branch (699:5): [True: 0, False: 56.5M]
  ------------------
  700|      0|      return "Invalid character";
  701|  56.5M|    }
  702|  56.5M|    if (check_done(p, out)) answer = OK;
  ------------------
  |  |  643|  56.5M|   (((p)->flags & JV_PARSE_STREAMING) ? stream_check_done((p), (o)) : parse_check_done((p), (o)))
  |  |  ------------------
  |  |  |  Branch (643:4): [True: 133, False: 56.5M]
  |  |  |  Branch (643:5): [True: 0, False: 56.5M]
  |  |  ------------------
  ------------------
  703|  56.5M|  } else {
  704|  13.6M|    if (ch == '"' && p->st == JV_PARSER_STRING) {
  ------------------
  |  Branch (704:9): [True: 50.5k, False: 13.6M]
  |  Branch (704:22): [True: 48.3k, False: 2.21k]
  ------------------
  705|  48.3k|      TRY(found_string(p));
  ------------------
  |  |   18|  48.3k|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 196, False: 48.1k]
  |  |  |  Branch (18:74): [Folded, False: 48.1k]
  |  |  ------------------
  ------------------
  706|  48.1k|      p->st = JV_PARSER_NORMAL;
  707|  48.1k|      if (check_done(p, out)) answer = OK;
  ------------------
  |  |  643|  48.1k|   (((p)->flags & JV_PARSE_STREAMING) ? stream_check_done((p), (o)) : parse_check_done((p), (o)))
  |  |  ------------------
  |  |  |  Branch (643:4): [True: 284, False: 47.8k]
  |  |  |  Branch (643:5): [True: 0, False: 48.1k]
  |  |  ------------------
  ------------------
  708|  13.6M|    } else {
  709|  13.6M|      TRY(tokenadd(p, ch));
  ------------------
  |  |   18|  13.6M|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 0, False: 13.6M]
  |  |  |  Branch (18:74): [Folded, False: 13.6M]
  |  |  ------------------
  ------------------
  710|  13.6M|      if (ch == '\\' && p->st == JV_PARSER_STRING) {
  ------------------
  |  Branch (710:11): [True: 45.6k, False: 13.5M]
  |  Branch (710:25): [True: 42.8k, False: 2.78k]
  ------------------
  711|  42.8k|        p->st = JV_PARSER_STRING_ESCAPE;
  712|  13.5M|      } else {
  713|  13.5M|        p->st = JV_PARSER_STRING;
  714|  13.5M|      }
  715|  13.6M|    }
  716|  13.6M|  }
  717|  70.1M|  return answer;
  718|  70.1M|}
jv_parse.c:parse_check_done:
  593|  63.1M|static int parse_check_done(struct jv_parser* p, jv* out) {
  594|  63.1M|  if (p->stackpos == 0 && jv_is_valid(p->next)) {
  ------------------
  |  Branch (594:7): [True: 41.4M, False: 21.7M]
  |  Branch (594:27): [True: 792, False: 41.4M]
  ------------------
  595|    792|    *out = p->next;
  596|    792|    p->next = jv_invalid();
  597|    792|    return 1;
  598|  63.1M|  } else {
  599|  63.1M|    return 0;
  600|  63.1M|  }
  601|  63.1M|}
jv_parse.c:classify:
  564|  56.5M|static chclass classify(char c) {
  565|  56.5M|  switch (c) {
  566|      0|  case '\0':
  ------------------
  |  Branch (566:3): [True: 0, False: 56.5M]
  ------------------
  567|       |    // RFC 8259 forbids raw NUL in JSON text. Treating it as a literal lets it
  568|       |    // slip into the token buffer, where check_literal() reads the buffer as a
  569|       |    // NUL-terminated C string and silently truncates the token. Reject it.
  570|      0|    return INVALID;
  571|   316k|  case ' ':
  ------------------
  |  Branch (571:3): [True: 316k, False: 56.1M]
  ------------------
  572|   316k|  case '\t':
  ------------------
  |  Branch (572:3): [True: 413, False: 56.5M]
  ------------------
  573|   317k|  case '\r':
  ------------------
  |  Branch (573:3): [True: 325, False: 56.5M]
  ------------------
  574|   346k|  case '\n':
  ------------------
  |  Branch (574:3): [True: 29.0k, False: 56.4M]
  ------------------
  575|   346k|    return WHITESPACE;
  576|  48.4k|  case '"':
  ------------------
  |  Branch (576:3): [True: 48.4k, False: 56.4M]
  ------------------
  577|  48.4k|    return QUOTE;
  578|   270k|  case '[':
  ------------------
  |  Branch (578:3): [True: 270k, False: 56.2M]
  ------------------
  579|  5.90M|  case ',':
  ------------------
  |  Branch (579:3): [True: 5.63M, False: 50.8M]
  ------------------
  580|  5.91M|  case ']':
  ------------------
  |  Branch (580:3): [True: 8.65k, False: 56.4M]
  ------------------
  581|  6.08M|  case '{':
  ------------------
  |  Branch (581:3): [True: 176k, False: 56.3M]
  ------------------
  582|  6.12M|  case ':':
  ------------------
  |  Branch (582:3): [True: 38.7k, False: 56.4M]
  ------------------
  583|  6.19M|  case '}':
  ------------------
  |  Branch (583:3): [True: 70.9k, False: 56.4M]
  ------------------
  584|  6.19M|    return STRUCTURE;
  585|  49.9M|  default:
  ------------------
  |  Branch (585:3): [True: 49.9M, False: 6.59M]
  ------------------
  586|  49.9M|    return LITERAL;
  587|  56.5M|  }
  588|  56.5M|}
jv_parse.c:tokenadd:
  423|  63.5M|static pfunc tokenadd(struct jv_parser* p, char c) {
  424|  63.5M|  assert(p->tokenpos <= p->tokenlen);
  ------------------
  |  Branch (424:3): [True: 0, False: 63.5M]
  |  Branch (424:3): [True: 63.5M, False: 0]
  ------------------
  425|  63.5M|  if (p->tokenpos >= (p->tokenlen - 1)) {
  ------------------
  |  Branch (425:7): [True: 2.65k, False: 63.5M]
  ------------------
  426|  2.65k|    if (p->tokenlen > INT_MAX / 2)
  ------------------
  |  Branch (426:9): [True: 0, False: 2.65k]
  ------------------
  427|      0|      return "Token too long";
  428|  2.65k|    p->tokenlen *= 2;
  429|  2.65k|    p->tokenbuf = jv_mem_realloc(p->tokenbuf, p->tokenlen);
  430|  2.65k|  }
  431|  63.5M|  assert(p->tokenpos < p->tokenlen);
  ------------------
  |  Branch (431:3): [True: 0, False: 63.5M]
  |  Branch (431:3): [True: 63.5M, False: 0]
  ------------------
  432|  63.5M|  p->tokenbuf[p->tokenpos++] = c;
  433|  63.5M|  return 0;
  434|  63.5M|}
jv_parse.c:parse_token:
  158|  6.19M|static pfunc parse_token(struct jv_parser* p, char ch) {
  159|  6.19M|  switch (ch) {
  ------------------
  |  Branch (159:11): [True: 6.19M, False: 0]
  ------------------
  160|   270k|  case '[':
  ------------------
  |  Branch (160:3): [True: 270k, False: 5.92M]
  ------------------
  161|   270k|    if (p->stackpos >= MAX_PARSING_DEPTH) return "Exceeds depth limit for parsing";
  ------------------
  |  |   15|   270k|#define MAX_PARSING_DEPTH (10000)
  ------------------
  |  Branch (161:9): [True: 1, False: 270k]
  ------------------
  162|   270k|    if (jv_is_valid(p->next)) return "Expected separator between values";
  ------------------
  |  Branch (162:9): [True: 11, False: 270k]
  ------------------
  163|   270k|    push(p, jv_array());
  164|   270k|    break;
  165|       |
  166|   176k|  case '{':
  ------------------
  |  Branch (166:3): [True: 176k, False: 6.02M]
  ------------------
  167|   176k|    if (p->stackpos >= MAX_PARSING_DEPTH) return "Exceeds depth limit for parsing";
  ------------------
  |  |   15|   176k|#define MAX_PARSING_DEPTH (10000)
  ------------------
  |  Branch (167:9): [True: 1, False: 176k]
  ------------------
  168|   176k|    if (jv_is_valid(p->next)) return "Expected separator between values";
  ------------------
  |  Branch (168:9): [True: 6, False: 176k]
  ------------------
  169|   176k|    push(p, jv_object());
  170|   176k|    break;
  171|       |
  172|  38.7k|  case ':':
  ------------------
  |  Branch (172:3): [True: 38.7k, False: 6.16M]
  ------------------
  173|  38.7k|    if (!jv_is_valid(p->next))
  ------------------
  |  Branch (173:9): [True: 12, False: 38.6k]
  ------------------
  174|     12|      return "Expected string key before ':'";
  175|  38.6k|    if (p->stackpos == 0 || jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_OBJECT)
  ------------------
  |  Branch (175:9): [True: 0, False: 38.6k]
  |  Branch (175:29): [True: 7, False: 38.6k]
  ------------------
  176|      7|      return "':' not as part of an object";
  177|  38.6k|    if (jv_get_kind(p->next) != JV_KIND_STRING)
  ------------------
  |  Branch (177:9): [True: 7, False: 38.6k]
  ------------------
  178|      7|      return "Object keys must be strings";
  179|  38.6k|    push(p, p->next);
  180|  38.6k|    p->next = jv_invalid();
  181|  38.6k|    break;
  182|       |
  183|  5.63M|  case ',':
  ------------------
  |  Branch (183:3): [True: 5.63M, False: 564k]
  ------------------
  184|  5.63M|    if (!jv_is_valid(p->next))
  ------------------
  |  Branch (184:9): [True: 13, False: 5.63M]
  ------------------
  185|     13|      return "Expected value before ','";
  186|  5.63M|    if (p->stackpos == 0)
  ------------------
  |  Branch (186:9): [True: 0, False: 5.63M]
  ------------------
  187|      0|      return "',' not as part of an object or array";
  188|  5.63M|    if (jv_get_kind(p->stack[p->stackpos-1]) == JV_KIND_ARRAY) {
  ------------------
  |  Branch (188:9): [True: 5.60M, False: 30.4k]
  ------------------
  189|  5.60M|      p->stack[p->stackpos-1] = jv_array_append(p->stack[p->stackpos-1], p->next);
  190|  5.60M|      p->next = jv_invalid();
  191|  5.60M|    } else if (jv_get_kind(p->stack[p->stackpos-1]) == JV_KIND_STRING) {
  ------------------
  |  Branch (191:16): [True: 30.4k, False: 6]
  ------------------
  192|  30.4k|      assert(p->stackpos > 1 && jv_get_kind(p->stack[p->stackpos-2]) == JV_KIND_OBJECT);
  ------------------
  |  Branch (192:7): [True: 0, False: 30.4k]
  |  Branch (192:7): [True: 0, False: 0]
  |  Branch (192:7): [True: 30.4k, False: 0]
  |  Branch (192:7): [True: 30.4k, False: 0]
  ------------------
  193|  30.4k|      p->stack[p->stackpos-2] = jv_object_set(p->stack[p->stackpos-2],
  194|  30.4k|                                              p->stack[p->stackpos-1], p->next);
  195|  30.4k|      p->stackpos--;
  196|  30.4k|      p->next = jv_invalid();
  197|  30.4k|    } else {
  198|       |      // this case hits on input like {"a", "b"}
  199|      6|      return "Objects must consist of key:value pairs";
  200|      6|    }
  201|  5.63M|    break;
  202|       |
  203|  5.63M|  case ']':
  ------------------
  |  Branch (203:3): [True: 8.65k, False: 6.19M]
  ------------------
  204|  8.65k|    if (p->stackpos == 0 || jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_ARRAY)
  ------------------
  |  Branch (204:9): [True: 12, False: 8.64k]
  |  Branch (204:29): [True: 16, False: 8.62k]
  ------------------
  205|     28|      return "Unmatched ']'";
  206|  8.62k|    if (jv_is_valid(p->next)) {
  ------------------
  |  Branch (206:9): [True: 1.38k, False: 7.24k]
  ------------------
  207|  1.38k|      p->stack[p->stackpos-1] = jv_array_append(p->stack[p->stackpos-1], p->next);
  208|  1.38k|      p->next = jv_invalid();
  209|  7.24k|    } else {
  210|  7.24k|      if (jv_array_length(jv_copy(p->stack[p->stackpos-1])) != 0) {
  ------------------
  |  Branch (210:11): [True: 38, False: 7.20k]
  ------------------
  211|       |        // this case hits on input like [1,2,3,]
  212|     38|        return "Expected another array element";
  213|     38|      }
  214|  7.24k|    }
  215|  8.58k|    jv_free(p->next);
  216|  8.58k|    p->next = p->stack[--p->stackpos];
  217|  8.58k|    break;
  218|       |
  219|  70.9k|  case '}':
  ------------------
  |  Branch (219:3): [True: 70.9k, False: 6.12M]
  ------------------
  220|  70.9k|    if (p->stackpos == 0)
  ------------------
  |  Branch (220:9): [True: 5, False: 70.9k]
  ------------------
  221|      5|      return "Unmatched '}'";
  222|  70.9k|    if (jv_is_valid(p->next)) {
  ------------------
  |  Branch (222:9): [True: 7.07k, False: 63.8k]
  ------------------
  223|  7.07k|      if (jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_STRING)
  ------------------
  |  Branch (223:11): [True: 11, False: 7.06k]
  ------------------
  224|     11|        return "Objects must consist of key:value pairs";
  225|  7.07k|      assert(p->stackpos > 1 && jv_get_kind(p->stack[p->stackpos-2]) == JV_KIND_OBJECT);
  ------------------
  |  Branch (225:7): [True: 0, False: 7.06k]
  |  Branch (225:7): [True: 0, False: 0]
  |  Branch (225:7): [True: 7.06k, False: 0]
  |  Branch (225:7): [True: 7.06k, False: 0]
  ------------------
  226|  7.06k|      p->stack[p->stackpos-2] = jv_object_set(p->stack[p->stackpos-2],
  227|  7.06k|                                              p->stack[p->stackpos-1], p->next);
  228|  7.06k|      p->stackpos--;
  229|  7.06k|      p->next = jv_invalid();
  230|  63.8k|    } else {
  231|  63.8k|      if (jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_OBJECT)
  ------------------
  |  Branch (231:11): [True: 11, False: 63.8k]
  ------------------
  232|     11|        return "Unmatched '}'";
  233|  63.8k|      if (jv_object_length(jv_copy(p->stack[p->stackpos-1])) != 0)
  ------------------
  |  Branch (233:11): [True: 18, False: 63.8k]
  ------------------
  234|     18|        return "Expected another key-value pair";
  235|  63.8k|    }
  236|  70.9k|    jv_free(p->next);
  237|  70.9k|    p->next = p->stack[--p->stackpos];
  238|  70.9k|    break;
  239|  6.19M|  }
  240|  6.19M|  return 0;
  241|  6.19M|}
jv_parse.c:push:
  148|   484k|static void push(struct jv_parser* p, jv v) {
  149|   484k|  assert(p->stackpos <= p->stacklen);
  ------------------
  |  Branch (149:3): [True: 0, False: 484k]
  |  Branch (149:3): [True: 484k, False: 0]
  ------------------
  150|   484k|  if (p->stackpos == p->stacklen) {
  ------------------
  |  Branch (150:7): [True: 2.20k, False: 482k]
  ------------------
  151|  2.20k|    p->stacklen = p->stacklen * 2 + 10;
  152|  2.20k|    p->stack = jv_mem_realloc(p->stack, p->stacklen * sizeof(jv));
  153|  2.20k|  }
  154|   484k|  assert(p->stackpos < p->stacklen);
  ------------------
  |  Branch (154:3): [True: 0, False: 484k]
  |  Branch (154:3): [True: 484k, False: 0]
  ------------------
  155|   484k|  p->stack[p->stackpos++] = v;
  156|   484k|}
jv_parse.c:found_string:
  451|  48.3k|static pfunc found_string(struct jv_parser* p) {
  452|  48.3k|  char* in = p->tokenbuf;
  453|  48.3k|  char* out = p->tokenbuf;
  454|  48.3k|  char* end = p->tokenbuf + p->tokenpos;
  455|       |
  456|  4.60M|  while (in < end) {
  ------------------
  |  Branch (456:10): [True: 4.55M, False: 48.1k]
  ------------------
  457|  4.55M|    char c = *in++;
  458|  4.55M|    if (c == '\\') {
  ------------------
  |  Branch (458:9): [True: 11.6k, False: 4.54M]
  ------------------
  459|  11.6k|      if (in >= end)
  ------------------
  |  Branch (459:11): [True: 0, False: 11.6k]
  ------------------
  460|      0|        return "Expected escape character at end of string";
  461|  11.6k|      c = *in++;
  462|  11.6k|      switch (c) {
  463|  1.66k|      case '\\':
  ------------------
  |  Branch (463:7): [True: 1.66k, False: 9.94k]
  ------------------
  464|  2.81k|      case '"':
  ------------------
  |  Branch (464:7): [True: 1.14k, False: 10.4k]
  ------------------
  465|  3.52k|      case '/': *out++ = c;    break;
  ------------------
  |  Branch (465:7): [True: 711, False: 10.9k]
  ------------------
  466|  2.31k|      case 'b': *out++ = '\b'; break;
  ------------------
  |  Branch (466:7): [True: 2.31k, False: 9.29k]
  ------------------
  467|    246|      case 'f': *out++ = '\f'; break;
  ------------------
  |  Branch (467:7): [True: 246, False: 11.3k]
  ------------------
  468|  1.78k|      case 't': *out++ = '\t'; break;
  ------------------
  |  Branch (468:7): [True: 1.78k, False: 9.82k]
  ------------------
  469|    557|      case 'n': *out++ = '\n'; break;
  ------------------
  |  Branch (469:7): [True: 557, False: 11.0k]
  ------------------
  470|    248|      case 'r': *out++ = '\r'; break;
  ------------------
  |  Branch (470:7): [True: 248, False: 11.3k]
  ------------------
  471|       |
  472|  2.93k|      case 'u':
  ------------------
  |  Branch (472:7): [True: 2.93k, False: 8.67k]
  ------------------
  473|       |        /* ahh, the complicated case */
  474|  2.93k|        if (in + 4 > end)
  ------------------
  |  Branch (474:13): [True: 3, False: 2.93k]
  ------------------
  475|      3|          return "Invalid \\uXXXX escape";
  476|  2.93k|        int hexvalue = unhex4(in);
  477|  2.93k|        if (hexvalue < 0)
  ------------------
  |  Branch (477:13): [True: 21, False: 2.90k]
  ------------------
  478|     21|          return "Invalid characters in \\uXXXX escape";
  479|  2.90k|        unsigned long codepoint = (unsigned long)hexvalue;
  480|  2.90k|        in += 4;
  481|  2.90k|        if (0xD800 <= codepoint && codepoint <= 0xDBFF) {
  ------------------
  |  Branch (481:13): [True: 1.52k, False: 1.38k]
  |  Branch (481:36): [True: 501, False: 1.01k]
  ------------------
  482|       |          /* who thought UTF-16 surrogate pairs were a good idea? */
  483|    501|          if (in + 6 > end || in[0] != '\\' || in[1] != 'u')
  ------------------
  |  Branch (483:15): [True: 15, False: 486]
  |  Branch (483:31): [True: 11, False: 475]
  |  Branch (483:48): [True: 11, False: 464]
  ------------------
  484|     37|            return "Invalid \\uXXXX\\uXXXX surrogate pair escape";
  485|    464|          unsigned long surrogate = unhex4(in+2);
  486|    464|          if (!(0xDC00 <= surrogate && surrogate <= 0xDFFF))
  ------------------
  |  Branch (486:17): [True: 442, False: 22]
  |  Branch (486:40): [True: 413, False: 29]
  ------------------
  487|     51|            return "Invalid \\uXXXX\\uXXXX surrogate pair escape";
  488|    413|          in += 6;
  489|    413|          codepoint = 0x10000 + (((codepoint - 0xD800) << 10)
  490|    413|                                 |(surrogate - 0xDC00));
  491|    413|        }
  492|  2.82k|        if (codepoint > 0x10FFFF)
  ------------------
  |  Branch (492:13): [True: 0, False: 2.82k]
  ------------------
  493|      0|          codepoint = 0xFFFD; // U+FFFD REPLACEMENT CHARACTER
  494|  2.82k|        out += jvp_utf8_encode(codepoint, out);
  495|  2.82k|        break;
  496|       |
  497|      1|      default:
  ------------------
  |  Branch (497:7): [True: 1, False: 11.6k]
  ------------------
  498|      1|        return "Invalid escape";
  499|  11.6k|      }
  500|  4.54M|    } else {
  501|  4.54M|      if (!(c & ~0x1F))
  ------------------
  |  Branch (501:11): [True: 62, False: 4.54M]
  ------------------
  502|     62|        return "Invalid string: control characters from U+0000 through U+001F must be escaped";
  503|  4.54M|      *out++ = c;
  504|  4.54M|    }
  505|  4.55M|  }
  506|  48.1k|  TRY(value(p, jv_string_sized(p->tokenbuf, out - p->tokenbuf)));
  ------------------
  |  |   18|  48.1k|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 21, False: 48.1k]
  |  |  |  Branch (18:74): [Folded, False: 48.1k]
  |  |  ------------------
  ------------------
  507|  48.1k|  p->tokenpos = 0;
  508|  48.1k|  return 0;
  509|  48.1k|}
jv_parse.c:unhex4:
  436|  3.39k|static int unhex4(char* hex) {
  437|  3.39k|  int r = 0;
  438|  16.8k|  for (int i=0; i<4; i++) {
  ------------------
  |  Branch (438:17): [True: 13.4k, False: 3.34k]
  ------------------
  439|  13.4k|    char c = *hex++;
  440|  13.4k|    int n;
  441|  13.4k|    if ('0' <= c && c <= '9') n = c - '0';
  ------------------
  |  Branch (441:9): [True: 13.4k, False: 22]
  |  Branch (441:21): [True: 6.72k, False: 6.74k]
  ------------------
  442|  6.76k|    else if ('a' <= c && c <= 'f') n = c - 'a' + 10;
  ------------------
  |  Branch (442:14): [True: 4.75k, False: 2.01k]
  |  Branch (442:26): [True: 4.74k, False: 7]
  ------------------
  443|  2.02k|    else if ('A' <= c && c <= 'F') n = c - 'A' + 10;
  ------------------
  |  Branch (443:14): [True: 1.99k, False: 29]
  |  Branch (443:26): [True: 1.97k, False: 18]
  ------------------
  444|     47|    else return -1;
  445|  13.4k|    r <<= 4;
  446|  13.4k|    r |= n;
  447|  13.4k|  }
  448|  3.34k|  return r;
  449|  3.39k|}
jv_parse.c:value:
  127|  5.60M|static pfunc value(struct jv_parser* p, jv val) {
  128|  5.60M|  if ((p->flags & JV_PARSE_STREAMING)) {
  ------------------
  |  Branch (128:7): [True: 0, False: 5.60M]
  ------------------
  129|      0|    if (jv_is_valid(p->next) || p->last_seen == JV_LAST_VALUE) {
  ------------------
  |  Branch (129:9): [True: 0, False: 0]
  |  Branch (129:33): [True: 0, False: 0]
  ------------------
  130|      0|      jv_free(val);
  131|      0|      return "Expected separator between values";
  132|      0|    }
  133|      0|    if (p->stacklen > 0)
  ------------------
  |  Branch (133:9): [True: 0, False: 0]
  ------------------
  134|      0|      p->last_seen = JV_LAST_VALUE;
  135|      0|    else
  136|      0|      p->last_seen = JV_LAST_NONE;
  137|  5.60M|  } else {
  138|  5.60M|    if (jv_is_valid(p->next)) {
  ------------------
  |  Branch (138:9): [True: 36, False: 5.60M]
  ------------------
  139|     36|      jv_free(val);
  140|     36|      return "Expected separator between values";
  141|     36|    }
  142|  5.60M|  }
  143|  5.60M|  jv_free(p->next);
  144|  5.60M|  p->next = val;
  145|  5.60M|  return 0;
  146|  5.60M|}
jv_parse.c:make_error:
  767|  1.95k|static jv make_error(struct jv_parser* p, const char *fmt, ...) {
  768|  1.95k|  va_list ap;
  769|  1.95k|  va_start(ap, fmt);
  770|  1.95k|  jv e = jv_string_vfmt(fmt, ap);
  771|  1.95k|  va_end(ap);
  772|  1.95k|  if ((p->flags & JV_PARSE_STREAM_ERRORS))
  ------------------
  |  Branch (772:7): [True: 0, False: 1.95k]
  ------------------
  773|      0|    return JV_ARRAY(e, jv_copy(p->path));
  ------------------
  |  |  111|      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__)
  |  |  ------------------
  |  |  |  |  109|      0|#define JV_ARRAY_IDX(_1,_2,_3,_4,_5,_6,_7,_8,_9,NAME,...) NAME
  |  |  |  |  ------------------
  |  |  |  |  |  |  111|      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__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  101|      0|#define JV_ARRAY_2(e1,e2) (jv_array_append(JV_ARRAY_1(e1),e2))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  100|      0|#define JV_ARRAY_1(e) (jv_array_append(jv_array(),e))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  774|  1.95k|  return jv_invalid_with_msg(e);
  775|  1.95k|}
jv_parse.c:check_literal:
  511|  6.59M|static pfunc check_literal(struct jv_parser* p) {
  512|  6.59M|  if (p->tokenpos == 0) return 0;
  ------------------
  |  Branch (512:7): [True: 1.03M, False: 5.55M]
  ------------------
  513|       |
  514|  5.55M|  const char* pattern = 0;
  515|  5.55M|  int plen;
  516|  5.55M|  jv v;
  517|  5.55M|  switch (p->tokenbuf[0]) {
  ------------------
  |  Branch (517:11): [True: 1.86k, False: 5.55M]
  ------------------
  518|    406|  case 't': pattern = "true"; plen = 4; v = jv_true(); break;
  ------------------
  |  Branch (518:3): [True: 406, False: 5.55M]
  ------------------
  519|    260|  case 'f': pattern = "false"; plen = 5; v = jv_false(); break;
  ------------------
  |  Branch (519:3): [True: 260, False: 5.55M]
  ------------------
  520|      8|  case '\'':
  ------------------
  |  Branch (520:3): [True: 8, False: 5.55M]
  ------------------
  521|      8|    return "Invalid string literal; expected \", but got '";
  522|  1.18k|  case 'n':
  ------------------
  |  Branch (522:3): [True: 1.18k, False: 5.55M]
  ------------------
  523|       |    // if it starts with 'n', it could be a literal "nan"
  524|  1.18k|    if (p->tokenpos > 1 && p->tokenbuf[1] == 'u') {
  ------------------
  |  Branch (524:9): [True: 1.18k, False: 7]
  |  Branch (524:28): [True: 258, False: 923]
  ------------------
  525|    258|      pattern = "null"; plen = 4; v = jv_null();
  526|    258|    }
  527|  5.55M|  }
  528|  5.55M|  if (pattern) {
  ------------------
  |  Branch (528:7): [True: 924, False: 5.55M]
  ------------------
  529|    924|    if (p->tokenpos != plen) return "Invalid literal";
  ------------------
  |  Branch (529:9): [True: 73, False: 851]
  ------------------
  530|  4.45k|    for (int i=0; i<plen; i++)
  ------------------
  |  Branch (530:19): [True: 3.62k, False: 838]
  ------------------
  531|  3.62k|      if (p->tokenbuf[i] != pattern[i])
  ------------------
  |  Branch (531:11): [True: 13, False: 3.60k]
  ------------------
  532|     13|        return "Invalid literal";
  533|    838|    TRY(value(p, v));
  ------------------
  |  |   18|    838|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 3, False: 835]
  |  |  |  Branch (18:74): [Folded, False: 835]
  |  |  ------------------
  ------------------
  534|  5.55M|  } else {
  535|       |    // FIXME: better parser
  536|  5.55M|    p->tokenbuf[p->tokenpos] = 0;
  537|  5.55M|#ifdef USE_DECNUM
  538|  5.55M|    jv number = jv_number_with_literal(p->tokenbuf);
  539|  5.55M|    if (jv_get_kind(number) == JV_KIND_INVALID) {
  ------------------
  |  Branch (539:9): [True: 631, False: 5.55M]
  ------------------
  540|    631|      return "Invalid numeric literal";
  541|    631|    }
  542|  5.55M|    TRY(value(p, number));
  ------------------
  |  |   18|  5.55M|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 12, False: 5.55M]
  |  |  |  Branch (18:74): [Folded, False: 5.55M]
  |  |  ------------------
  ------------------
  543|       |#else
  544|       |    char *end = 0;
  545|       |    double d = jvp_strtod(&p->dtoa, p->tokenbuf, &end);
  546|       |    if (end == 0 || *end != 0) {
  547|       |      return "Invalid numeric literal";
  548|       |    }
  549|       |    TRY(value(p, jv_number(d)));
  550|       |#endif
  551|  5.55M|  }
  552|  5.55M|  p->tokenpos = 0;
  553|  5.55M|  return 0;
  554|  5.55M|}

jvp_utf8_next:
   30|  58.4M|const char* jvp_utf8_next(const char* in, const char* end, int* codepoint_ret) {
   31|  58.4M|  assert(in <= end);
  ------------------
  |  Branch (31:3): [True: 0, False: 58.4M]
  |  Branch (31:3): [True: 58.4M, False: 0]
  ------------------
   32|  58.4M|  if (in == end) {
  ------------------
  |  Branch (32:7): [True: 52.2k, False: 58.3M]
  ------------------
   33|  52.2k|    return 0;
   34|  52.2k|  }
   35|  58.3M|  int codepoint = -1;
   36|  58.3M|  unsigned char first = (unsigned char)in[0];
   37|  58.3M|  int length = utf8_coding_length[first];
   38|  58.3M|  if ((first & 0x80) == 0) {
  ------------------
  |  Branch (38:7): [True: 54.1M, False: 4.27M]
  ------------------
   39|       |    /* Fast-path for ASCII */
   40|  54.1M|    codepoint = first;
   41|  54.1M|    length = 1;
   42|  54.1M|  } else if (length == 0 || length == UTF8_CONTINUATION_BYTE) {
  ------------------
  |  |    1|  3.49M|#define UTF8_CONTINUATION_BYTE ((unsigned char)255)
  ------------------
  |  Branch (42:14): [True: 783k, False: 3.49M]
  |  Branch (42:29): [True: 3.11M, False: 377k]
  ------------------
   43|       |    /* Bad single byte - either an invalid byte or an out-of-place continuation byte */
   44|  3.90M|    length = 1;
   45|  3.90M|  } else if (length > end - in) {
  ------------------
  |  Branch (45:14): [True: 1.68k, False: 376k]
  ------------------
   46|       |    /* String ends before UTF8 sequence ends */
   47|  1.68k|    length = end - in;
   48|   376k|  } else {
   49|   376k|    codepoint = ((unsigned)in[0]) & utf8_coding_bits[first];
   50|   397k|    for (int i=1; i<length; i++) {
  ------------------
  |  Branch (50:19): [True: 388k, False: 8.67k]
  ------------------
   51|   388k|      unsigned ch = (unsigned char)in[i];
   52|   388k|      if (utf8_coding_length[ch] != UTF8_CONTINUATION_BYTE){
  ------------------
  |  |    1|   388k|#define UTF8_CONTINUATION_BYTE ((unsigned char)255)
  ------------------
  |  Branch (52:11): [True: 367k, False: 20.9k]
  ------------------
   53|       |        /* Invalid UTF8 sequence - not followed by the right number of continuation bytes */
   54|   367k|        codepoint = -1;
   55|   367k|        length = i;
   56|   367k|        break;
   57|   367k|      }
   58|  20.9k|      codepoint = (codepoint << 6) | (ch & 0x3f);
   59|  20.9k|    }
   60|   376k|    if (codepoint < utf8_first_codepoint[length]) {
  ------------------
  |  Branch (60:9): [True: 367k, False: 8.67k]
  ------------------
   61|       |      /* Overlong UTF8 sequence */
   62|   367k|      codepoint = -1;
   63|   367k|    }
   64|   376k|    if (0xD800 <= codepoint && codepoint <= 0xDFFF) {
  ------------------
  |  Branch (64:9): [True: 6.24k, False: 369k]
  |  Branch (64:32): [True: 486, False: 5.75k]
  ------------------
   65|       |      /* Surrogate codepoints can't be encoded in UTF8 */
   66|    486|      codepoint = -1;
   67|    486|    }
   68|   376k|    if (codepoint > 0x10FFFF) {
  ------------------
  |  Branch (68:9): [True: 201, False: 375k]
  ------------------
   69|       |      /* Outside Unicode range */
   70|    201|      codepoint = -1;
   71|    201|    }
   72|   376k|  }
   73|  58.3M|  assert(length > 0);
  ------------------
  |  Branch (73:3): [True: 0, False: 58.3M]
  |  Branch (73:3): [True: 58.3M, False: 0]
  ------------------
   74|  58.3M|  *codepoint_ret = codepoint;
   75|  58.3M|  return in + length;
   76|  58.3M|}
jvp_utf8_is_valid:
   78|  52.2k|int jvp_utf8_is_valid(const char* in, const char* end) {
   79|  52.2k|  int codepoint;
   80|  22.7M|  while ((in = jvp_utf8_next(in, end, &codepoint))) {
  ------------------
  |  Branch (80:10): [True: 22.7M, False: 48.4k]
  ------------------
   81|  22.7M|    if (codepoint == -1) return 0;
  ------------------
  |  Branch (81:9): [True: 3.77k, False: 22.7M]
  ------------------
   82|  22.7M|  }
   83|  48.4k|  return 1;
   84|  52.2k|}
jvp_utf8_encode_length:
   94|  35.6M|int jvp_utf8_encode_length(int codepoint) {
   95|  35.6M|  if (codepoint <= 0x7F) return 1;
  ------------------
  |  Branch (95:7): [True: 31.3M, False: 4.27M]
  ------------------
   96|  4.27M|  else if (codepoint <= 0x7FF) return 2;
  ------------------
  |  Branch (96:12): [True: 1.39k, False: 4.27M]
  ------------------
   97|  4.27M|  else if (codepoint <= 0xFFFF) return 3;
  ------------------
  |  Branch (97:12): [True: 4.26M, False: 4.45k]
  ------------------
   98|  4.45k|  else return 4;
   99|  35.6M|}
jvp_utf8_encode:
  101|  35.6M|int jvp_utf8_encode(int codepoint, char* out) {
  102|  35.6M|  assert(codepoint >= 0 && codepoint <= 0x10FFFF);
  ------------------
  |  Branch (102:3): [True: 0, False: 35.6M]
  |  Branch (102:3): [True: 0, False: 0]
  |  Branch (102:3): [True: 35.6M, False: 0]
  |  Branch (102:3): [True: 35.6M, False: 0]
  ------------------
  103|  35.6M|  char* start = out;
  104|  35.6M|  if (codepoint <= 0x7F) {
  ------------------
  |  Branch (104:7): [True: 31.3M, False: 4.27M]
  ------------------
  105|  31.3M|    *out++ = codepoint;
  106|  31.3M|  } else if (codepoint <= 0x7FF) {
  ------------------
  |  Branch (106:14): [True: 1.39k, False: 4.27M]
  ------------------
  107|  1.39k|    *out++ = 0xC0 + ((codepoint & 0x7C0) >> 6);
  108|  1.39k|    *out++ = 0x80 + ((codepoint & 0x03F));
  109|  4.27M|  } else if(codepoint <= 0xFFFF) {
  ------------------
  |  Branch (109:13): [True: 4.26M, False: 4.45k]
  ------------------
  110|  4.26M|    *out++ = 0xE0 + ((codepoint & 0xF000) >> 12);
  111|  4.26M|    *out++ = 0x80 + ((codepoint & 0x0FC0) >> 6);
  112|  4.26M|    *out++ = 0x80 + ((codepoint & 0x003F));
  113|  4.26M|  } else {
  114|  4.45k|    *out++ = 0xF0 + ((codepoint & 0x1C0000) >> 18);
  115|  4.45k|    *out++ = 0x80 + ((codepoint & 0x03F000) >> 12);
  116|  4.45k|    *out++ = 0x80 + ((codepoint & 0x000FC0) >> 6);
  117|  4.45k|    *out++ = 0x80 + ((codepoint & 0x00003F));
  118|  4.45k|  }
  119|  35.6M|  assert(out - start == jvp_utf8_encode_length(codepoint));
  ------------------
  |  Branch (119:3): [True: 0, False: 35.6M]
  |  Branch (119:3): [True: 35.6M, False: 0]
  ------------------
  120|  35.6M|  return out - start;
  121|  35.6M|}

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

decContextClearStatus:
   54|  5.55M|decContext *decContextClearStatus(decContext *context, uInt mask) {
   55|  5.55M|  context->status&=~mask;
   56|  5.55M|  return context;
   57|  5.55M|  } // 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|  25.2k|decContext * decContextSetStatus(decContext *context, uInt status) {
  212|  25.2k|  context->status|=status;
  213|  25.2k|  if (status & context->traps) raise(SIGFPE);
  ------------------
  |  Branch (213:7): [True: 0, False: 25.2k]
  ------------------
  214|  25.2k|  return context;} // decContextSetStatus

decNumberFromString:
  479|  5.55M|                                decContext *set) {
  480|  5.55M|  Int   exponent=0;                // working exponent [assume 0]
  ------------------
  |  |   92|  5.55M|  #define Int    int32_t
  ------------------
  481|  5.55M|  uByte bits=0;                    // working flags [assume +ve]
  ------------------
  |  |   89|  5.55M|  #define uByte  uint8_t
  ------------------
  482|  5.55M|  Unit  *res;                      // where result will be built
  ------------------
  |  |   94|  5.55M|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  5.55M|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
  483|  5.55M|  Unit  resbuff[SD2U(DECBUFFER+9)];// local buffer in case need temporary
  ------------------
  |  |   94|  5.55M|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  5.55M|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
  484|       |                                   // [+9 allows for ln() constants]
  485|  5.55M|  Unit  *allocres=NULL;            // -> allocated result, iff allocated
  ------------------
  |  |   94|  5.55M|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  5.55M|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
  486|  5.55M|  Int   d=0;                       // count of digits found in decimal part
  ------------------
  |  |   92|  5.55M|  #define Int    int32_t
  ------------------
  487|  5.55M|  const char *dotchar=NULL;        // where dot was found
  488|  5.55M|  const char *cfirst=chars;        // -> first character of decimal part
  489|  5.55M|  const char *last=NULL;           // -> last digit of decimal part
  490|  5.55M|  const char *c;                   // work
  491|  5.55M|  Unit  *up;                       // ..
  ------------------
  |  |   94|  5.55M|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  5.55M|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
  492|  5.55M|  #if DECDPUN>1
  493|  5.55M|  Int   cut, out;                  // ..
  ------------------
  |  |   92|  5.55M|  #define Int    int32_t
  ------------------
  494|  5.55M|  #endif
  495|  5.55M|  Int   residue;                   // rounding residue
  ------------------
  |  |   92|  5.55M|  #define Int    int32_t
  ------------------
  496|  5.55M|  uInt  status=0;                  // error code
  ------------------
  |  |   93|  5.55M|  #define uInt   uint32_t
  ------------------
  497|       |
  498|       |  #if DECCHECK
  499|       |  if (decCheckOperands(DECUNRESU, DECUNUSED, DECUNUSED, set))
  500|       |    return decNumberZero(dn);
  501|       |  #endif
  502|       |
  503|  5.55M|  do {                             // status & malloc protection
  504|  35.1M|    for (c=chars;; c++) {          // -> input character
  505|  35.1M|      if (*c>='0' && *c<='9') {    // test for Arabic digit
  ------------------
  |  Branch (505:11): [True: 29.5M, False: 5.53M]
  |  Branch (505:22): [True: 29.5M, False: 34.9k]
  ------------------
  506|  29.5M|        last=c;
  507|  29.5M|        d++;                       // count of real digits
  508|  29.5M|        continue;                  // still in decimal part
  509|  29.5M|        }
  510|  5.57M|      if (*c=='.' && dotchar==NULL) { // first '.'
  ------------------
  |  Branch (510:11): [True: 8.95k, False: 5.56M]
  |  Branch (510:22): [True: 8.95k, False: 1]
  ------------------
  511|  8.95k|        dotchar=c;                 // record offset into decimal part
  512|  8.95k|        if (c==cfirst) cfirst++;   // first digit must follow
  ------------------
  |  Branch (512:13): [True: 990, False: 7.96k]
  ------------------
  513|  8.95k|        continue;}
  514|  5.56M|      if (c==chars) {              // first in string...
  ------------------
  |  Branch (514:11): [True: 9.37k, False: 5.55M]
  ------------------
  515|  9.37k|        if (*c=='-') {             // valid - sign
  ------------------
  |  Branch (515:13): [True: 357, False: 9.01k]
  ------------------
  516|    357|          cfirst++;
  517|    357|          bits=DECNEG;
  ------------------
  |  |   31|    357|  #define DECNEG    0x80      /* Sign; 1=negative, 0=positive or zero */
  ------------------
  518|    357|          continue;}
  519|  9.01k|        if (*c=='+') {             // valid + sign
  ------------------
  |  Branch (519:13): [True: 6.13k, False: 2.87k]
  ------------------
  520|  6.13k|          cfirst++;
  521|  6.13k|          continue;}
  522|  9.01k|        }
  523|       |      // *c is not a digit, or a valid +, -, or '.'
  524|  5.55M|      break;
  525|  5.56M|      } // c
  526|       |
  527|  5.55M|    if (last==NULL) {              // no digits yet
  ------------------
  |  Branch (527:9): [True: 2.91k, False: 5.55M]
  ------------------
  528|  2.91k|      status=DEC_Conversion_syntax;// assume the worst
  ------------------
  |  |  128|  2.91k|    #define DEC_Conversion_syntax    0x00000001
  ------------------
  529|  2.91k|      if (*c=='\0') break;         // and no more to come...
  ------------------
  |  Branch (529:11): [True: 31, False: 2.88k]
  ------------------
  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.88k|      if (dotchar!=NULL) break;    // .. unless had a dot
  ------------------
  |  Branch (535:11): [True: 3, False: 2.87k]
  ------------------
  536|  2.87k|      decNumberZero(dn);           // be optimistic
  537|  2.87k|      if (decBiStr(c, "infinity", "INFINITY")
  ------------------
  |  Branch (537:11): [True: 212, False: 2.66k]
  ------------------
  538|  2.66k|       || decBiStr(c, "inf", "INF")) {
  ------------------
  |  Branch (538:11): [True: 312, False: 2.35k]
  ------------------
  539|    524|        dn->bits=bits | DECINF;
  ------------------
  |  |   32|    524|  #define DECINF    0x40      /* 1=Infinity                           */
  ------------------
  540|    524|        status=0;                  // is OK
  541|    524|        break; // all done
  542|    524|        }
  543|       |      // a NaN expected
  544|       |      // 2003.09.10 NaNs are now permitted to have a sign
  545|  2.35k|      dn->bits=bits | DECNAN;      // assume simple NaN
  ------------------
  |  |   33|  2.35k|  #define DECNAN    0x20      /* 1=NaN                                */
  ------------------
  546|  2.35k|      if (*c=='s' || *c=='S') {    // looks like an sNaN
  ------------------
  |  Branch (546:11): [True: 247, False: 2.10k]
  |  Branch (546:22): [True: 200, False: 1.90k]
  ------------------
  547|    447|        c++;
  548|    447|        dn->bits=bits | DECSNAN;
  ------------------
  |  |   34|    447|  #define DECSNAN   0x10      /* 1=sNaN                               */
  ------------------
  549|    447|        }
  550|  2.35k|      if (*c!='n' && *c!='N') break;    // check caseless "NaN"
  ------------------
  |  Branch (550:11): [True: 1.17k, False: 1.17k]
  |  Branch (550:22): [True: 336, False: 843]
  ------------------
  551|  2.01k|      c++;
  552|  2.01k|      if (*c!='a' && *c!='A') break;    // ..
  ------------------
  |  Branch (552:11): [True: 517, False: 1.50k]
  |  Branch (552:22): [True: 56, False: 461]
  ------------------
  553|  1.96k|      c++;
  554|  1.96k|      if (*c!='n' && *c!='N') break;    // ..
  ------------------
  |  Branch (554:11): [True: 1.05k, False: 909]
  |  Branch (554:22): [True: 38, False: 1.01k]
  ------------------
  555|  1.92k|      c++;
  556|       |      // now either nothing, or nnnn payload, expected
  557|       |      // -> start of integer and skip leading 0s [including plain 0]
  558|  2.67k|      for (cfirst=c; *cfirst=='0';) cfirst++;
  ------------------
  |  Branch (558:22): [True: 749, False: 1.92k]
  ------------------
  559|  1.92k|      if (*cfirst=='\0') {         // "NaN" or "sNaN", maybe with all 0s
  ------------------
  |  Branch (559:11): [True: 1.85k, False: 68]
  ------------------
  560|  1.85k|        status=0;                  // it's good
  561|  1.85k|        break;                     // ..
  562|  1.85k|        }
  563|       |      // something other than 0s; setup last and d as usual [no dots]
  564|  1.73M|      for (c=cfirst;; c++, d++) {
  565|  1.73M|        if (*c<'0' || *c>'9') break; // test for Arabic digit
  ------------------
  |  Branch (565:13): [True: 61, False: 1.73M]
  |  Branch (565:23): [True: 7, False: 1.73M]
  ------------------
  566|  1.73M|        last=c;
  567|  1.73M|        }
  568|     68|      if (*c!='\0') break;         // not all digits
  ------------------
  |  Branch (568:11): [True: 23, False: 45]
  ------------------
  569|     45|      if (d>set->digits-1) {
  ------------------
  |  Branch (569:11): [True: 0, False: 45]
  ------------------
  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|     45|      status=0;                    // syntax is OK
  577|     45|      bits=dn->bits;               // for copy-back
  578|     45|      } // last==NULL
  579|       |
  580|  5.55M|     else if (*c!='\0') {          // more to process...
  ------------------
  |  Branch (580:15): [True: 32.3k, False: 5.52M]
  ------------------
  581|       |      // had some digits; exponent is only valid sequence now
  582|  32.3k|      Flag nege;                   // 1=negative exponent
  ------------------
  |  |   87|  32.3k|  #define Flag   uint8_t
  ------------------
  583|  32.3k|      const char *firstexp;        // -> first significant exponent digit
  584|  32.3k|      status=DEC_Conversion_syntax;// assume the worst
  ------------------
  |  |  128|  32.3k|    #define DEC_Conversion_syntax    0x00000001
  ------------------
  585|  32.3k|      uInt expa=0;                 // accumulator for exponent
  ------------------
  |  |   93|  32.3k|  #define uInt   uint32_t
  ------------------
  586|  32.3k|      if (*c!='e' && *c!='E') break;
  ------------------
  |  Branch (586:11): [True: 30.2k, False: 2.13k]
  |  Branch (586:22): [True: 40, False: 30.2k]
  ------------------
  587|       |      /* Found 'e' or 'E' -- now process explicit exponent */
  588|       |      // 1998.07.11: sign no longer required
  589|  32.3k|      nege=0;
  590|  32.3k|      c++;                         // to (possible) sign
  591|  32.3k|      if (*c=='-') {nege=1; c++;}
  ------------------
  |  Branch (591:11): [True: 16.4k, False: 15.9k]
  ------------------
  592|  15.9k|       else if (*c=='+') c++;
  ------------------
  |  Branch (592:17): [True: 213, False: 15.7k]
  ------------------
  593|  32.3k|      if (*c=='\0') break;
  ------------------
  |  Branch (593:11): [True: 28, False: 32.3k]
  ------------------
  594|       |
  595|  33.2k|      for (; *c=='0' && *(c+1)!='\0';) c++;  // strip insignificant zeros
  ------------------
  |  Branch (595:14): [True: 1.03k, False: 32.2k]
  |  Branch (595:25): [True: 914, False: 117]
  ------------------
  596|  32.3k|      firstexp=c;                            // save exponent digit place
  597|  2.95M|      for (; ;c++) {
  598|  2.95M|        if (*c<'0' || *c>'9') break;         // not a digit
  ------------------
  |  Branch (598:13): [True: 32.3k, False: 2.91M]
  |  Branch (598:23): [True: 6, False: 2.91M]
  ------------------
  599|  2.91M|        expa=X10(expa)+(Int)*c-(Int)'0';
  ------------------
  |  |  163|  2.91M|  #define X10(i)  (((i)<<1)+((i)<<3))
  ------------------
  600|  2.91M|        } // c
  601|       |      // if not now on a '\0', *c must not be a digit
  602|  32.3k|      if (*c!='\0') break;
  ------------------
  |  Branch (602:11): [True: 31, False: 32.2k]
  ------------------
  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|  32.2k|      if (c>=firstexp+9+1) {
  ------------------
  |  Branch (607:11): [True: 24.6k, False: 7.60k]
  ------------------
  608|  24.6k|        if (c>firstexp+9+1 || *firstexp>'1') expa=DECNUMMAXE*2;
  ------------------
  |  |  183|  8.01k|  #define DECNUMMAXE 999999999  /* maximum adjusted exponent ditto    */
  ------------------
  |  Branch (608:13): [True: 7.40k, False: 17.2k]
  |  Branch (608:31): [True: 603, False: 16.6k]
  ------------------
  609|       |        // [up to 1999999999 is OK, for example 1E-1000000998]
  610|  24.6k|        }
  611|  32.2k|      exponent=(Int)expa;               // save exponent
  612|  32.2k|      if (nege) exponent=-exponent;     // was negative
  ------------------
  |  Branch (612:11): [True: 16.4k, False: 15.8k]
  ------------------
  613|  32.2k|      status=0;                         // is OK
  614|  32.2k|      } // 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|  5.55M|    if (*cfirst=='0') {                 // [cfirst has stepped over .]
  ------------------
  |  Branch (620:9): [True: 2.61M, False: 2.93M]
  ------------------
  621|  2.65M|      for (c=cfirst; c<last; c++, cfirst++) {
  ------------------
  |  Branch (621:22): [True: 47.4k, False: 2.61M]
  ------------------
  622|  47.4k|        if (*c=='.') continue;          // ignore dots
  ------------------
  |  Branch (622:13): [True: 5.87k, False: 41.5k]
  ------------------
  623|  41.5k|        if (*c!='0') break;             // non-zero found
  ------------------
  |  Branch (623:13): [True: 1.47k, False: 40.0k]
  ------------------
  624|  40.0k|        d--;                            // 0 stripped
  625|  40.0k|        } // 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.61M|      } // at least one leading 0
  634|       |
  635|       |    // Handle decimal point...
  636|  5.55M|    if (dotchar!=NULL && dotchar<last)  // non-trailing '.' found?
  ------------------
  |  Branch (636:9): [True: 8.94k, False: 5.54M]
  |  Branch (636:26): [True: 8.68k, False: 255]
  ------------------
  637|  8.68k|      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|  5.55M|    if (d<=set->digits) res=dn->lsu;    // fits into supplied decNumber
  ------------------
  |  Branch (642:9): [True: 5.55M, 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|  5.55M|    #if DECDPUN>1
  657|  5.55M|    out=0;                         // accumulator
  658|  5.55M|    up=res+D2U(d)-1;               // -> msu
  ------------------
  |  |  264|  5.55M|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|  5.55M|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|  1.08k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|  1.08k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 5.55M, False: 1.08k]
  |  |  ------------------
  ------------------
  659|  5.55M|    cut=d-(up-res)*DECDPUN;        // digits in top unit
  ------------------
  |  |   43|  5.55M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  660|  30.5M|    for (c=cfirst;; c++) {         // along the digits
  661|  30.5M|      if (*c=='.') continue;       // ignore '.' [don't decrement cut]
  ------------------
  |  Branch (661:11): [True: 1.84k, False: 30.5M]
  ------------------
  662|  30.5M|      out=X10(out)+(Int)*c-(Int)'0';
  ------------------
  |  |  163|  30.5M|  #define X10(i)  (((i)<<1)+((i)<<3))
  ------------------
  663|  30.5M|      if (c==last) break;          // done [never get to trailing '.']
  ------------------
  |  Branch (663:11): [True: 5.55M, False: 25.0M]
  ------------------
  664|  25.0M|      cut--;
  665|  25.0M|      if (cut>0) continue;         // more for this unit
  ------------------
  |  Branch (665:11): [True: 16.7M, False: 8.30M]
  ------------------
  666|  8.30M|      *up=(Unit)out;               // write unit
  667|  8.30M|      up--;                        // prepare for unit below..
  668|  8.30M|      cut=DECDPUN;                 // ..
  ------------------
  |  |   43|  8.30M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  669|  8.30M|      out=0;                       // ..
  670|  8.30M|      } // c
  671|  5.55M|    *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|  5.55M|    dn->bits=bits;
  684|  5.55M|    dn->exponent=exponent;
  685|  5.55M|    dn->digits=d;
  686|       |
  687|       |    // if not in number (too long) shorten into the number
  688|  5.55M|    if (d>set->digits) {
  ------------------
  |  Branch (688:9): [True: 0, False: 5.55M]
  ------------------
  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|  5.55M|     else { // no rounding, but may still have overflow or subnormal
  695|       |      // [these tests are just for performance; finalize repeats them]
  696|  5.55M|      if ((dn->exponent-1<set->emin-dn->digits)
  ------------------
  |  Branch (696:11): [True: 13.0k, False: 5.53M]
  ------------------
  697|  5.53M|       || (dn->exponent-1>set->emax-set->digits)) {
  ------------------
  |  Branch (697:11): [True: 12.1k, False: 5.52M]
  ------------------
  698|  25.1k|        residue=0;
  699|  25.1k|        decFinalize(dn, set, &residue, &status);
  700|  25.1k|        }
  701|  5.55M|      }
  702|       |    // decNumberShow(dn);
  703|  5.55M|    } while(0);                         // [for break]
  ------------------
  |  Branch (703:13): [Folded, False: 5.55M]
  ------------------
  704|       |
  705|  5.55M|  if (allocres!=NULL) free(allocres);   // drop any storage used
  ------------------
  |  Branch (705:7): [True: 0, False: 5.55M]
  ------------------
  706|  5.55M|  if (status!=0) decStatus(dn, status, set);
  ------------------
  |  Branch (706:7): [True: 25.2k, False: 5.53M]
  ------------------
  707|  5.55M|  return dn;
  708|  5.55M|  } /* decNumberFromString */
decNumberZero:
 3588|  14.8k|decNumber * decNumberZero(decNumber *dn) {
 3589|       |
 3590|       |  #if DECCHECK
 3591|       |  if (decCheckOperands(dn, DECUNUSED, DECUNUSED, DECUNCONT)) return dn;
 3592|       |  #endif
 3593|       |
 3594|  14.8k|  dn->bits=0;
 3595|  14.8k|  dn->exponent=0;
 3596|  14.8k|  dn->digits=1;
 3597|  14.8k|  dn->lsu[0]=0;
 3598|  14.8k|  return dn;
 3599|  14.8k|  } // decNumberZero
decNumber.c:decUnitAddSub:
 6339|  2.39k|                         Unit *c, Int m) {
 6340|  2.39k|  const Unit *alsu=a;              // A lsu [need to remember it]
 6341|  2.39k|  Unit *clsu=c;                    // C ditto
  ------------------
  |  |   94|  2.39k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  2.39k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6342|  2.39k|  Unit *minC;                      // low water mark for C
  ------------------
  |  |   94|  2.39k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  2.39k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6343|  2.39k|  Unit *maxC;                      // high water mark for C
  ------------------
  |  |   94|  2.39k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  2.39k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6344|  2.39k|  eInt carry=0;                    // carry integer (could be Long)
  ------------------
  |  |  203|  2.39k|  #define eInt  Int           // extended integer
  |  |  ------------------
  |  |  |  |   92|  2.39k|  #define Int    int32_t
  |  |  ------------------
  ------------------
 6345|  2.39k|  Int  add;                        // work
  ------------------
  |  |   92|  2.39k|  #define Int    int32_t
  ------------------
 6346|  2.39k|  #if DECDPUN<=4                   // myriadal, millenary, etc.
 6347|  2.39k|  Int  est;                        // estimated quotient
  ------------------
  |  |   92|  2.39k|  #define Int    int32_t
  ------------------
 6348|  2.39k|  #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.39k|  maxC=c+alength;                  // A is usually the longer
 6356|  2.39k|  minC=c+blength;                  // .. and B the shorter
 6357|  2.39k|  if (bshift!=0) {                 // B is shifted; low As copy across
  ------------------
  |  Branch (6357:7): [True: 0, False: 2.39k]
  ------------------
 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.39k|  if (minC>maxC) { // swap
  ------------------
  |  Branch (6369:7): [True: 0, False: 2.39k]
  ------------------
 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.79k|  for (; c<minC; c++) {
  ------------------
  |  Branch (6379:10): [True: 2.39k, False: 2.39k]
  ------------------
 6380|  2.39k|    carry+=*a;
 6381|  2.39k|    a++;
 6382|  2.39k|    carry+=((eInt)*b)*m;                // [special-casing m=1/-1
 6383|  2.39k|    b++;                                // here is not a win]
 6384|       |    // here carry is new Unit of digits; it could be +ve or -ve
 6385|  2.39k|    if ((ueInt)carry<=DECDPUNMAX) {     // fastpath 0-DECDPUNMAX
  ------------------
  |  |  209|  2.39k|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6385:9): [True: 2.03k, False: 359]
  ------------------
 6386|  2.03k|      *c=(Unit)carry;
 6387|  2.03k|      carry=0;
 6388|  2.03k|      continue;
 6389|  2.03k|      }
 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|    359|      if (carry>=0) {
  ------------------
  |  Branch (6409:11): [True: 359, False: 0]
  ------------------
 6410|    359|        est=(((ueInt)carry>>3)*16777)>>21;
 6411|    359|        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder
  ------------------
  |  |  209|    359|    #define DECDPUNMAX 999
  ------------------
 6412|    359|        carry=est;                           // likely quotient [99%]
 6413|    359|        if (*c<DECDPUNMAX+1) continue;       // estimate was correct
  ------------------
  |  |  209|    359|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6413:13): [True: 0, False: 359]
  ------------------
 6414|    359|        carry++;
 6415|    359|        *c-=DECDPUNMAX+1;
  ------------------
  |  |  209|    359|    #define DECDPUNMAX 999
  ------------------
 6416|    359|        continue;
 6417|    359|        }
 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|  1.93M|  if (c<maxC) for (; c<maxC; c++) {
  ------------------
  |  Branch (6460:7): [True: 1.11k, False: 1.28k]
  |  Branch (6460:22): [True: 1.93M, False: 1.11k]
  ------------------
 6461|  1.93M|    if (a<alsu+alength) {               // still in A
  ------------------
  |  Branch (6461:9): [True: 1.93M, False: 0]
  ------------------
 6462|  1.93M|      carry+=*a;
 6463|  1.93M|      a++;
 6464|  1.93M|      }
 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|  1.93M|    if ((ueInt)carry<=DECDPUNMAX) {     // fastpath 0-DECDPUNMAX
  ------------------
  |  |  209|  1.93M|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6471:9): [True: 1.35M, False: 580k]
  ------------------
 6472|  1.35M|      *c=(Unit)carry;
 6473|  1.35M|      carry=0;
 6474|  1.35M|      continue;
 6475|  1.35M|      }
 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|   580k|      if (carry>=0) {
  ------------------
  |  Branch (6496:11): [True: 580k, False: 0]
  ------------------
 6497|   580k|        est=(((ueInt)carry>>3)*16777)>>21;
 6498|   580k|        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder
  ------------------
  |  |  209|   580k|    #define DECDPUNMAX 999
  ------------------
 6499|   580k|        carry=est;                           // likely quotient [99%]
 6500|   580k|        if (*c<DECDPUNMAX+1) continue;       // estimate was correct
  ------------------
  |  |  209|   580k|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6500:13): [True: 0, False: 580k]
  ------------------
 6501|   580k|        carry++;
 6502|   580k|        *c-=DECDPUNMAX+1;
  ------------------
  |  |  209|   580k|    #define DECDPUNMAX 999
  ------------------
 6503|   580k|        continue;
 6504|   580k|        }
 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.39k|  if (carry==0) return c-clsu;     // no carry, so no more to do
  ------------------
  |  Branch (6546:7): [True: 2.39k, 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|  12.0k|                          uInt *status) {
 7072|  12.0k|  Int  bump;                  // 1 if coefficient needs to be incremented
  ------------------
  |  |   92|  12.0k|  #define Int    int32_t
  ------------------
 7073|       |                              // -1 if coefficient needs to be decremented
 7074|       |
 7075|  12.0k|  if (residue==0) return;     // nothing to apply
  ------------------
  |  Branch (7075:7): [True: 3.36k, False: 8.70k]
  ------------------
 7076|       |
 7077|  8.70k|  bump=0;                     // assume a smooth ride
 7078|       |
 7079|       |  // now decide whether, and how, to round, depending on mode
 7080|  8.70k|  switch (set->round) {
 7081|      0|    case DEC_ROUND_05UP: {    // round zero or five up (for reround)
  ------------------
  |  Branch (7081:5): [True: 0, False: 8.70k]
  ------------------
 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: 8.70k]
  ------------------
 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: 8.70k]
  ------------------
 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: 8.70k]
  ------------------
 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|  8.70k|    case DEC_ROUND_HALF_UP: {
  ------------------
  |  Branch (7110:5): [True: 8.70k, False: 0]
  ------------------
 7111|  8.70k|      if (residue>=5) bump=1;
  ------------------
  |  Branch (7111:11): [True: 3.75k, False: 4.95k]
  ------------------
 7112|  8.70k|      break;} // r-h-u
 7113|       |
 7114|      0|    case DEC_ROUND_UP: {
  ------------------
  |  Branch (7114:5): [True: 0, False: 8.70k]
  ------------------
 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: 8.70k]
  ------------------
 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: 8.70k]
  ------------------
 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: 8.70k]
  ------------------
 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|  8.70k|    } // switch
 7147|       |
 7148|       |  // now bump the number, up or down, if need be
 7149|  8.70k|  if (bump==0) return;                       // no action required
  ------------------
  |  Branch (7149:7): [True: 4.95k, False: 3.75k]
  ------------------
 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.75k|  if (bump>0) {
  ------------------
  |  Branch (7156:7): [True: 3.75k, False: 0]
  ------------------
 7157|  3.75k|    Unit *up;                                // work
  ------------------
  |  |   94|  3.75k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  3.75k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 7158|  3.75k|    uInt count=dn->digits;                   // digits to be checked
  ------------------
  |  |   93|  3.75k|  #define uInt   uint32_t
  ------------------
 7159|  4.22M|    for (up=dn->lsu; ; up++) {
 7160|  4.22M|      if (count<=DECDPUN) {
  ------------------
  |  |   43|  4.22M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (7160:11): [True: 2.84k, False: 4.22M]
  ------------------
 7161|       |        // this is the last Unit (the msu)
 7162|  2.84k|        if (*up!=powers[count]-1) break;     // not still 9s
  ------------------
  |  |  177|  2.84k|#define powers      DECPOWERS      // old internal name
  ------------------
  |  Branch (7162:13): [True: 1.48k, False: 1.35k]
  ------------------
 7163|       |        // here if it, too, is all nines
 7164|  1.35k|        *up=(Unit)powers[count-1];           // here 999 -> 100 etc.
  ------------------
  |  |  177|  1.35k|#define powers      DECPOWERS      // old internal name
  ------------------
 7165|  3.64M|        for (up=up-1; up>=dn->lsu; up--) *up=0; // others all to 0
  ------------------
  |  Branch (7165:23): [True: 3.63M, False: 1.35k]
  ------------------
 7166|  1.35k|        dn->exponent++;                      // and bump exponent
 7167|       |        // [which, very rarely, could cause Overflow...]
 7168|  1.35k|        if ((dn->exponent+dn->digits)>set->emax+1) {
  ------------------
  |  Branch (7168:13): [True: 0, False: 1.35k]
  ------------------
 7169|      0|          decSetOverflow(dn, set, status);
 7170|      0|          }
 7171|  1.35k|        return;                              // done
 7172|  2.84k|        }
 7173|       |      // a full unit to check, with more to come
 7174|  4.22M|      if (*up!=DECDPUNMAX) break;            // not still 9s
  ------------------
  |  |  209|  4.22M|    #define DECDPUNMAX 999
  ------------------
  |  Branch (7174:11): [True: 912, False: 4.22M]
  ------------------
 7175|  4.22M|      count-=DECDPUN;
  ------------------
  |  |   43|  4.22M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 7176|  4.22M|      } // up
 7177|  3.75k|    } // 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.39k|  decUnitAddSub(dn->lsu, D2U(dn->digits), uarrone, 1, 0, dn->lsu, bump);
  ------------------
  |  |  264|  2.39k|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|  2.39k|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    250|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    250|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 2.14k, False: 250]
  |  |  ------------------
  ------------------
 7220|  2.39k|  } // decApplyRound
decNumber.c:decSetOverflow:
 7348|  11.8k|static void decSetOverflow(decNumber *dn, decContext *set, uInt *status) {
 7349|  11.8k|  Flag needmax=0;                  // result is maximum finite value
  ------------------
  |  |   87|  11.8k|  #define Flag   uint8_t
  ------------------
 7350|  11.8k|  uByte sign=dn->bits&DECNEG;      // clean and save sign bit
  ------------------
  |  |   89|  11.8k|  #define uByte  uint8_t
  ------------------
                uByte sign=dn->bits&DECNEG;      // clean and save sign bit
  ------------------
  |  |   31|  11.8k|  #define DECNEG    0x80      /* Sign; 1=negative, 0=positive or zero */
  ------------------
 7351|       |
 7352|  11.8k|  if (ISZERO(dn)) {                // zero does not overflow magnitude
  ------------------
  |  |  255|  11.8k|  #define ISZERO(dn) decNumberIsZero(dn)     /* now just a local name */
  |  |  ------------------
  |  |  |  |  177|  11.8k|  #define decNumberIsZero(dn)      (*(dn)->lsu==0 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (177:37): [True: 889, False: 10.9k]
  |  |  |  |  ------------------
  |  |  |  |  178|  11.8k|                                    && (dn)->digits==1 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:40): [True: 539, False: 350]
  |  |  |  |  ------------------
  |  |  |  |  179|  11.8k|                                    && (((dn)->bits&DECSPECIAL)==0))
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|    539|  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|    539|  #define DECINF    0x40      /* 1=Infinity                           */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   33|    539|  #define DECNAN    0x20      /* 1=NaN                                */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   34|    539|  #define DECSNAN   0x10      /* 1=sNaN                               */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (179:40): [True: 539, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7353|    539|    Int emax=set->emax;                      // limit value
  ------------------
  |  |   92|    539|  #define Int    int32_t
  ------------------
 7354|    539|    if (set->clamp) emax-=set->digits-1;     // lower if clamping
  ------------------
  |  Branch (7354:9): [True: 0, False: 539]
  ------------------
 7355|    539|    if (dn->exponent>emax) {                 // clamp required
  ------------------
  |  Branch (7355:9): [True: 539, False: 0]
  ------------------
 7356|    539|      dn->exponent=emax;
 7357|    539|      *status|=DEC_Clamped;
  ------------------
  |  |  140|    539|    #define DEC_Clamped              0x00000400
  ------------------
 7358|    539|      }
 7359|    539|    return;
 7360|    539|    }
 7361|       |
 7362|  11.3k|  decNumberZero(dn);
 7363|  11.3k|  switch (set->round) {
 7364|      0|    case DEC_ROUND_DOWN: {
  ------------------
  |  Branch (7364:5): [True: 0, False: 11.3k]
  ------------------
 7365|      0|      needmax=1;                   // never Infinity
 7366|      0|      break;} // r-d
 7367|      0|    case DEC_ROUND_05UP: {
  ------------------
  |  Branch (7367:5): [True: 0, False: 11.3k]
  ------------------
 7368|      0|      needmax=1;                   // never Infinity
 7369|      0|      break;} // r-05
 7370|      0|    case DEC_ROUND_CEILING: {
  ------------------
  |  Branch (7370:5): [True: 0, False: 11.3k]
  ------------------
 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: 11.3k]
  ------------------
 7374|      0|      if (!sign) needmax=1;        // Infinity if negative
  ------------------
  |  Branch (7374:11): [True: 0, False: 0]
  ------------------
 7375|      0|      break;} // r-f
 7376|  11.3k|    default: break;                // Infinity in all other cases
  ------------------
  |  Branch (7376:5): [True: 11.3k, False: 0]
  ------------------
 7377|  11.3k|    }
 7378|  11.3k|  if (needmax) {
  ------------------
  |  Branch (7378:7): [True: 0, False: 11.3k]
  ------------------
 7379|      0|    decSetMaxValue(dn, set);
 7380|      0|    dn->bits=sign;                 // set sign
 7381|      0|    }
 7382|  11.3k|   else dn->bits=sign|DECINF;      // Value is +/-Infinity
  ------------------
  |  |   32|  11.3k|  #define DECINF    0x40      /* 1=Infinity                           */
  ------------------
 7383|  11.3k|  *status|=DEC_Overflow | DEC_Inexact | DEC_Rounded;
  ------------------
  |  |  139|  11.3k|    #define DEC_Overflow             0x00000200
  ------------------
                *status|=DEC_Overflow | DEC_Inexact | DEC_Rounded;
  ------------------
  |  |  133|  11.3k|    #define DEC_Inexact              0x00000020
  ------------------
                *status|=DEC_Overflow | DEC_Inexact | DEC_Rounded;
  ------------------
  |  |  141|  11.3k|    #define DEC_Rounded              0x00000800
  ------------------
 7384|  11.3k|  } // decSetOverflow
decNumber.c:decShiftToMost:
 6685|  1.35k|static Int decShiftToMost(Unit *uar, Int digits, Int shift) {
 6686|  1.35k|  Unit  *target, *source, *first;  // work
  ------------------
  |  |   94|  1.35k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  1.35k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6687|  1.35k|  Int   cut;                       // odd 0's to add
  ------------------
  |  |   92|  1.35k|  #define Int    int32_t
  ------------------
 6688|  1.35k|  uInt  next;                      // work
  ------------------
  |  |   93|  1.35k|  #define uInt   uint32_t
  ------------------
 6689|       |
 6690|  1.35k|  if (shift==0) return digits;     // [fastpath] nothing to do
  ------------------
  |  Branch (6690:7): [True: 0, False: 1.35k]
  ------------------
 6691|  1.35k|  if ((digits+shift)<=DECDPUN) {   // [fastpath] single-unit case
  ------------------
  |  |   43|  1.35k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6691:7): [True: 469, False: 887]
  ------------------
 6692|    469|    *uar=(Unit)(*uar*powers[shift]);
  ------------------
  |  |  177|    469|#define powers      DECPOWERS      // old internal name
  ------------------
 6693|    469|    return digits+shift;
 6694|    469|    }
 6695|       |
 6696|    887|  next=0;                          // all paths
 6697|    887|  source=uar+D2U(digits)-1;        // where msu comes from
  ------------------
  |  |  264|    887|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|    887|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    308|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    308|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 579, False: 308]
  |  |  ------------------
  ------------------
 6698|    887|  target=source+D2U(shift);        // where upper part of first cut goes
  ------------------
  |  |  264|    887|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|    887|  #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: 887, False: 0]
  |  |  ------------------
  ------------------
 6699|    887|  cut=DECDPUN-MSUDIGITS(shift);    // where to slice
  ------------------
  |  |   43|    887|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
                cut=DECDPUN-MSUDIGITS(shift);    // where to slice
  ------------------
  |  |  271|    887|  #define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN)
  |  |  ------------------
  |  |  |  |  264|    887|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  |  |  ------------------
  |  |  |  |  |  |  249|    887|  #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: 887, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 #define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    887|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  ------------------
 6700|    887|  if (cut==0) {                    // unit-boundary case
  ------------------
  |  Branch (6700:7): [True: 0, False: 887]
  ------------------
 6701|      0|    for (; source>=uar; source--, target--) *target=*source;
  ------------------
  |  Branch (6701:12): [True: 0, False: 0]
  ------------------
 6702|      0|    }
 6703|    887|   else {
 6704|    887|    first=uar+D2U(digits+shift)-1; // where msu of source will end up
  ------------------
  |  |  264|    887|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|    887|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    492|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    492|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 395, False: 492]
  |  |  ------------------
  ------------------
 6705|  3.64M|    for (; source>=uar; source--, target--) {
  ------------------
  |  Branch (6705:12): [True: 3.64M, False: 887]
  ------------------
 6706|       |      // split the source Unit and accumulate remainder for next
 6707|  3.64M|      #if DECDPUN<=4
 6708|  3.64M|        uInt quot=QUOT10(*source, cut);
  ------------------
  |  |   93|  3.64M|  #define uInt   uint32_t
  ------------------
                      uInt quot=QUOT10(*source, cut);
  ------------------
  |  |  210|  3.64M|  #define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17)
  ------------------
 6709|  3.64M|        uInt rem=*source-quot*powers[cut];
  ------------------
  |  |   93|  3.64M|  #define uInt   uint32_t
  ------------------
                      uInt rem=*source-quot*powers[cut];
  ------------------
  |  |  177|  3.64M|#define powers      DECPOWERS      // old internal name
  ------------------
 6710|  3.64M|        next+=quot;
 6711|       |      #else
 6712|       |        uInt rem=*source%powers[cut];
 6713|       |        next+=*source/powers[cut];
 6714|       |      #endif
 6715|  3.64M|      if (target<=first) *target=(Unit)next;   // write to target iff valid
  ------------------
  |  Branch (6715:11): [True: 3.63M, False: 695]
  ------------------
 6716|  3.64M|      next=rem*powers[DECDPUN-cut];            // save remainder for next Unit
  ------------------
  |  |  177|  3.64M|#define powers      DECPOWERS      // old internal name
  ------------------
                    next=rem*powers[DECDPUN-cut];            // save remainder for next Unit
  ------------------
  |  |   43|  3.64M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 6717|  3.64M|      }
 6718|    887|    } // shift-move
 6719|       |
 6720|       |  // propagate any partial unit to one below and clear the rest
 6721|  1.77k|  for (; target>=uar; target--) {
  ------------------
  |  Branch (6721:10): [True: 887, False: 887]
  ------------------
 6722|    887|    *target=(Unit)next;
 6723|    887|    next=0;
 6724|    887|    }
 6725|    887|  return digits+shift;
 6726|  1.35k|  } // decShiftToMost
decNumber.c:decSetCoeff:
 6890|  12.0k|                        Int len, Int *residue, uInt *status) {
 6891|  12.0k|  Int   discard;              // number of digits to discard
  ------------------
  |  |   92|  12.0k|  #define Int    int32_t
  ------------------
 6892|  12.0k|  uInt  cut;                  // cut point in Unit
  ------------------
  |  |   93|  12.0k|  #define uInt   uint32_t
  ------------------
 6893|  12.0k|  const Unit *up;             // work
 6894|  12.0k|  Unit  *target;              // ..
  ------------------
  |  |   94|  12.0k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  12.0k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6895|  12.0k|  Int   count;                // ..
  ------------------
  |  |   92|  12.0k|  #define Int    int32_t
  ------------------
 6896|  12.0k|  #if DECDPUN<=4
 6897|  12.0k|  uInt  temp;                 // ..
  ------------------
  |  |   93|  12.0k|  #define uInt   uint32_t
  ------------------
 6898|  12.0k|  #endif
 6899|       |
 6900|  12.0k|  discard=len-set->digits;    // digits to discard
 6901|  12.0k|  if (discard<=0) {           // no digits are being discarded
  ------------------
  |  Branch (6901:7): [True: 0, False: 12.0k]
  ------------------
 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|  12.0k|  dn->exponent+=discard;      // maintain numerical value
 6917|  12.0k|  *status|=DEC_Rounded;       // accumulate Rounded status
  ------------------
  |  |  141|  12.0k|    #define DEC_Rounded              0x00000800
  ------------------
 6918|  12.0k|  if (*residue>1) *residue=1; // previous residue now to right, so reduce
  ------------------
  |  Branch (6918:7): [True: 0, False: 12.0k]
  ------------------
 6919|       |
 6920|  12.0k|  if (discard>len) {          // everything, +1, is being discarded
  ------------------
  |  Branch (6920:7): [True: 4.63k, False: 7.43k]
  ------------------
 6921|       |    // guard digit is 0
 6922|       |    // residue is all the number [NB could be all 0s]
 6923|  4.63k|    if (*residue<=0) {        // not already positive
  ------------------
  |  Branch (6923:9): [True: 4.63k, False: 0]
  ------------------
 6924|  4.63k|      count=len;              // avoids D2U
 6925|   173k|      for (up=lsu; count>0; up++, count-=DECDPUN) if (*up!=0) { // found non-0
  ------------------
  |  |   43|   168k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6925:20): [True: 173k, False: 0]
  |  Branch (6925:55): [True: 4.63k, False: 168k]
  ------------------
 6926|  4.63k|        *residue=1;
 6927|  4.63k|        break;                // no need to check any others
 6928|  4.63k|        }
 6929|  4.63k|      }
 6930|  4.63k|    if (*residue!=0) *status|=DEC_Inexact; // record inexactitude
  ------------------
  |  |  133|  4.63k|    #define DEC_Inexact              0x00000020
  ------------------
  |  Branch (6930:9): [True: 4.63k, False: 0]
  ------------------
 6931|  4.63k|    *dn->lsu=0;               // coefficient will now be 0
 6932|  4.63k|    dn->digits=1;             // ..
 6933|  4.63k|    return;
 6934|  4.63k|    } // 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|  7.43k|  count=0;
 6943|   414k|  for (up=lsu;; up++) {
 6944|   414k|    count+=DECDPUN;
  ------------------
  |  |   43|   414k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 6945|   414k|    if (count>=discard) break; // full ones all checked
  ------------------
  |  Branch (6945:9): [True: 7.43k, False: 407k]
  ------------------
 6946|   407k|    if (*up!=0) *residue=1;
  ------------------
  |  Branch (6946:9): [True: 27.7k, False: 379k]
  ------------------
 6947|   407k|    } // up
 6948|       |
 6949|       |  // here up -> Unit with first discarded digit
 6950|  7.43k|  cut=discard-(count-DECDPUN)-1;
  ------------------
  |  |   43|  7.43k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 6951|  7.43k|  if (cut==DECDPUN-1) {       // unit-boundary case (fast)
  ------------------
  |  |   43|  7.43k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6951:7): [True: 882, False: 6.54k]
  ------------------
 6952|    882|    Unit half=(Unit)powers[DECDPUN]>>1;
  ------------------
  |  |   94|    882|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|    882|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
                  Unit half=(Unit)powers[DECDPUN]>>1;
  ------------------
  |  |  177|    882|#define powers      DECPOWERS      // old internal name
  ------------------
                  Unit half=(Unit)powers[DECDPUN]>>1;
  ------------------
  |  |   43|    882|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 6953|       |    // set residue directly
 6954|    882|    if (*up>=half) {
  ------------------
  |  Branch (6954:9): [True: 452, False: 430]
  ------------------
 6955|    452|      if (*up>half) *residue=7;
  ------------------
  |  Branch (6955:11): [True: 239, False: 213]
  ------------------
 6956|    213|      else *residue+=5;       // add sticky bit
 6957|    452|      }
 6958|    430|     else { // <half
 6959|    430|      if (*up!=0) *residue=3; // [else is 0, leave as sticky bit]
  ------------------
  |  Branch (6959:11): [True: 223, False: 207]
  ------------------
 6960|    430|      }
 6961|    882|    if (set->digits<=0) {     // special for Quantize/Subnormal :-(
  ------------------
  |  Branch (6961:9): [True: 625, False: 257]
  ------------------
 6962|    625|      *dn->lsu=0;             // .. result is 0
 6963|    625|      dn->digits=1;           // ..
 6964|    625|      }
 6965|    257|     else {                   // shift to least
 6966|    257|      count=set->digits;      // now digits to end up with
 6967|    257|      dn->digits=count;       // set the new length
 6968|    257|      up++;                   // move to next
 6969|       |      // on unit boundary, so shift-down copy loop is simple
 6970|   160k|      for (target=dn->lsu; count>0; target++, up++, count-=DECDPUN)
  ------------------
  |  |   43|   160k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6970:28): [True: 160k, False: 257]
  ------------------
 6971|   160k|        *target=*up;
 6972|    257|      }
 6973|    882|    } // unit-boundary case
 6974|       |
 6975|  6.54k|   else { // discard digit is in low digit(s), and not top digit
 6976|  6.54k|    uInt  discard1;                // first discarded digit
  ------------------
  |  |   93|  6.54k|  #define uInt   uint32_t
  ------------------
 6977|  6.54k|    uInt  quot, rem;               // for divisions
  ------------------
  |  |   93|  6.54k|  #define uInt   uint32_t
  ------------------
 6978|  6.54k|    if (cut==0) quot=*up;          // is at bottom of unit
  ------------------
  |  Branch (6978:9): [True: 5.89k, False: 654]
  ------------------
 6979|    654|     else /* cut>0 */ {            // it's not at bottom of unit
 6980|    654|      #if DECDPUN<=4
 6981|    654|        quot=QUOT10(*up, cut);
  ------------------
  |  |  210|    654|  #define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17)
  ------------------
 6982|    654|        rem=*up-quot*powers[cut];
  ------------------
  |  |  177|    654|#define powers      DECPOWERS      // old internal name
  ------------------
 6983|       |      #else
 6984|       |        rem=*up%powers[cut];
 6985|       |        quot=*up/powers[cut];
 6986|       |      #endif
 6987|    654|      if (rem!=0) *residue=1;
  ------------------
  |  Branch (6987:11): [True: 354, False: 300]
  ------------------
 6988|    654|      }
 6989|       |    // discard digit is now at bottom of quot
 6990|  6.54k|    #if DECDPUN<=4
 6991|  6.54k|      temp=(quot*6554)>>16;        // fast /10
 6992|       |      // Vowels algorithm here not a win (9 instructions)
 6993|  6.54k|      discard1=quot-X10(temp);
  ------------------
  |  |  163|  6.54k|  #define X10(i)  (((i)<<1)+((i)<<3))
  ------------------
 6994|  6.54k|      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|  6.54k|    *residue+=resmap[discard1];
 7002|  6.54k|    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|  6.54k|    if (set->digits<=0) {          // special for Quantize/Subnormal :-(
  ------------------
  |  Branch (7006:9): [True: 817, False: 5.73k]
  ------------------
 7007|    817|      *dn->lsu=0;                  // .. result is 0
 7008|    817|      dn->digits=1;                // ..
 7009|    817|      }
 7010|  5.73k|     else {                        // shift to least needed
 7011|  5.73k|      count=set->digits;           // now digits to end up with
 7012|  5.73k|      dn->digits=count;            // set the new length
 7013|       |      // shift-copy the coefficient array to the result number
 7014|  5.98M|      for (target=dn->lsu; ; target++) {
 7015|  5.98M|        *target=(Unit)quot;
 7016|  5.98M|        count-=(DECDPUN-cut);
  ------------------
  |  |   43|  5.98M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 7017|  5.98M|        if (count<=0) break;
  ------------------
  |  Branch (7017:13): [True: 4.91k, False: 5.97M]
  ------------------
 7018|  5.97M|        up++;
 7019|  5.97M|        quot=*up;
 7020|  5.97M|        #if DECDPUN<=4
 7021|  5.97M|          quot=QUOT10(quot, cut);
  ------------------
  |  |  210|  5.97M|  #define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17)
  ------------------
 7022|  5.97M|          rem=*up-quot*powers[cut];
  ------------------
  |  |  177|  5.97M|#define powers      DECPOWERS      // old internal name
  ------------------
 7023|       |        #else
 7024|       |          rem=quot%powers[cut];
 7025|       |          quot=quot/powers[cut];
 7026|       |        #endif
 7027|  5.97M|        *target=(Unit)(*target+rem*powers[DECDPUN-cut]);
  ------------------
  |  |  177|  5.97M|#define powers      DECPOWERS      // old internal name
  ------------------
                      *target=(Unit)(*target+rem*powers[DECDPUN-cut]);
  ------------------
  |  |   43|  5.97M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 7028|  5.97M|        count-=cut;
 7029|  5.97M|        if (count<=0) break;
  ------------------
  |  Branch (7029:13): [True: 820, False: 5.97M]
  ------------------
 7030|  5.97M|        } // shift-copy loop
 7031|  5.73k|      } // shift to least
 7032|  6.54k|    } // not unit boundary
 7033|       |
 7034|  7.43k|  if (*residue!=0) *status|=DEC_Inexact; // record inexactitude
  ------------------
  |  |  133|  4.06k|    #define DEC_Inexact              0x00000020
  ------------------
  |  Branch (7034:7): [True: 4.06k, False: 3.36k]
  ------------------
 7035|  7.43k|  return;
 7036|  12.0k|  } // decSetCoeff
decNumber.c:decFinalize:
 7275|  25.1k|                        uInt *status) {
 7276|  25.1k|  Int shift;                            // shift needed if clamping
  ------------------
  |  |   92|  25.1k|  #define Int    int32_t
  ------------------
 7277|  25.1k|  Int tinyexp=set->emin-dn->digits+1;   // precalculate subnormal boundary
  ------------------
  |  |   92|  25.1k|  #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|  25.1k|  if (dn->exponent<=tinyexp) {          // prefilter
  ------------------
  |  Branch (7285:7): [True: 13.0k, False: 12.1k]
  ------------------
 7286|  13.0k|    Int comp;
  ------------------
  |  |   92|  13.0k|  #define Int    int32_t
  ------------------
 7287|  13.0k|    decNumber nmin;
 7288|       |    // A very nasty case here is dn == Nmin and residue<0
 7289|  13.0k|    if (dn->exponent<tinyexp) {
  ------------------
  |  Branch (7289:9): [True: 13.0k, False: 0]
  ------------------
 7290|       |      // Go handle subnormals; this will apply round if needed.
 7291|  13.0k|      decSetSubnormal(dn, set, residue, status);
 7292|  13.0k|      return;
 7293|  13.0k|      }
 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|  12.1k|  if (*residue!=0) decApplyRound(dn, set, *residue, status);
  ------------------
  |  Branch (7311:7): [True: 0, False: 12.1k]
  ------------------
 7312|       |
 7313|       |  // Check for overflow [redundant in the 'rare' case] or clamp
 7314|  12.1k|  if (dn->exponent<=set->emax-set->digits+1) return;   // neither needed
  ------------------
  |  Branch (7314:7): [True: 0, False: 12.1k]
  ------------------
 7315|       |
 7316|       |
 7317|       |  // here when might have an overflow or clamp to do
 7318|  12.1k|  if (dn->exponent>set->emax-dn->digits+1) {           // too big
  ------------------
  |  Branch (7318:7): [True: 11.8k, False: 247]
  ------------------
 7319|  11.8k|    decSetOverflow(dn, set, status);
 7320|  11.8k|    return;
 7321|  11.8k|    }
 7322|       |  // here when the result is normal but in clamp range
 7323|    247|  if (!set->clamp) return;
  ------------------
  |  Branch (7323:7): [True: 247, 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|    247|  } // decFinalize
decNumber.c:decSetSubnormal:
 7429|  13.0k|                            uInt *status) {
 7430|  13.0k|  decContext workset;         // work
 7431|  13.0k|  Int        etiny, adjust;   // ..
  ------------------
  |  |   92|  13.0k|  #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|  13.0k|  etiny=set->emin-(set->digits-1);      // smallest allowed exponent
 7446|       |
 7447|  13.0k|  if ISZERO(dn) {                       // value is zero
  ------------------
  |  |  255|  13.0k|  #define ISZERO(dn) decNumberIsZero(dn)     /* now just a local name */
  |  |  ------------------
  |  |  |  |  177|  13.0k|  #define decNumberIsZero(dn)      (*(dn)->lsu==0 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (177:37): [True: 1.04k, False: 12.0k]
  |  |  |  |  ------------------
  |  |  |  |  178|  13.0k|                                    && (dn)->digits==1 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:40): [True: 668, False: 380]
  |  |  |  |  ------------------
  |  |  |  |  179|  13.0k|                                    && (((dn)->bits&DECSPECIAL)==0))
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|    668|  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|    668|  #define DECINF    0x40      /* 1=Infinity                           */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   33|    668|  #define DECNAN    0x20      /* 1=NaN                                */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   34|    668|  #define DECSNAN   0x10      /* 1=sNaN                               */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (179:40): [True: 668, 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|    668|    if (dn->exponent<etiny) {           // clamp required
  ------------------
  |  Branch (7455:9): [True: 428, False: 240]
  ------------------
 7456|    428|      dn->exponent=etiny;
 7457|    428|      *status|=DEC_Clamped;
  ------------------
  |  |  140|    428|    #define DEC_Clamped              0x00000400
  ------------------
 7458|    428|      }
 7459|    668|    return;
 7460|    668|    }
 7461|       |
 7462|  12.3k|  *status|=DEC_Subnormal;               // have a non-zero subnormal
  ------------------
  |  |  142|  12.3k|    #define DEC_Subnormal            0x00001000
  ------------------
 7463|  12.3k|  adjust=etiny-dn->exponent;            // calculate digits to remove
 7464|  12.3k|  if (adjust<=0) {                      // not out of range; unrounded
  ------------------
  |  Branch (7464:7): [True: 323, False: 12.0k]
  ------------------
 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|    323|    if (*status&DEC_Inexact) *status|=DEC_Underflow;
  ------------------
  |  |  133|    323|    #define DEC_Inexact              0x00000020
  ------------------
                  if (*status&DEC_Inexact) *status|=DEC_Underflow;
  ------------------
  |  |  143|      0|    #define DEC_Underflow            0x00002000
  ------------------
  |  Branch (7468:9): [True: 0, False: 323]
  ------------------
 7469|    323|    return;
 7470|    323|    }
 7471|       |
 7472|       |  // adjust>0, so need to rescale the result so exponent becomes Etiny
 7473|       |  // [this code is similar to that in rescale]
 7474|  12.0k|  workset=*set;                         // clone rounding, etc.
 7475|  12.0k|  workset.digits=dn->digits-adjust;     // set requested length
 7476|  12.0k|  workset.emin-=adjust;                 // and adjust emin to match
 7477|       |  // [note that the latter can be <1, here, similar to Rescale case]
 7478|  12.0k|  decSetCoeff(dn, &workset, dn->lsu, dn->digits, residue, status);
 7479|  12.0k|  decApplyRound(dn, &workset, *residue, status);
 7480|       |
 7481|       |  // Use 754 default rule: Underflow is set iff Inexact
 7482|       |  // [independent of whether trapped]
 7483|  12.0k|  if (*status&DEC_Inexact) *status|=DEC_Underflow;
  ------------------
  |  |  133|  12.0k|    #define DEC_Inexact              0x00000020
  ------------------
                if (*status&DEC_Inexact) *status|=DEC_Underflow;
  ------------------
  |  |  143|  8.70k|    #define DEC_Underflow            0x00002000
  ------------------
  |  Branch (7483:7): [True: 8.70k, False: 3.36k]
  ------------------
 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|  12.0k|  if (dn->exponent>etiny) {
  ------------------
  |  Branch (7487:7): [True: 1.35k, False: 10.7k]
  ------------------
 7488|  1.35k|    dn->digits=decShiftToMost(dn->lsu, dn->digits, 1);
 7489|  1.35k|    dn->exponent--;                     // (re)adjust the exponent.
 7490|  1.35k|    }
 7491|       |
 7492|       |  // if rounded to zero, it is by definition clamped...
 7493|  12.0k|  if (ISZERO(dn)) *status|=DEC_Clamped;
  ------------------
  |  |  255|  12.0k|  #define ISZERO(dn) decNumberIsZero(dn)     /* now just a local name */
  |  |  ------------------
  |  |  |  |  177|  12.0k|  #define decNumberIsZero(dn)      (*(dn)->lsu==0 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (177:37): [True: 6.15k, False: 5.91k]
  |  |  |  |  ------------------
  |  |  |  |  178|  12.0k|                                    && (dn)->digits==1 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:40): [True: 4.88k, False: 1.27k]
  |  |  |  |  ------------------
  |  |  |  |  179|  12.0k|                                    && (((dn)->bits&DECSPECIAL)==0))
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|  4.88k|  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|  4.88k|  #define DECINF    0x40      /* 1=Infinity                           */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   33|  4.88k|  #define DECNAN    0x20      /* 1=NaN                                */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   34|  4.88k|  #define DECSNAN   0x10      /* 1=sNaN                               */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (179:40): [True: 4.88k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                if (ISZERO(dn)) *status|=DEC_Clamped;
  ------------------
  |  |  140|  4.88k|    #define DEC_Clamped              0x00000400
  ------------------
 7494|  12.0k|  } // decSetSubnormal
decNumber.c:decBiStr:
 7667|  5.54k|static Flag decBiStr(const char *targ, const char *str1, const char *str2) {
 7668|  9.22k|  for (;;targ++, str1++, str2++) {
 7669|  9.22k|    if (*targ!=*str1 && *targ!=*str2) return 0;
  ------------------
  |  Branch (7669:9): [True: 7.01k, False: 2.20k]
  |  Branch (7669:25): [True: 5.02k, False: 1.99k]
  ------------------
 7670|       |    // *targ has a match in one (or both, if terminator)
 7671|  4.20k|    if (*targ=='\0') break;
  ------------------
  |  Branch (7671:9): [True: 524, False: 3.67k]
  ------------------
 7672|  4.20k|    } // forever
 7673|    524|  return 1;
 7674|  5.54k|  } // decBiStr
decNumber.c:decStatus:
 7741|  25.2k|static void decStatus(decNumber *dn, uInt status, decContext *set) {
 7742|  25.2k|  if (status & DEC_NaNs) {              // error status -> NaN
  ------------------
  |  |  187|  25.2k|  #define DEC_NaNs    DEC_IEEE_754_Invalid_operation
  |  |  ------------------
  |  |  |  |  173|  25.2k|  #define DEC_IEEE_754_Invalid_operation (DEC_Conversion_syntax |     \
  |  |  |  |  ------------------
  |  |  |  |  |  |  128|  25.2k|    #define DEC_Conversion_syntax    0x00000001
  |  |  |  |  ------------------
  |  |  |  |  174|  25.2k|                                          DEC_Division_impossible |   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  130|  25.2k|    #define DEC_Division_impossible  0x00000004
  |  |  |  |  ------------------
  |  |  |  |  175|  25.2k|                                          DEC_Division_undefined |    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  131|  25.2k|    #define DEC_Division_undefined   0x00000008
  |  |  |  |  ------------------
  |  |  |  |  176|  25.2k|                                          DEC_Insufficient_storage |  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  132|  25.2k|    #define DEC_Insufficient_storage 0x00000010 /* [when malloc fails]  */
  |  |  |  |  ------------------
  |  |  |  |  177|  25.2k|                                          DEC_Invalid_context |       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  134|  25.2k|    #define DEC_Invalid_context      0x00000040
  |  |  |  |  ------------------
  |  |  |  |  178|  25.2k|                                          DEC_Invalid_operation)
  |  |  |  |  ------------------
  |  |  |  |  |  |  135|  25.2k|    #define DEC_Invalid_operation    0x00000080
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (7742:7): [True: 586, False: 24.7k]
  ------------------
 7743|       |    // if cause was an sNaN, clear and propagate [NaN is already set up]
 7744|    586|    if (status & DEC_sNaN) status&=~DEC_sNaN;
  ------------------
  |  |  193|    586|#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: 586]
  ------------------
 7745|    586|     else {
 7746|    586|      decNumberZero(dn);                // other error: clean throughout
 7747|    586|      dn->bits=DECNAN;                  // and make a quiet NaN
  ------------------
  |  |   33|    586|  #define DECNAN    0x20      /* 1=NaN                                */
  ------------------
 7748|    586|      }
 7749|    586|    }
 7750|  25.2k|  decContextSetStatus(set, status);     // [may not return]
 7751|  25.2k|  return;
 7752|  25.2k|  } // decStatus

