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

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

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

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

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

jvp_utf8_next_multibyte:
   31|  5.55M|const char* jvp_utf8_next_multibyte(const char* in, const char* end, int* codepoint_ret) {
   32|  5.55M|  assert(in < end);
  ------------------
  |  Branch (32:3): [True: 0, False: 5.55M]
  |  Branch (32:3): [True: 5.55M, False: 0]
  ------------------
   33|  5.55M|  int codepoint = -1;
   34|  5.55M|  unsigned char first = (unsigned char)in[0];
   35|  5.55M|  assert(first & 0x80);
  ------------------
  |  Branch (35:3): [True: 0, False: 5.55M]
  |  Branch (35:3): [True: 5.55M, False: 0]
  ------------------
   36|  5.55M|  int length = utf8_coding_length[first];
   37|  5.55M|  if (length == 0 || length == UTF8_CONTINUATION_BYTE) {
  ------------------
  |  |    1|  4.80M|#define UTF8_CONTINUATION_BYTE ((unsigned char)255)
  ------------------
  |  Branch (37:7): [True: 752k, False: 4.80M]
  |  Branch (37:22): [True: 3.69M, False: 1.10M]
  ------------------
   38|       |    /* Bad single byte - either an invalid byte or an out-of-place continuation byte */
   39|  4.44M|    length = 1;
   40|  4.44M|  } else if (length > end - in) {
  ------------------
  |  Branch (40:14): [True: 2.22k, False: 1.10M]
  ------------------
   41|       |    /* String ends before UTF8 sequence ends */
   42|  2.22k|    length = end - in;
   43|  1.10M|  } else {
   44|  1.10M|    codepoint = ((unsigned)in[0]) & utf8_coding_bits[first];
   45|  1.12M|    for (int i=1; i<length; i++) {
  ------------------
  |  Branch (45:19): [True: 1.11M, False: 8.52k]
  ------------------
   46|  1.11M|      unsigned ch = (unsigned char)in[i];
   47|  1.11M|      if (utf8_coding_length[ch] != UTF8_CONTINUATION_BYTE){
  ------------------
  |  |    1|  1.11M|#define UTF8_CONTINUATION_BYTE ((unsigned char)255)
  ------------------
  |  Branch (47:11): [True: 1.09M, False: 17.9k]
  ------------------
   48|       |        /* Invalid UTF8 sequence - not followed by the right number of continuation bytes */
   49|  1.09M|        codepoint = -1;
   50|  1.09M|        length = i;
   51|  1.09M|        break;
   52|  1.09M|      }
   53|  17.9k|      codepoint = (codepoint << 6) | (ch & 0x3f);
   54|  17.9k|    }
   55|  1.10M|    if (codepoint < utf8_first_codepoint[length]) {
  ------------------
  |  Branch (55:9): [True: 1.09M, False: 8.52k]
  ------------------
   56|       |      /* Overlong UTF8 sequence */
   57|  1.09M|      codepoint = -1;
   58|  1.09M|    }
   59|  1.10M|    if (0xD800 <= codepoint && codepoint <= 0xDFFF) {
  ------------------
  |  Branch (59:9): [True: 4.74k, False: 1.10M]
  |  Branch (59:32): [True: 458, False: 4.28k]
  ------------------
   60|       |      /* Surrogate codepoints can't be encoded in UTF8 */
   61|    458|      codepoint = -1;
   62|    458|    }
   63|  1.10M|    if (codepoint > 0x10FFFF) {
  ------------------
  |  Branch (63:9): [True: 231, False: 1.10M]
  ------------------
   64|       |      /* Outside Unicode range */
   65|    231|      codepoint = -1;
   66|    231|    }
   67|  1.10M|  }
   68|  5.55M|  assert(length > 0);
  ------------------
  |  Branch (68:3): [True: 0, False: 5.55M]
  |  Branch (68:3): [True: 5.55M, False: 0]
  ------------------
   69|  5.55M|  *codepoint_ret = codepoint;
   70|  5.55M|  return in + length;
   71|  5.55M|}
jvp_utf8_is_valid:
   73|  45.3k|int jvp_utf8_is_valid(const char* in, const char* end) {
   74|  45.3k|  int codepoint;
   75|  24.1M|  while ((in = jvp_utf8_next(in, end, &codepoint))) {
  ------------------
  |  Branch (75:10): [True: 24.1M, False: 42.0k]
  ------------------
   76|  24.1M|    if (codepoint == -1) return 0;
  ------------------
  |  Branch (76:9): [True: 3.28k, False: 24.1M]
  ------------------
   77|  24.1M|  }
   78|  42.0k|  return 1;
   79|  45.3k|}
jvp_utf8_encode_length:
   89|  30.1M|int jvp_utf8_encode_length(int codepoint) {
   90|  30.1M|  if (codepoint <= 0x7F) return 1;
  ------------------
  |  Branch (90:7): [True: 24.6M, False: 5.55M]
  ------------------
   91|  5.55M|  else if (codepoint <= 0x7FF) return 2;
  ------------------
  |  Branch (91:12): [True: 2.73k, False: 5.54M]
  ------------------
   92|  5.54M|  else if (codepoint <= 0xFFFF) return 3;
  ------------------
  |  Branch (92:12): [True: 5.54M, False: 2.73k]
  ------------------
   93|  2.73k|  else return 4;
   94|  30.1M|}
jvp_utf8_encode:
   96|  30.1M|int jvp_utf8_encode(int codepoint, char* out) {
   97|  30.1M|  assert(codepoint >= 0 && codepoint <= 0x10FFFF);
  ------------------
  |  Branch (97:3): [True: 0, False: 30.1M]
  |  Branch (97:3): [True: 0, False: 0]
  |  Branch (97:3): [True: 30.1M, False: 0]
  |  Branch (97:3): [True: 30.1M, False: 0]
  ------------------
   98|  30.1M|  char* start = out;
   99|  30.1M|  if (codepoint <= 0x7F) {
  ------------------
  |  Branch (99:7): [True: 24.6M, False: 5.55M]
  ------------------
  100|  24.6M|    *out++ = codepoint;
  101|  24.6M|  } else if (codepoint <= 0x7FF) {
  ------------------
  |  Branch (101:14): [True: 2.73k, False: 5.54M]
  ------------------
  102|  2.73k|    *out++ = 0xC0 + ((codepoint & 0x7C0) >> 6);
  103|  2.73k|    *out++ = 0x80 + ((codepoint & 0x03F));
  104|  5.54M|  } else if(codepoint <= 0xFFFF) {
  ------------------
  |  Branch (104:13): [True: 5.54M, False: 2.73k]
  ------------------
  105|  5.54M|    *out++ = 0xE0 + ((codepoint & 0xF000) >> 12);
  106|  5.54M|    *out++ = 0x80 + ((codepoint & 0x0FC0) >> 6);
  107|  5.54M|    *out++ = 0x80 + ((codepoint & 0x003F));
  108|  5.54M|  } else {
  109|  2.73k|    *out++ = 0xF0 + ((codepoint & 0x1C0000) >> 18);
  110|  2.73k|    *out++ = 0x80 + ((codepoint & 0x03F000) >> 12);
  111|  2.73k|    *out++ = 0x80 + ((codepoint & 0x000FC0) >> 6);
  112|  2.73k|    *out++ = 0x80 + ((codepoint & 0x00003F));
  113|  2.73k|  }
  114|  30.1M|  assert(out - start == jvp_utf8_encode_length(codepoint));
  ------------------
  |  Branch (114:3): [True: 0, False: 30.1M]
  |  Branch (114:3): [True: 30.1M, False: 0]
  ------------------
  115|  30.1M|  return out - start;
  116|  30.1M|}

jv.c:jvp_utf8_next:
   13|  30.1M|static inline const char* jvp_utf8_next(const char* in, const char* end, int* codepoint) {
   14|  30.1M|  if (in >= end) {
  ------------------
  |  Branch (14:7): [True: 3.28k, False: 30.1M]
  ------------------
   15|  3.28k|    assert(in == end);
  ------------------
  |  Branch (15:5): [True: 0, False: 3.28k]
  |  Branch (15:5): [True: 3.28k, False: 0]
  ------------------
   16|  3.28k|    return 0;
   17|  3.28k|  }
   18|  30.1M|  if (!(*in & 0x80)) {
  ------------------
  |  Branch (18:7): [True: 24.6M, False: 5.54M]
  ------------------
   19|  24.6M|    *codepoint = (unsigned char)*in;
   20|  24.6M|    return in + 1;
   21|  24.6M|  }
   22|  5.54M|  return jvp_utf8_next_multibyte(in, end, codepoint);
   23|  30.1M|}
jv_unicode.c:jvp_utf8_next:
   13|  24.1M|static inline const char* jvp_utf8_next(const char* in, const char* end, int* codepoint) {
   14|  24.1M|  if (in >= end) {
  ------------------
  |  Branch (14:7): [True: 42.0k, False: 24.1M]
  ------------------
   15|  42.0k|    assert(in == end);
  ------------------
  |  Branch (15:5): [True: 0, False: 42.0k]
  |  Branch (15:5): [True: 42.0k, False: 0]
  ------------------
   16|  42.0k|    return 0;
   17|  42.0k|  }
   18|  24.1M|  if (!(*in & 0x80)) {
  ------------------
  |  Branch (18:7): [True: 24.1M, False: 5.28k]
  ------------------
   19|  24.1M|    *codepoint = (unsigned char)*in;
   20|  24.1M|    return in + 1;
   21|  24.1M|  }
   22|  5.28k|  return jvp_utf8_next_multibyte(in, end, codepoint);
   23|  24.1M|}

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

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

decNumberFromString:
  479|  5.40M|                                decContext *set) {
  480|  5.40M|  Int   exponent=0;                // working exponent [assume 0]
  ------------------
  |  |   92|  5.40M|  #define Int    int32_t
  ------------------
  481|  5.40M|  uByte bits=0;                    // working flags [assume +ve]
  ------------------
  |  |   89|  5.40M|  #define uByte  uint8_t
  ------------------
  482|  5.40M|  Unit  *res;                      // where result will be built
  ------------------
  |  |   94|  5.40M|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  5.40M|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
  483|  5.40M|  Unit  resbuff[SD2U(DECBUFFER+9)];// local buffer in case need temporary
  ------------------
  |  |   94|  5.40M|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  5.40M|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
  484|       |                                   // [+9 allows for ln() constants]
  485|  5.40M|  Unit  *allocres=NULL;            // -> allocated result, iff allocated
  ------------------
  |  |   94|  5.40M|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  5.40M|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
  486|  5.40M|  Int   d=0;                       // count of digits found in decimal part
  ------------------
  |  |   92|  5.40M|  #define Int    int32_t
  ------------------
  487|  5.40M|  const char *dotchar=NULL;        // where dot was found
  488|  5.40M|  const char *cfirst=chars;        // -> first character of decimal part
  489|  5.40M|  const char *last=NULL;           // -> last digit of decimal part
  490|  5.40M|  const char *c;                   // work
  491|  5.40M|  Unit  *up;                       // ..
  ------------------
  |  |   94|  5.40M|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  5.40M|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
  492|  5.40M|  #if DECDPUN>1
  493|  5.40M|  Int   cut, out;                  // ..
  ------------------
  |  |   92|  5.40M|  #define Int    int32_t
  ------------------
  494|  5.40M|  #endif
  495|  5.40M|  Int   residue;                   // rounding residue
  ------------------
  |  |   92|  5.40M|  #define Int    int32_t
  ------------------
  496|  5.40M|  uInt  status=0;                  // error code
  ------------------
  |  |   93|  5.40M|  #define uInt   uint32_t
  ------------------
  497|       |
  498|       |  #if DECCHECK
  499|       |  if (decCheckOperands(DECUNRESU, DECUNUSED, DECUNUSED, set))
  500|       |    return decNumberZero(dn);
  501|       |  #endif
  502|       |
  503|  5.40M|  do {                             // status & malloc protection
  504|  40.7M|    for (c=chars;; c++) {          // -> input character
  505|  40.7M|      if (*c>='0' && *c<='9') {    // test for Arabic digit
  ------------------
  |  Branch (505:11): [True: 35.4M, False: 5.38M]
  |  Branch (505:22): [True: 35.3M, False: 33.7k]
  ------------------
  506|  35.3M|        last=c;
  507|  35.3M|        d++;                       // count of real digits
  508|  35.3M|        continue;                  // still in decimal part
  509|  35.3M|        }
  510|  5.41M|      if (*c=='.' && dotchar==NULL) { // first '.'
  ------------------
  |  Branch (510:11): [True: 7.19k, False: 5.41M]
  |  Branch (510:22): [True: 7.19k, False: 1]
  ------------------
  511|  7.19k|        dotchar=c;                 // record offset into decimal part
  512|  7.19k|        if (c==cfirst) cfirst++;   // first digit must follow
  ------------------
  |  Branch (512:13): [True: 1.00k, False: 6.19k]
  ------------------
  513|  7.19k|        continue;}
  514|  5.41M|      if (c==chars) {              // first in string...
  ------------------
  |  Branch (514:11): [True: 8.11k, False: 5.40M]
  ------------------
  515|  8.11k|        if (*c=='-') {             // valid - sign
  ------------------
  |  Branch (515:13): [True: 970, False: 7.14k]
  ------------------
  516|    970|          cfirst++;
  517|    970|          bits=DECNEG;
  ------------------
  |  |   31|    970|  #define DECNEG    0x80      /* Sign; 1=negative, 0=positive or zero */
  ------------------
  518|    970|          continue;}
  519|  7.14k|        if (*c=='+') {             // valid + sign
  ------------------
  |  Branch (519:13): [True: 4.19k, False: 2.95k]
  ------------------
  520|  4.19k|          cfirst++;
  521|  4.19k|          continue;}
  522|  7.14k|        }
  523|       |      // *c is not a digit, or a valid +, -, or '.'
  524|  5.40M|      break;
  525|  5.41M|      } // c
  526|       |
  527|  5.40M|    if (last==NULL) {              // no digits yet
  ------------------
  |  Branch (527:9): [True: 2.98k, False: 5.40M]
  ------------------
  528|  2.98k|      status=DEC_Conversion_syntax;// assume the worst
  ------------------
  |  |  128|  2.98k|    #define DEC_Conversion_syntax    0x00000001
  ------------------
  529|  2.98k|      if (*c=='\0') break;         // and no more to come...
  ------------------
  |  Branch (529:11): [True: 29, False: 2.95k]
  ------------------
  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.95k|      if (dotchar!=NULL) break;    // .. unless had a dot
  ------------------
  |  Branch (535:11): [True: 1, False: 2.95k]
  ------------------
  536|  2.95k|      decNumberZero(dn);           // be optimistic
  537|  2.95k|      if (decBiStr(c, "infinity", "INFINITY")
  ------------------
  |  Branch (537:11): [True: 213, False: 2.73k]
  ------------------
  538|  2.73k|       || decBiStr(c, "inf", "INF")) {
  ------------------
  |  Branch (538:11): [True: 340, False: 2.39k]
  ------------------
  539|    553|        dn->bits=bits | DECINF;
  ------------------
  |  |   32|    553|  #define DECINF    0x40      /* 1=Infinity                           */
  ------------------
  540|    553|        status=0;                  // is OK
  541|    553|        break; // all done
  542|    553|        }
  543|       |      // a NaN expected
  544|       |      // 2003.09.10 NaNs are now permitted to have a sign
  545|  2.39k|      dn->bits=bits | DECNAN;      // assume simple NaN
  ------------------
  |  |   33|  2.39k|  #define DECNAN    0x20      /* 1=NaN                                */
  ------------------
  546|  2.39k|      if (*c=='s' || *c=='S') {    // looks like an sNaN
  ------------------
  |  Branch (546:11): [True: 195, False: 2.20k]
  |  Branch (546:22): [True: 196, False: 2.00k]
  ------------------
  547|    391|        c++;
  548|    391|        dn->bits=bits | DECSNAN;
  ------------------
  |  |   34|    391|  #define DECSNAN   0x10      /* 1=sNaN                               */
  ------------------
  549|    391|        }
  550|  2.39k|      if (*c!='n' && *c!='N') break;    // check caseless "NaN"
  ------------------
  |  Branch (550:11): [True: 1.21k, False: 1.18k]
  |  Branch (550:22): [True: 365, False: 854]
  ------------------
  551|  2.03k|      c++;
  552|  2.03k|      if (*c!='a' && *c!='A') break;    // ..
  ------------------
  |  Branch (552:11): [True: 583, False: 1.45k]
  |  Branch (552:22): [True: 49, False: 534]
  ------------------
  553|  1.98k|      c++;
  554|  1.98k|      if (*c!='n' && *c!='N') break;    // ..
  ------------------
  |  Branch (554:11): [True: 1.04k, False: 945]
  |  Branch (554:22): [True: 39, False: 1.00k]
  ------------------
  555|  1.94k|      c++;
  556|       |      // now either nothing, or nnnn payload, expected
  557|       |      // -> start of integer and skip leading 0s [including plain 0]
  558|  2.37k|      for (cfirst=c; *cfirst=='0';) cfirst++;
  ------------------
  |  Branch (558:22): [True: 429, False: 1.94k]
  ------------------
  559|  1.94k|      if (*cfirst=='\0') {         // "NaN" or "sNaN", maybe with all 0s
  ------------------
  |  Branch (559:11): [True: 1.87k, False: 68]
  ------------------
  560|  1.87k|        status=0;                  // it's good
  561|  1.87k|        break;                     // ..
  562|  1.87k|        }
  563|       |      // something other than 0s; setup last and d as usual [no dots]
  564|  1.11M|      for (c=cfirst;; c++, d++) {
  565|  1.11M|        if (*c<'0' || *c>'9') break; // test for Arabic digit
  ------------------
  |  Branch (565:13): [True: 62, False: 1.11M]
  |  Branch (565:23): [True: 6, False: 1.11M]
  ------------------
  566|  1.11M|        last=c;
  567|  1.11M|        }
  568|     68|      if (*c!='\0') break;         // not all digits
  ------------------
  |  Branch (568:11): [True: 24, False: 44]
  ------------------
  569|     44|      if (d>set->digits-1) {
  ------------------
  |  Branch (569:11): [True: 0, False: 44]
  ------------------
  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|     44|      status=0;                    // syntax is OK
  577|     44|      bits=dn->bits;               // for copy-back
  578|     44|      } // last==NULL
  579|       |
  580|  5.40M|     else if (*c!='\0') {          // more to process...
  ------------------
  |  Branch (580:15): [True: 31.0k, False: 5.37M]
  ------------------
  581|       |      // had some digits; exponent is only valid sequence now
  582|  31.0k|      Flag nege;                   // 1=negative exponent
  ------------------
  |  |   87|  31.0k|  #define Flag   uint8_t
  ------------------
  583|  31.0k|      const char *firstexp;        // -> first significant exponent digit
  584|  31.0k|      status=DEC_Conversion_syntax;// assume the worst
  ------------------
  |  |  128|  31.0k|    #define DEC_Conversion_syntax    0x00000001
  ------------------
  585|  31.0k|      uInt expa=0;                 // accumulator for exponent
  ------------------
  |  |   93|  31.0k|  #define uInt   uint32_t
  ------------------
  586|  31.0k|      if (*c!='e' && *c!='E') break;
  ------------------
  |  Branch (586:11): [True: 29.1k, False: 1.88k]
  |  Branch (586:22): [True: 37, False: 29.1k]
  ------------------
  587|       |      /* Found 'e' or 'E' -- now process explicit exponent */
  588|       |      // 1998.07.11: sign no longer required
  589|  31.0k|      nege=0;
  590|  31.0k|      c++;                         // to (possible) sign
  591|  31.0k|      if (*c=='-') {nege=1; c++;}
  ------------------
  |  Branch (591:11): [True: 14.9k, False: 16.1k]
  ------------------
  592|  16.1k|       else if (*c=='+') c++;
  ------------------
  |  Branch (592:17): [True: 197, False: 15.9k]
  ------------------
  593|  31.0k|      if (*c=='\0') break;
  ------------------
  |  Branch (593:11): [True: 30, False: 31.0k]
  ------------------
  594|       |
  595|  31.8k|      for (; *c=='0' && *(c+1)!='\0';) c++;  // strip insignificant zeros
  ------------------
  |  Branch (595:14): [True: 970, False: 30.8k]
  |  Branch (595:25): [True: 854, False: 116]
  ------------------
  596|  31.0k|      firstexp=c;                            // save exponent digit place
  597|  2.00M|      for (; ;c++) {
  598|  2.00M|        if (*c<'0' || *c>'9') break;         // not a digit
  ------------------
  |  Branch (598:13): [True: 31.0k, False: 1.97M]
  |  Branch (598:23): [True: 8, False: 1.97M]
  ------------------
  599|  1.97M|        expa=X10(expa)+(Int)*c-(Int)'0';
  ------------------
  |  |  163|  1.97M|  #define X10(i)  (((i)<<1)+((i)<<3))
  ------------------
  600|  1.97M|        } // c
  601|       |      // if not now on a '\0', *c must not be a digit
  602|  31.0k|      if (*c!='\0') break;
  ------------------
  |  Branch (602:11): [True: 29, False: 30.9k]
  ------------------
  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|  30.9k|      if (c>=firstexp+9+1) {
  ------------------
  |  Branch (607:11): [True: 24.1k, False: 6.80k]
  ------------------
  608|  24.1k|        if (c>firstexp+9+1 || *firstexp>'1') expa=DECNUMMAXE*2;
  ------------------
  |  |  183|  7.57k|  #define DECNUMMAXE 999999999  /* maximum adjusted exponent ditto    */
  ------------------
  |  Branch (608:13): [True: 7.03k, False: 17.1k]
  |  Branch (608:31): [True: 537, False: 16.6k]
  ------------------
  609|       |        // [up to 1999999999 is OK, for example 1E-1000000998]
  610|  24.1k|        }
  611|  30.9k|      exponent=(Int)expa;               // save exponent
  612|  30.9k|      if (nege) exponent=-exponent;     // was negative
  ------------------
  |  Branch (612:11): [True: 14.9k, False: 16.0k]
  ------------------
  613|  30.9k|      status=0;                         // is OK
  614|  30.9k|      } // 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.40M|    if (*cfirst=='0') {                 // [cfirst has stepped over .]
  ------------------
  |  Branch (620:9): [True: 2.49M, False: 2.90M]
  ------------------
  621|  2.52M|      for (c=cfirst; c<last; c++, cfirst++) {
  ------------------
  |  Branch (621:22): [True: 30.4k, False: 2.49M]
  ------------------
  622|  30.4k|        if (*c=='.') continue;          // ignore dots
  ------------------
  |  Branch (622:13): [True: 4.26k, False: 26.1k]
  ------------------
  623|  26.1k|        if (*c!='0') break;             // non-zero found
  ------------------
  |  Branch (623:13): [True: 348, False: 25.7k]
  ------------------
  624|  25.7k|        d--;                            // 0 stripped
  625|  25.7k|        } // 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.49M|      } // at least one leading 0
  634|       |
  635|       |    // Handle decimal point...
  636|  5.40M|    if (dotchar!=NULL && dotchar<last)  // non-trailing '.' found?
  ------------------
  |  Branch (636:9): [True: 7.18k, False: 5.39M]
  |  Branch (636:26): [True: 6.94k, False: 241]
  ------------------
  637|  6.94k|      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.40M|    if (d<=set->digits) res=dn->lsu;    // fits into supplied decNumber
  ------------------
  |  Branch (642:9): [True: 5.40M, 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.40M|    #if DECDPUN>1
  657|  5.40M|    out=0;                         // accumulator
  658|  5.40M|    up=res+D2U(d)-1;               // -> msu
  ------------------
  |  |  264|  5.40M|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|  5.40M|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|  1.06k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|  1.06k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 5.40M, False: 1.06k]
  |  |  ------------------
  ------------------
  659|  5.40M|    cut=d-(up-res)*DECDPUN;        // digits in top unit
  ------------------
  |  |   43|  5.40M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  660|  34.7M|    for (c=cfirst;; c++) {         // along the digits
  661|  34.7M|      if (*c=='.') continue;       // ignore '.' [don't decrement cut]
  ------------------
  |  Branch (661:11): [True: 1.68k, False: 34.7M]
  ------------------
  662|  34.7M|      out=X10(out)+(Int)*c-(Int)'0';
  ------------------
  |  |  163|  34.7M|  #define X10(i)  (((i)<<1)+((i)<<3))
  ------------------
  663|  34.7M|      if (c==last) break;          // done [never get to trailing '.']
  ------------------
  |  Branch (663:11): [True: 5.40M, False: 29.3M]
  ------------------
  664|  29.3M|      cut--;
  665|  29.3M|      if (cut>0) continue;         // more for this unit
  ------------------
  |  Branch (665:11): [True: 19.6M, False: 9.75M]
  ------------------
  666|  9.75M|      *up=(Unit)out;               // write unit
  667|  9.75M|      up--;                        // prepare for unit below..
  668|  9.75M|      cut=DECDPUN;                 // ..
  ------------------
  |  |   43|  9.75M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  669|  9.75M|      out=0;                       // ..
  670|  9.75M|      } // c
  671|  5.40M|    *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.40M|    dn->bits=bits;
  684|  5.40M|    dn->exponent=exponent;
  685|  5.40M|    dn->digits=d;
  686|       |
  687|       |    // if not in number (too long) shorten into the number
  688|  5.40M|    if (d>set->digits) {
  ------------------
  |  Branch (688:9): [True: 0, False: 5.40M]
  ------------------
  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.40M|     else { // no rounding, but may still have overflow or subnormal
  695|       |      // [these tests are just for performance; finalize repeats them]
  696|  5.40M|      if ((dn->exponent-1<set->emin-dn->digits)
  ------------------
  |  Branch (696:11): [True: 12.0k, False: 5.38M]
  ------------------
  697|  5.38M|       || (dn->exponent-1>set->emax-set->digits)) {
  ------------------
  |  Branch (697:11): [True: 12.6k, False: 5.37M]
  ------------------
  698|  24.6k|        residue=0;
  699|  24.6k|        decFinalize(dn, set, &residue, &status);
  700|  24.6k|        }
  701|  5.40M|      }
  702|       |    // decNumberShow(dn);
  703|  5.40M|    } while(0);                         // [for break]
  ------------------
  |  Branch (703:13): [Folded, False: 5.40M]
  ------------------
  704|       |
  705|  5.40M|  if (allocres!=NULL) free(allocres);   // drop any storage used
  ------------------
  |  Branch (705:7): [True: 0, False: 5.40M]
  ------------------
  706|  5.40M|  if (status!=0) decStatus(dn, status, set);
  ------------------
  |  Branch (706:7): [True: 24.7k, False: 5.38M]
  ------------------
  707|  5.40M|  return dn;
  708|  5.40M|  } /* decNumberFromString */
decNumberZero:
 3588|  15.3k|decNumber * decNumberZero(decNumber *dn) {
 3589|       |
 3590|       |  #if DECCHECK
 3591|       |  if (decCheckOperands(dn, DECUNUSED, DECUNUSED, DECUNCONT)) return dn;
 3592|       |  #endif
 3593|       |
 3594|  15.3k|  dn->bits=0;
 3595|  15.3k|  dn->exponent=0;
 3596|  15.3k|  dn->digits=1;
 3597|  15.3k|  dn->lsu[0]=0;
 3598|  15.3k|  return dn;
 3599|  15.3k|  } // decNumberZero
decNumber.c:decUnitAddSub:
 6339|  2.69k|                         Unit *c, Int m) {
 6340|  2.69k|  const Unit *alsu=a;              // A lsu [need to remember it]
 6341|  2.69k|  Unit *clsu=c;                    // C ditto
  ------------------
  |  |   94|  2.69k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  2.69k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6342|  2.69k|  Unit *minC;                      // low water mark for C
  ------------------
  |  |   94|  2.69k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  2.69k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6343|  2.69k|  Unit *maxC;                      // high water mark for C
  ------------------
  |  |   94|  2.69k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  2.69k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6344|  2.69k|  eInt carry=0;                    // carry integer (could be Long)
  ------------------
  |  |  203|  2.69k|  #define eInt  Int           // extended integer
  |  |  ------------------
  |  |  |  |   92|  2.69k|  #define Int    int32_t
  |  |  ------------------
  ------------------
 6345|  2.69k|  Int  add;                        // work
  ------------------
  |  |   92|  2.69k|  #define Int    int32_t
  ------------------
 6346|  2.69k|  #if DECDPUN<=4                   // myriadal, millenary, etc.
 6347|  2.69k|  Int  est;                        // estimated quotient
  ------------------
  |  |   92|  2.69k|  #define Int    int32_t
  ------------------
 6348|  2.69k|  #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.69k|  maxC=c+alength;                  // A is usually the longer
 6356|  2.69k|  minC=c+blength;                  // .. and B the shorter
 6357|  2.69k|  if (bshift!=0) {                 // B is shifted; low As copy across
  ------------------
  |  Branch (6357:7): [True: 0, False: 2.69k]
  ------------------
 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.69k|  if (minC>maxC) { // swap
  ------------------
  |  Branch (6369:7): [True: 0, False: 2.69k]
  ------------------
 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|  5.39k|  for (; c<minC; c++) {
  ------------------
  |  Branch (6379:10): [True: 2.69k, False: 2.69k]
  ------------------
 6380|  2.69k|    carry+=*a;
 6381|  2.69k|    a++;
 6382|  2.69k|    carry+=((eInt)*b)*m;                // [special-casing m=1/-1
 6383|  2.69k|    b++;                                // here is not a win]
 6384|       |    // here carry is new Unit of digits; it could be +ve or -ve
 6385|  2.69k|    if ((ueInt)carry<=DECDPUNMAX) {     // fastpath 0-DECDPUNMAX
  ------------------
  |  |  209|  2.69k|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6385:9): [True: 2.39k, False: 306]
  ------------------
 6386|  2.39k|      *c=(Unit)carry;
 6387|  2.39k|      carry=0;
 6388|  2.39k|      continue;
 6389|  2.39k|      }
 6390|       |    #if DECDPUN==4                           // use divide-by-multiply
 6391|       |      if (carry>=0) {
 6392|       |        est=(((ueInt)carry>>11)*53687)>>18;
 6393|       |        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder
 6394|       |        carry=est;                           // likely quotient [89%]
 6395|       |        if (*c<DECDPUNMAX+1) continue;       // estimate was correct
 6396|       |        carry++;
 6397|       |        *c-=DECDPUNMAX+1;
 6398|       |        continue;
 6399|       |        }
 6400|       |      // negative case
 6401|       |      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive
 6402|       |      est=(((ueInt)carry>>11)*53687)>>18;
 6403|       |      *c=(Unit)(carry-est*(DECDPUNMAX+1));
 6404|       |      carry=est-(DECDPUNMAX+1);              // correctly negative
 6405|       |      if (*c<DECDPUNMAX+1) continue;         // was OK
 6406|       |      carry++;
 6407|       |      *c-=DECDPUNMAX+1;
 6408|       |    #elif DECDPUN==3
 6409|    306|      if (carry>=0) {
  ------------------
  |  Branch (6409:11): [True: 306, False: 0]
  ------------------
 6410|    306|        est=(((ueInt)carry>>3)*16777)>>21;
 6411|    306|        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder
  ------------------
  |  |  209|    306|    #define DECDPUNMAX 999
  ------------------
 6412|    306|        carry=est;                           // likely quotient [99%]
 6413|    306|        if (*c<DECDPUNMAX+1) continue;       // estimate was correct
  ------------------
  |  |  209|    306|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6413:13): [True: 0, False: 306]
  ------------------
 6414|    306|        carry++;
 6415|    306|        *c-=DECDPUNMAX+1;
  ------------------
  |  |  209|    306|    #define DECDPUNMAX 999
  ------------------
 6416|    306|        continue;
 6417|    306|        }
 6418|       |      // negative case
 6419|      0|      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
                    carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
 6420|      0|      est=(((ueInt)carry>>3)*16777)>>21;
 6421|      0|      *c=(Unit)(carry-est*(DECDPUNMAX+1));
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
 6422|      0|      carry=est-(DECDPUNMAX+1);              // correctly negative
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
 6423|      0|      if (*c<DECDPUNMAX+1) continue;         // was OK
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6423:11): [True: 0, False: 0]
  ------------------
 6424|      0|      carry++;
 6425|      0|      *c-=DECDPUNMAX+1;
  ------------------
  |  |  209|      0|    #define DECDPUNMAX 999
  ------------------
 6426|       |    #elif DECDPUN<=2
 6427|       |      // Can use QUOT10 as carry <= 4 digits
 6428|       |      if (carry>=0) {
 6429|       |        est=QUOT10(carry, DECDPUN);
 6430|       |        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder
 6431|       |        carry=est;                           // quotient
 6432|       |        continue;
 6433|       |        }
 6434|       |      // negative case
 6435|       |      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive
 6436|       |      est=QUOT10(carry, DECDPUN);
 6437|       |      *c=(Unit)(carry-est*(DECDPUNMAX+1));
 6438|       |      carry=est-(DECDPUNMAX+1);              // correctly negative
 6439|       |    #else
 6440|       |      // remainder operator is undefined if negative, so must test
 6441|       |      if ((ueInt)carry<(DECDPUNMAX+1)*2) {   // fastpath carry +1
 6442|       |        *c=(Unit)(carry-(DECDPUNMAX+1));     // [helps additions]
 6443|       |        carry=1;
 6444|       |        continue;
 6445|       |        }
 6446|       |      if (carry>=0) {
 6447|       |        *c=(Unit)(carry%(DECDPUNMAX+1));
 6448|       |        carry=carry/(DECDPUNMAX+1);
 6449|       |        continue;
 6450|       |        }
 6451|       |      // negative case
 6452|       |      carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); // make positive
 6453|       |      *c=(Unit)(carry%(DECDPUNMAX+1));
 6454|       |      carry=carry/(DECDPUNMAX+1)-(DECDPUNMAX+1);
 6455|       |    #endif
 6456|      0|    } // c
 6457|       |
 6458|       |  // now may have one or other to complete
 6459|       |  // [pretest to avoid loop setup/shutdown]
 6460|  1.87M|  if (c<maxC) for (; c<maxC; c++) {
  ------------------
  |  Branch (6460:7): [True: 1.21k, False: 1.48k]
  |  Branch (6460:22): [True: 1.87M, False: 1.21k]
  ------------------
 6461|  1.87M|    if (a<alsu+alength) {               // still in A
  ------------------
  |  Branch (6461:9): [True: 1.87M, False: 0]
  ------------------
 6462|  1.87M|      carry+=*a;
 6463|  1.87M|      a++;
 6464|  1.87M|      }
 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.87M|    if ((ueInt)carry<=DECDPUNMAX) {     // fastpath 0-DECDPUNMAX
  ------------------
  |  |  209|  1.87M|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6471:9): [True: 1.38M, False: 489k]
  ------------------
 6472|  1.38M|      *c=(Unit)carry;
 6473|  1.38M|      carry=0;
 6474|  1.38M|      continue;
 6475|  1.38M|      }
 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|   489k|      if (carry>=0) {
  ------------------
  |  Branch (6496:11): [True: 489k, False: 0]
  ------------------
 6497|   489k|        est=(((ueInt)carry>>3)*16777)>>21;
 6498|   489k|        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder
  ------------------
  |  |  209|   489k|    #define DECDPUNMAX 999
  ------------------
 6499|   489k|        carry=est;                           // likely quotient [99%]
 6500|   489k|        if (*c<DECDPUNMAX+1) continue;       // estimate was correct
  ------------------
  |  |  209|   489k|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6500:13): [True: 0, False: 489k]
  ------------------
 6501|   489k|        carry++;
 6502|   489k|        *c-=DECDPUNMAX+1;
  ------------------
  |  |  209|   489k|    #define DECDPUNMAX 999
  ------------------
 6503|   489k|        continue;
 6504|   489k|        }
 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.69k|  if (carry==0) return c-clsu;     // no carry, so no more to do
  ------------------
  |  Branch (6546:7): [True: 2.69k, 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|  11.1k|                          uInt *status) {
 7072|  11.1k|  Int  bump;                  // 1 if coefficient needs to be incremented
  ------------------
  |  |   92|  11.1k|  #define Int    int32_t
  ------------------
 7073|       |                              // -1 if coefficient needs to be decremented
 7074|       |
 7075|  11.1k|  if (residue==0) return;     // nothing to apply
  ------------------
  |  Branch (7075:7): [True: 2.88k, False: 8.26k]
  ------------------
 7076|       |
 7077|  8.26k|  bump=0;                     // assume a smooth ride
 7078|       |
 7079|       |  // now decide whether, and how, to round, depending on mode
 7080|  8.26k|  switch (set->round) {
 7081|      0|    case DEC_ROUND_05UP: {    // round zero or five up (for reround)
  ------------------
  |  Branch (7081:5): [True: 0, False: 8.26k]
  ------------------
 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.26k]
  ------------------
 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.26k]
  ------------------
 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.26k]
  ------------------
 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.26k|    case DEC_ROUND_HALF_UP: {
  ------------------
  |  Branch (7110:5): [True: 8.26k, False: 0]
  ------------------
 7111|  8.26k|      if (residue>=5) bump=1;
  ------------------
  |  Branch (7111:11): [True: 3.81k, False: 4.44k]
  ------------------
 7112|  8.26k|      break;} // r-h-u
 7113|       |
 7114|      0|    case DEC_ROUND_UP: {
  ------------------
  |  Branch (7114:5): [True: 0, False: 8.26k]
  ------------------
 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.26k]
  ------------------
 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.26k]
  ------------------
 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.26k]
  ------------------
 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.26k|    } // switch
 7147|       |
 7148|       |  // now bump the number, up or down, if need be
 7149|  8.26k|  if (bump==0) return;                       // no action required
  ------------------
  |  Branch (7149:7): [True: 4.44k, False: 3.81k]
  ------------------
 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.81k|  if (bump>0) {
  ------------------
  |  Branch (7156:7): [True: 3.81k, False: 0]
  ------------------
 7157|  3.81k|    Unit *up;                                // work
  ------------------
  |  |   94|  3.81k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  3.81k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 7158|  3.81k|    uInt count=dn->digits;                   // digits to be checked
  ------------------
  |  |   93|  3.81k|  #define uInt   uint32_t
  ------------------
 7159|  4.85M|    for (up=dn->lsu; ; up++) {
 7160|  4.85M|      if (count<=DECDPUN) {
  ------------------
  |  |   43|  4.85M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (7160:11): [True: 2.80k, False: 4.85M]
  ------------------
 7161|       |        // this is the last Unit (the msu)
 7162|  2.80k|        if (*up!=powers[count]-1) break;     // not still 9s
  ------------------
  |  |  177|  2.80k|#define powers      DECPOWERS      // old internal name
  ------------------
  |  Branch (7162:13): [True: 1.68k, False: 1.11k]
  ------------------
 7163|       |        // here if it, too, is all nines
 7164|  1.11k|        *up=(Unit)powers[count-1];           // here 999 -> 100 etc.
  ------------------
  |  |  177|  1.11k|#define powers      DECPOWERS      // old internal name
  ------------------
 7165|  4.36M|        for (up=up-1; up>=dn->lsu; up--) *up=0; // others all to 0
  ------------------
  |  Branch (7165:23): [True: 4.36M, False: 1.11k]
  ------------------
 7166|  1.11k|        dn->exponent++;                      // and bump exponent
 7167|       |        // [which, very rarely, could cause Overflow...]
 7168|  1.11k|        if ((dn->exponent+dn->digits)>set->emax+1) {
  ------------------
  |  Branch (7168:13): [True: 0, False: 1.11k]
  ------------------
 7169|      0|          decSetOverflow(dn, set, status);
 7170|      0|          }
 7171|  1.11k|        return;                              // done
 7172|  2.80k|        }
 7173|       |      // a full unit to check, with more to come
 7174|  4.85M|      if (*up!=DECDPUNMAX) break;            // not still 9s
  ------------------
  |  |  209|  4.85M|    #define DECDPUNMAX 999
  ------------------
  |  Branch (7174:11): [True: 1.00k, False: 4.85M]
  ------------------
 7175|  4.85M|      count-=DECDPUN;
  ------------------
  |  |   43|  4.85M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 7176|  4.85M|      } // up
 7177|  3.81k|    } // 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.69k|  decUnitAddSub(dn->lsu, D2U(dn->digits), uarrone, 1, 0, dn->lsu, bump);
  ------------------
  |  |  264|  2.69k|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|  2.69k|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    252|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    252|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 2.44k, False: 252]
  |  |  ------------------
  ------------------
 7220|  2.69k|  } // decApplyRound
decNumber.c:decSetOverflow:
 7348|  12.3k|static void decSetOverflow(decNumber *dn, decContext *set, uInt *status) {
 7349|  12.3k|  Flag needmax=0;                  // result is maximum finite value
  ------------------
  |  |   87|  12.3k|  #define Flag   uint8_t
  ------------------
 7350|  12.3k|  uByte sign=dn->bits&DECNEG;      // clean and save sign bit
  ------------------
  |  |   89|  12.3k|  #define uByte  uint8_t
  ------------------
                uByte sign=dn->bits&DECNEG;      // clean and save sign bit
  ------------------
  |  |   31|  12.3k|  #define DECNEG    0x80      /* Sign; 1=negative, 0=positive or zero */
  ------------------
 7351|       |
 7352|  12.3k|  if (ISZERO(dn)) {                // zero does not overflow magnitude
  ------------------
  |  |  255|  12.3k|  #define ISZERO(dn) decNumberIsZero(dn)     /* now just a local name */
  |  |  ------------------
  |  |  |  |  177|  12.3k|  #define decNumberIsZero(dn)      (*(dn)->lsu==0 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (177:37): [True: 843, False: 11.5k]
  |  |  |  |  ------------------
  |  |  |  |  178|  12.3k|                                    && (dn)->digits==1 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:40): [True: 634, False: 209]
  |  |  |  |  ------------------
  |  |  |  |  179|  12.3k|                                    && (((dn)->bits&DECSPECIAL)==0))
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|    634|  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|    634|  #define DECINF    0x40      /* 1=Infinity                           */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   33|    634|  #define DECNAN    0x20      /* 1=NaN                                */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   34|    634|  #define DECSNAN   0x10      /* 1=sNaN                               */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (179:40): [True: 634, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7353|    634|    Int emax=set->emax;                      // limit value
  ------------------
  |  |   92|    634|  #define Int    int32_t
  ------------------
 7354|    634|    if (set->clamp) emax-=set->digits-1;     // lower if clamping
  ------------------
  |  Branch (7354:9): [True: 0, False: 634]
  ------------------
 7355|    634|    if (dn->exponent>emax) {                 // clamp required
  ------------------
  |  Branch (7355:9): [True: 634, False: 0]
  ------------------
 7356|    634|      dn->exponent=emax;
 7357|    634|      *status|=DEC_Clamped;
  ------------------
  |  |  140|    634|    #define DEC_Clamped              0x00000400
  ------------------
 7358|    634|      }
 7359|    634|    return;
 7360|    634|    }
 7361|       |
 7362|  11.7k|  decNumberZero(dn);
 7363|  11.7k|  switch (set->round) {
 7364|      0|    case DEC_ROUND_DOWN: {
  ------------------
  |  Branch (7364:5): [True: 0, False: 11.7k]
  ------------------
 7365|      0|      needmax=1;                   // never Infinity
 7366|      0|      break;} // r-d
 7367|      0|    case DEC_ROUND_05UP: {
  ------------------
  |  Branch (7367:5): [True: 0, False: 11.7k]
  ------------------
 7368|      0|      needmax=1;                   // never Infinity
 7369|      0|      break;} // r-05
 7370|      0|    case DEC_ROUND_CEILING: {
  ------------------
  |  Branch (7370:5): [True: 0, False: 11.7k]
  ------------------
 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.7k]
  ------------------
 7374|      0|      if (!sign) needmax=1;        // Infinity if negative
  ------------------
  |  Branch (7374:11): [True: 0, False: 0]
  ------------------
 7375|      0|      break;} // r-f
 7376|  11.7k|    default: break;                // Infinity in all other cases
  ------------------
  |  Branch (7376:5): [True: 11.7k, False: 0]
  ------------------
 7377|  11.7k|    }
 7378|  11.7k|  if (needmax) {
  ------------------
  |  Branch (7378:7): [True: 0, False: 11.7k]
  ------------------
 7379|      0|    decSetMaxValue(dn, set);
 7380|      0|    dn->bits=sign;                 // set sign
 7381|      0|    }
 7382|  11.7k|   else dn->bits=sign|DECINF;      // Value is +/-Infinity
  ------------------
  |  |   32|  11.7k|  #define DECINF    0x40      /* 1=Infinity                           */
  ------------------
 7383|  11.7k|  *status|=DEC_Overflow | DEC_Inexact | DEC_Rounded;
  ------------------
  |  |  139|  11.7k|    #define DEC_Overflow             0x00000200
  ------------------
                *status|=DEC_Overflow | DEC_Inexact | DEC_Rounded;
  ------------------
  |  |  133|  11.7k|    #define DEC_Inexact              0x00000020
  ------------------
                *status|=DEC_Overflow | DEC_Inexact | DEC_Rounded;
  ------------------
  |  |  141|  11.7k|    #define DEC_Rounded              0x00000800
  ------------------
 7384|  11.7k|  } // decSetOverflow
decNumber.c:decShiftToMost:
 6685|  1.11k|static Int decShiftToMost(Unit *uar, Int digits, Int shift) {
 6686|  1.11k|  Unit  *target, *source, *first;  // work
  ------------------
  |  |   94|  1.11k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  1.11k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6687|  1.11k|  Int   cut;                       // odd 0's to add
  ------------------
  |  |   92|  1.11k|  #define Int    int32_t
  ------------------
 6688|  1.11k|  uInt  next;                      // work
  ------------------
  |  |   93|  1.11k|  #define uInt   uint32_t
  ------------------
 6689|       |
 6690|  1.11k|  if (shift==0) return digits;     // [fastpath] nothing to do
  ------------------
  |  Branch (6690:7): [True: 0, False: 1.11k]
  ------------------
 6691|  1.11k|  if ((digits+shift)<=DECDPUN) {   // [fastpath] single-unit case
  ------------------
  |  |   43|  1.11k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6691:7): [True: 218, False: 899]
  ------------------
 6692|    218|    *uar=(Unit)(*uar*powers[shift]);
  ------------------
  |  |  177|    218|#define powers      DECPOWERS      // old internal name
  ------------------
 6693|    218|    return digits+shift;
 6694|    218|    }
 6695|       |
 6696|    899|  next=0;                          // all paths
 6697|    899|  source=uar+D2U(digits)-1;        // where msu comes from
  ------------------
  |  |  264|    899|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|    899|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    309|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    309|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 590, False: 309]
  |  |  ------------------
  ------------------
 6698|    899|  target=source+D2U(shift);        // where upper part of first cut goes
  ------------------
  |  |  264|    899|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|    899|  #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: 899, False: 0]
  |  |  ------------------
  ------------------
 6699|    899|  cut=DECDPUN-MSUDIGITS(shift);    // where to slice
  ------------------
  |  |   43|    899|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
                cut=DECDPUN-MSUDIGITS(shift);    // where to slice
  ------------------
  |  |  271|    899|  #define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN)
  |  |  ------------------
  |  |  |  |  264|    899|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  |  |  ------------------
  |  |  |  |  |  |  249|    899|  #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: 899, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 #define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    899|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  ------------------
 6700|    899|  if (cut==0) {                    // unit-boundary case
  ------------------
  |  Branch (6700:7): [True: 0, False: 899]
  ------------------
 6701|      0|    for (; source>=uar; source--, target--) *target=*source;
  ------------------
  |  Branch (6701:12): [True: 0, False: 0]
  ------------------
 6702|      0|    }
 6703|    899|   else {
 6704|    899|    first=uar+D2U(digits+shift)-1; // where msu of source will end up
  ------------------
  |  |  264|    899|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|    899|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    463|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    463|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 436, False: 463]
  |  |  ------------------
  ------------------
 6705|  4.36M|    for (; source>=uar; source--, target--) {
  ------------------
  |  Branch (6705:12): [True: 4.36M, False: 899]
  ------------------
 6706|       |      // split the source Unit and accumulate remainder for next
 6707|  4.36M|      #if DECDPUN<=4
 6708|  4.36M|        uInt quot=QUOT10(*source, cut);
  ------------------
  |  |   93|  4.36M|  #define uInt   uint32_t
  ------------------
                      uInt quot=QUOT10(*source, cut);
  ------------------
  |  |  210|  4.36M|  #define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17)
  ------------------
 6709|  4.36M|        uInt rem=*source-quot*powers[cut];
  ------------------
  |  |   93|  4.36M|  #define uInt   uint32_t
  ------------------
                      uInt rem=*source-quot*powers[cut];
  ------------------
  |  |  177|  4.36M|#define powers      DECPOWERS      // old internal name
  ------------------
 6710|  4.36M|        next+=quot;
 6711|       |      #else
 6712|       |        uInt rem=*source%powers[cut];
 6713|       |        next+=*source/powers[cut];
 6714|       |      #endif
 6715|  4.36M|      if (target<=first) *target=(Unit)next;   // write to target iff valid
  ------------------
  |  Branch (6715:11): [True: 4.36M, False: 659]
  ------------------
 6716|  4.36M|      next=rem*powers[DECDPUN-cut];            // save remainder for next Unit
  ------------------
  |  |  177|  4.36M|#define powers      DECPOWERS      // old internal name
  ------------------
                    next=rem*powers[DECDPUN-cut];            // save remainder for next Unit
  ------------------
  |  |   43|  4.36M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 6717|  4.36M|      }
 6718|    899|    } // shift-move
 6719|       |
 6720|       |  // propagate any partial unit to one below and clear the rest
 6721|  1.79k|  for (; target>=uar; target--) {
  ------------------
  |  Branch (6721:10): [True: 899, False: 899]
  ------------------
 6722|    899|    *target=(Unit)next;
 6723|    899|    next=0;
 6724|    899|    }
 6725|    899|  return digits+shift;
 6726|  1.11k|  } // decShiftToMost
decNumber.c:decSetCoeff:
 6890|  11.1k|                        Int len, Int *residue, uInt *status) {
 6891|  11.1k|  Int   discard;              // number of digits to discard
  ------------------
  |  |   92|  11.1k|  #define Int    int32_t
  ------------------
 6892|  11.1k|  uInt  cut;                  // cut point in Unit
  ------------------
  |  |   93|  11.1k|  #define uInt   uint32_t
  ------------------
 6893|  11.1k|  const Unit *up;             // work
 6894|  11.1k|  Unit  *target;              // ..
  ------------------
  |  |   94|  11.1k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  11.1k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6895|  11.1k|  Int   count;                // ..
  ------------------
  |  |   92|  11.1k|  #define Int    int32_t
  ------------------
 6896|  11.1k|  #if DECDPUN<=4
 6897|  11.1k|  uInt  temp;                 // ..
  ------------------
  |  |   93|  11.1k|  #define uInt   uint32_t
  ------------------
 6898|  11.1k|  #endif
 6899|       |
 6900|  11.1k|  discard=len-set->digits;    // digits to discard
 6901|  11.1k|  if (discard<=0) {           // no digits are being discarded
  ------------------
  |  Branch (6901:7): [True: 0, False: 11.1k]
  ------------------
 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|  11.1k|  dn->exponent+=discard;      // maintain numerical value
 6917|  11.1k|  *status|=DEC_Rounded;       // accumulate Rounded status
  ------------------
  |  |  141|  11.1k|    #define DEC_Rounded              0x00000800
  ------------------
 6918|  11.1k|  if (*residue>1) *residue=1; // previous residue now to right, so reduce
  ------------------
  |  Branch (6918:7): [True: 0, False: 11.1k]
  ------------------
 6919|       |
 6920|  11.1k|  if (discard>len) {          // everything, +1, is being discarded
  ------------------
  |  Branch (6920:7): [True: 4.15k, False: 6.98k]
  ------------------
 6921|       |    // guard digit is 0
 6922|       |    // residue is all the number [NB could be all 0s]
 6923|  4.15k|    if (*residue<=0) {        // not already positive
  ------------------
  |  Branch (6923:9): [True: 4.15k, False: 0]
  ------------------
 6924|  4.15k|      count=len;              // avoids D2U
 6925|   178k|      for (up=lsu; count>0; up++, count-=DECDPUN) if (*up!=0) { // found non-0
  ------------------
  |  |   43|   174k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6925:20): [True: 178k, False: 0]
  |  Branch (6925:55): [True: 4.15k, False: 174k]
  ------------------
 6926|  4.15k|        *residue=1;
 6927|  4.15k|        break;                // no need to check any others
 6928|  4.15k|        }
 6929|  4.15k|      }
 6930|  4.15k|    if (*residue!=0) *status|=DEC_Inexact; // record inexactitude
  ------------------
  |  |  133|  4.15k|    #define DEC_Inexact              0x00000020
  ------------------
  |  Branch (6930:9): [True: 4.15k, False: 0]
  ------------------
 6931|  4.15k|    *dn->lsu=0;               // coefficient will now be 0
 6932|  4.15k|    dn->digits=1;             // ..
 6933|  4.15k|    return;
 6934|  4.15k|    } // total discard
 6935|       |
 6936|       |  // partial discard [most common case]
 6937|       |  // here, at least the first (most significant) discarded digit exists
 6938|       |
 6939|       |  // spin up the number, noting residue during the spin, until get to
 6940|       |  // the Unit with the first discarded digit.  When reach it, extract
 6941|       |  // it and remember its position
 6942|  6.98k|  count=0;
 6943|   213k|  for (up=lsu;; up++) {
 6944|   213k|    count+=DECDPUN;
  ------------------
  |  |   43|   213k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 6945|   213k|    if (count>=discard) break; // full ones all checked
  ------------------
  |  Branch (6945:9): [True: 6.98k, False: 206k]
  ------------------
 6946|   206k|    if (*up!=0) *residue=1;
  ------------------
  |  Branch (6946:9): [True: 34.1k, False: 172k]
  ------------------
 6947|   206k|    } // up
 6948|       |
 6949|       |  // here up -> Unit with first discarded digit
 6950|  6.98k|  cut=discard-(count-DECDPUN)-1;
  ------------------
  |  |   43|  6.98k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 6951|  6.98k|  if (cut==DECDPUN-1) {       // unit-boundary case (fast)
  ------------------
  |  |   43|  6.98k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6951:7): [True: 1.10k, False: 5.87k]
  ------------------
 6952|  1.10k|    Unit half=(Unit)powers[DECDPUN]>>1;
  ------------------
  |  |   94|  1.10k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  1.10k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
                  Unit half=(Unit)powers[DECDPUN]>>1;
  ------------------
  |  |  177|  1.10k|#define powers      DECPOWERS      // old internal name
  ------------------
                  Unit half=(Unit)powers[DECDPUN]>>1;
  ------------------
  |  |   43|  1.10k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 6953|       |    // set residue directly
 6954|  1.10k|    if (*up>=half) {
  ------------------
  |  Branch (6954:9): [True: 566, False: 539]
  ------------------
 6955|    566|      if (*up>half) *residue=7;
  ------------------
  |  Branch (6955:11): [True: 353, False: 213]
  ------------------
 6956|    213|      else *residue+=5;       // add sticky bit
 6957|    566|      }
 6958|    539|     else { // <half
 6959|    539|      if (*up!=0) *residue=3; // [else is 0, leave as sticky bit]
  ------------------
  |  Branch (6959:11): [True: 211, False: 328]
  ------------------
 6960|    539|      }
 6961|  1.10k|    if (set->digits<=0) {     // special for Quantize/Subnormal :-(
  ------------------
  |  Branch (6961:9): [True: 751, False: 354]
  ------------------
 6962|    751|      *dn->lsu=0;             // .. result is 0
 6963|    751|      dn->digits=1;           // ..
 6964|    751|      }
 6965|    354|     else {                   // shift to least
 6966|    354|      count=set->digits;      // now digits to end up with
 6967|    354|      dn->digits=count;       // set the new length
 6968|    354|      up++;                   // move to next
 6969|       |      // on unit boundary, so shift-down copy loop is simple
 6970|   837k|      for (target=dn->lsu; count>0; target++, up++, count-=DECDPUN)
  ------------------
  |  |   43|   837k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6970:28): [True: 837k, False: 354]
  ------------------
 6971|   837k|        *target=*up;
 6972|    354|      }
 6973|  1.10k|    } // unit-boundary case
 6974|       |
 6975|  5.87k|   else { // discard digit is in low digit(s), and not top digit
 6976|  5.87k|    uInt  discard1;                // first discarded digit
  ------------------
  |  |   93|  5.87k|  #define uInt   uint32_t
  ------------------
 6977|  5.87k|    uInt  quot, rem;               // for divisions
  ------------------
  |  |   93|  5.87k|  #define uInt   uint32_t
  ------------------
 6978|  5.87k|    if (cut==0) quot=*up;          // is at bottom of unit
  ------------------
  |  Branch (6978:9): [True: 5.41k, False: 461]
  ------------------
 6979|    461|     else /* cut>0 */ {            // it's not at bottom of unit
 6980|    461|      #if DECDPUN<=4
 6981|    461|        quot=QUOT10(*up, cut);
  ------------------
  |  |  210|    461|  #define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17)
  ------------------
 6982|    461|        rem=*up-quot*powers[cut];
  ------------------
  |  |  177|    461|#define powers      DECPOWERS      // old internal name
  ------------------
 6983|       |      #else
 6984|       |        rem=*up%powers[cut];
 6985|       |        quot=*up/powers[cut];
 6986|       |      #endif
 6987|    461|      if (rem!=0) *residue=1;
  ------------------
  |  Branch (6987:11): [True: 230, False: 231]
  ------------------
 6988|    461|      }
 6989|       |    // discard digit is now at bottom of quot
 6990|  5.87k|    #if DECDPUN<=4
 6991|  5.87k|      temp=(quot*6554)>>16;        // fast /10
 6992|       |      // Vowels algorithm here not a win (9 instructions)
 6993|  5.87k|      discard1=quot-X10(temp);
  ------------------
  |  |  163|  5.87k|  #define X10(i)  (((i)<<1)+((i)<<3))
  ------------------
 6994|  5.87k|      quot=temp;
 6995|       |    #else
 6996|       |      discard1=quot%10;
 6997|       |      quot=quot/10;
 6998|       |    #endif
 6999|       |    // here, discard1 is the guard digit, and residue is everything
 7000|       |    // else [use mapping array to accumulate residue safely]
 7001|  5.87k|    *residue+=resmap[discard1];
 7002|  5.87k|    cut++;                         // update cut
 7003|       |    // here: up -> Unit of the array with bottom digit
 7004|       |    //       cut is the division point for each Unit
 7005|       |    //       quot holds the uncut high-order digits for the current unit
 7006|  5.87k|    if (set->digits<=0) {          // special for Quantize/Subnormal :-(
  ------------------
  |  Branch (7006:9): [True: 917, False: 4.96k]
  ------------------
 7007|    917|      *dn->lsu=0;                  // .. result is 0
 7008|    917|      dn->digits=1;                // ..
 7009|    917|      }
 7010|  4.96k|     else {                        // shift to least needed
 7011|  4.96k|      count=set->digits;           // now digits to end up with
 7012|  4.96k|      dn->digits=count;            // set the new length
 7013|       |      // shift-copy the coefficient array to the result number
 7014|  6.97M|      for (target=dn->lsu; ; target++) {
 7015|  6.97M|        *target=(Unit)quot;
 7016|  6.97M|        count-=(DECDPUN-cut);
  ------------------
  |  |   43|  6.97M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 7017|  6.97M|        if (count<=0) break;
  ------------------
  |  Branch (7017:13): [True: 4.22k, False: 6.97M]
  ------------------
 7018|  6.97M|        up++;
 7019|  6.97M|        quot=*up;
 7020|  6.97M|        #if DECDPUN<=4
 7021|  6.97M|          quot=QUOT10(quot, cut);
  ------------------
  |  |  210|  6.97M|  #define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17)
  ------------------
 7022|  6.97M|          rem=*up-quot*powers[cut];
  ------------------
  |  |  177|  6.97M|#define powers      DECPOWERS      // old internal name
  ------------------
 7023|       |        #else
 7024|       |          rem=quot%powers[cut];
 7025|       |          quot=quot/powers[cut];
 7026|       |        #endif
 7027|  6.97M|        *target=(Unit)(*target+rem*powers[DECDPUN-cut]);
  ------------------
  |  |  177|  6.97M|#define powers      DECPOWERS      // old internal name
  ------------------
                      *target=(Unit)(*target+rem*powers[DECDPUN-cut]);
  ------------------
  |  |   43|  6.97M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 7028|  6.97M|        count-=cut;
 7029|  6.97M|        if (count<=0) break;
  ------------------
  |  Branch (7029:13): [True: 736, False: 6.97M]
  ------------------
 7030|  6.97M|        } // shift-copy loop
 7031|  4.96k|      } // shift to least
 7032|  5.87k|    } // not unit boundary
 7033|       |
 7034|  6.98k|  if (*residue!=0) *status|=DEC_Inexact; // record inexactitude
  ------------------
  |  |  133|  4.10k|    #define DEC_Inexact              0x00000020
  ------------------
  |  Branch (7034:7): [True: 4.10k, False: 2.88k]
  ------------------
 7035|  6.98k|  return;
 7036|  11.1k|  } // decSetCoeff
decNumber.c:decFinalize:
 7275|  24.6k|                        uInt *status) {
 7276|  24.6k|  Int shift;                            // shift needed if clamping
  ------------------
  |  |   92|  24.6k|  #define Int    int32_t
  ------------------
 7277|  24.6k|  Int tinyexp=set->emin-dn->digits+1;   // precalculate subnormal boundary
  ------------------
  |  |   92|  24.6k|  #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|  24.6k|  if (dn->exponent<=tinyexp) {          // prefilter
  ------------------
  |  Branch (7285:7): [True: 12.0k, False: 12.6k]
  ------------------
 7286|  12.0k|    Int comp;
  ------------------
  |  |   92|  12.0k|  #define Int    int32_t
  ------------------
 7287|  12.0k|    decNumber nmin;
 7288|       |    // A very nasty case here is dn == Nmin and residue<0
 7289|  12.0k|    if (dn->exponent<tinyexp) {
  ------------------
  |  Branch (7289:9): [True: 12.0k, False: 0]
  ------------------
 7290|       |      // Go handle subnormals; this will apply round if needed.
 7291|  12.0k|      decSetSubnormal(dn, set, residue, status);
 7292|  12.0k|      return;
 7293|  12.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.6k|  if (*residue!=0) decApplyRound(dn, set, *residue, status);
  ------------------
  |  Branch (7311:7): [True: 0, False: 12.6k]
  ------------------
 7312|       |
 7313|       |  // Check for overflow [redundant in the 'rare' case] or clamp
 7314|  12.6k|  if (dn->exponent<=set->emax-set->digits+1) return;   // neither needed
  ------------------
  |  Branch (7314:7): [True: 0, False: 12.6k]
  ------------------
 7315|       |
 7316|       |
 7317|       |  // here when might have an overflow or clamp to do
 7318|  12.6k|  if (dn->exponent>set->emax-dn->digits+1) {           // too big
  ------------------
  |  Branch (7318:7): [True: 12.3k, False: 248]
  ------------------
 7319|  12.3k|    decSetOverflow(dn, set, status);
 7320|  12.3k|    return;
 7321|  12.3k|    }
 7322|       |  // here when the result is normal but in clamp range
 7323|    248|  if (!set->clamp) return;
  ------------------
  |  Branch (7323:7): [True: 248, 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|    248|  } // decFinalize
decNumber.c:decSetSubnormal:
 7429|  12.0k|                            uInt *status) {
 7430|  12.0k|  decContext workset;         // work
 7431|  12.0k|  Int        etiny, adjust;   // ..
  ------------------
  |  |   92|  12.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|  12.0k|  etiny=set->emin-(set->digits-1);      // smallest allowed exponent
 7446|       |
 7447|  12.0k|  if ISZERO(dn) {                       // value is zero
  ------------------
  |  |  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: 978, False: 11.0k]
  |  |  |  |  ------------------
  |  |  |  |  178|  12.0k|                                    && (dn)->digits==1 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:40): [True: 569, False: 409]
  |  |  |  |  ------------------
  |  |  |  |  179|  12.0k|                                    && (((dn)->bits&DECSPECIAL)==0))
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|    569|  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|    569|  #define DECINF    0x40      /* 1=Infinity                           */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   33|    569|  #define DECNAN    0x20      /* 1=NaN                                */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   34|    569|  #define DECSNAN   0x10      /* 1=sNaN                               */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (179:40): [True: 569, 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|    569|    if (dn->exponent<etiny) {           // clamp required
  ------------------
  |  Branch (7455:9): [True: 328, False: 241]
  ------------------
 7456|    328|      dn->exponent=etiny;
 7457|    328|      *status|=DEC_Clamped;
  ------------------
  |  |  140|    328|    #define DEC_Clamped              0x00000400
  ------------------
 7458|    328|      }
 7459|    569|    return;
 7460|    569|    }
 7461|       |
 7462|  11.4k|  *status|=DEC_Subnormal;               // have a non-zero subnormal
  ------------------
  |  |  142|  11.4k|    #define DEC_Subnormal            0x00001000
  ------------------
 7463|  11.4k|  adjust=etiny-dn->exponent;            // calculate digits to remove
 7464|  11.4k|  if (adjust<=0) {                      // not out of range; unrounded
  ------------------
  |  Branch (7464:7): [True: 299, False: 11.1k]
  ------------------
 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|    299|    if (*status&DEC_Inexact) *status|=DEC_Underflow;
  ------------------
  |  |  133|    299|    #define DEC_Inexact              0x00000020
  ------------------
                  if (*status&DEC_Inexact) *status|=DEC_Underflow;
  ------------------
  |  |  143|      0|    #define DEC_Underflow            0x00002000
  ------------------
  |  Branch (7468:9): [True: 0, False: 299]
  ------------------
 7469|    299|    return;
 7470|    299|    }
 7471|       |
 7472|       |  // adjust>0, so need to rescale the result so exponent becomes Etiny
 7473|       |  // [this code is similar to that in rescale]
 7474|  11.1k|  workset=*set;                         // clone rounding, etc.
 7475|  11.1k|  workset.digits=dn->digits-adjust;     // set requested length
 7476|  11.1k|  workset.emin-=adjust;                 // and adjust emin to match
 7477|       |  // [note that the latter can be <1, here, similar to Rescale case]
 7478|  11.1k|  decSetCoeff(dn, &workset, dn->lsu, dn->digits, residue, status);
 7479|  11.1k|  decApplyRound(dn, &workset, *residue, status);
 7480|       |
 7481|       |  // Use 754 default rule: Underflow is set iff Inexact
 7482|       |  // [independent of whether trapped]
 7483|  11.1k|  if (*status&DEC_Inexact) *status|=DEC_Underflow;
  ------------------
  |  |  133|  11.1k|    #define DEC_Inexact              0x00000020
  ------------------
                if (*status&DEC_Inexact) *status|=DEC_Underflow;
  ------------------
  |  |  143|  8.26k|    #define DEC_Underflow            0x00002000
  ------------------
  |  Branch (7483:7): [True: 8.26k, False: 2.88k]
  ------------------
 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|  11.1k|  if (dn->exponent>etiny) {
  ------------------
  |  Branch (7487:7): [True: 1.11k, False: 10.0k]
  ------------------
 7488|  1.11k|    dn->digits=decShiftToMost(dn->lsu, dn->digits, 1);
 7489|  1.11k|    dn->exponent--;                     // (re)adjust the exponent.
 7490|  1.11k|    }
 7491|       |
 7492|       |  // if rounded to zero, it is by definition clamped...
 7493|  11.1k|  if (ISZERO(dn)) *status|=DEC_Clamped;
  ------------------
  |  |  255|  11.1k|  #define ISZERO(dn) decNumberIsZero(dn)     /* now just a local name */
  |  |  ------------------
  |  |  |  |  177|  11.1k|  #define decNumberIsZero(dn)      (*(dn)->lsu==0 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (177:37): [True: 5.65k, False: 5.49k]
  |  |  |  |  ------------------
  |  |  |  |  178|  11.1k|                                    && (dn)->digits==1 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:40): [True: 4.40k, False: 1.24k]
  |  |  |  |  ------------------
  |  |  |  |  179|  11.1k|                                    && (((dn)->bits&DECSPECIAL)==0))
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|  4.40k|  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|  4.40k|  #define DECINF    0x40      /* 1=Infinity                           */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   33|  4.40k|  #define DECNAN    0x20      /* 1=NaN                                */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   34|  4.40k|  #define DECSNAN   0x10      /* 1=sNaN                               */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (179:40): [True: 4.40k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                if (ISZERO(dn)) *status|=DEC_Clamped;
  ------------------
  |  |  140|  4.40k|    #define DEC_Clamped              0x00000400
  ------------------
 7494|  11.1k|  } // decSetSubnormal
decNumber.c:decBiStr:
 7667|  5.69k|static Flag decBiStr(const char *targ, const char *str1, const char *str2) {
 7668|  9.54k|  for (;;targ++, str1++, str2++) {
 7669|  9.54k|    if (*targ!=*str1 && *targ!=*str2) return 0;
  ------------------
  |  Branch (7669:9): [True: 7.12k, False: 2.41k]
  |  Branch (7669:25): [True: 5.13k, False: 1.99k]
  ------------------
 7670|       |    // *targ has a match in one (or both, if terminator)
 7671|  4.40k|    if (*targ=='\0') break;
  ------------------
  |  Branch (7671:9): [True: 553, False: 3.85k]
  ------------------
 7672|  4.40k|    } // forever
 7673|    553|  return 1;
 7674|  5.69k|  } // decBiStr
decNumber.c:decStatus:
 7741|  24.7k|static void decStatus(decNumber *dn, uInt status, decContext *set) {
 7742|  24.7k|  if (status & DEC_NaNs) {              // error status -> NaN
  ------------------
  |  |  187|  24.7k|  #define DEC_NaNs    DEC_IEEE_754_Invalid_operation
  |  |  ------------------
  |  |  |  |  173|  24.7k|  #define DEC_IEEE_754_Invalid_operation (DEC_Conversion_syntax |     \
  |  |  |  |  ------------------
  |  |  |  |  |  |  128|  24.7k|    #define DEC_Conversion_syntax    0x00000001
  |  |  |  |  ------------------
  |  |  |  |  174|  24.7k|                                          DEC_Division_impossible |   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  130|  24.7k|    #define DEC_Division_impossible  0x00000004
  |  |  |  |  ------------------
  |  |  |  |  175|  24.7k|                                          DEC_Division_undefined |    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  131|  24.7k|    #define DEC_Division_undefined   0x00000008
  |  |  |  |  ------------------
  |  |  |  |  176|  24.7k|                                          DEC_Insufficient_storage |  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  132|  24.7k|    #define DEC_Insufficient_storage 0x00000010 /* [when malloc fails]  */
  |  |  |  |  ------------------
  |  |  |  |  177|  24.7k|                                          DEC_Invalid_context |       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  134|  24.7k|    #define DEC_Invalid_context      0x00000040
  |  |  |  |  ------------------
  |  |  |  |  178|  24.7k|                                          DEC_Invalid_operation)
  |  |  |  |  ------------------
  |  |  |  |  |  |  135|  24.7k|    #define DEC_Invalid_operation    0x00000080
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (7742:7): [True: 603, False: 24.1k]
  ------------------
 7743|       |    // if cause was an sNaN, clear and propagate [NaN is already set up]
 7744|    603|    if (status & DEC_sNaN) status&=~DEC_sNaN;
  ------------------
  |  |  193|    603|#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: 603]
  ------------------
 7745|    603|     else {
 7746|    603|      decNumberZero(dn);                // other error: clean throughout
 7747|    603|      dn->bits=DECNAN;                  // and make a quiet NaN
  ------------------
  |  |   33|    603|  #define DECNAN    0x20      /* 1=NaN                                */
  ------------------
 7748|    603|      }
 7749|    603|    }
 7750|  24.7k|  decContextSetStatus(set, status);     // [may not return]
 7751|  24.7k|  return;
 7752|  24.7k|  } // decStatus

