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

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

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

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

jv_parser_set_buf:
  735|  3.19k|void jv_parser_set_buf(struct jv_parser* p, const char* buf, int length, int is_partial) {
  736|  3.19k|  assert((p->curr_buf == 0 || p->curr_buf_pos == p->curr_buf_length)
  ------------------
  |  Branch (736:3): [True: 3.19k, False: 0]
  |  Branch (736:3): [True: 0, False: 0]
  |  Branch (736:3): [True: 0, False: 0]
  |  Branch (736:3): [True: 3.19k, False: 0]
  |  Branch (736:3): [True: 0, False: 0]
  |  Branch (736:3): [True: 3.19k, False: 0]
  ------------------
  737|  3.19k|         && "previous buffer not exhausted");
  738|  6.41k|  while (length > 0 && p->bom_strip_position < sizeof(UTF8_BOM)) {
  ------------------
  |  Branch (738:10): [True: 6.41k, False: 4]
  |  Branch (738:24): [True: 3.22k, False: 3.18k]
  ------------------
  739|  3.22k|    if ((unsigned char)*buf == UTF8_BOM[p->bom_strip_position]) {
  ------------------
  |  Branch (739:9): [True: 35, False: 3.18k]
  ------------------
  740|       |      // matched a BOM character
  741|     35|      buf++;
  742|     35|      length--;
  743|     35|      p->bom_strip_position++;
  744|  3.18k|    } else {
  745|  3.18k|      if (p->bom_strip_position == 0) {
  ------------------
  |  Branch (745:11): [True: 3.16k, False: 24]
  ------------------
  746|       |        // no BOM in this document
  747|  3.16k|        p->bom_strip_position = sizeof(UTF8_BOM);
  748|  3.16k|      } else {
  749|       |        // malformed BOM (prefix present, rest missing)
  750|     24|        p->bom_strip_position = 0xff;
  751|     24|      }
  752|  3.18k|    }
  753|  3.22k|  }
  754|  3.19k|  p->curr_buf = buf;
  755|  3.19k|  p->curr_buf_length = length;
  756|  3.19k|  p->curr_buf_pos = 0;
  757|  3.19k|  p->curr_buf_is_partial = is_partial;
  758|  3.19k|}
jv_parser_next:
  772|  4.82k|jv jv_parser_next(struct jv_parser* p) {
  773|  4.82k|  if (p->eof)
  ------------------
  |  Branch (773:7): [True: 845, False: 3.98k]
  ------------------
  774|    845|    return jv_invalid();
  775|  3.98k|  if (!p->curr_buf)
  ------------------
  |  Branch (775:7): [True: 0, False: 3.98k]
  ------------------
  776|      0|    return jv_invalid(); // Need a buffer
  777|  3.98k|  if (p->bom_strip_position == 0xff) {
  ------------------
  |  Branch (777:7): [True: 24, False: 3.96k]
  ------------------
  778|     24|    if (!(p->flags & JV_PARSE_SEQ))
  ------------------
  |  Branch (778:9): [True: 24, False: 0]
  ------------------
  779|     24|      return jv_invalid_with_msg(jv_string("Malformed BOM"));
  780|      0|    p->st =JV_PARSER_WAITING_FOR_RS;
  781|      0|    parser_reset(p);
  782|      0|  }
  783|  3.96k|  jv value = jv_invalid();
  784|  3.96k|  if ((p->flags & JV_PARSE_STREAMING) && stream_check_done(p, &value))
  ------------------
  |  Branch (784:7): [True: 0, False: 3.96k]
  |  Branch (784:42): [True: 0, False: 0]
  ------------------
  785|      0|    return value;
  786|  3.96k|  char ch;
  787|  3.96k|  presult msg = 0;
  788|  74.5M|  while (!msg && p->curr_buf_pos < p->curr_buf_length) {
  ------------------
  |  Branch (788:10): [True: 74.5M, False: 1.25k]
  |  Branch (788:18): [True: 74.5M, False: 2.70k]
  ------------------
  789|  74.5M|    ch = p->curr_buf[p->curr_buf_pos++];
  790|  74.5M|    if (p->st == JV_PARSER_WAITING_FOR_RS) {
  ------------------
  |  Branch (790:9): [True: 0, False: 74.5M]
  ------------------
  791|      0|      if (ch == '\n') {
  ------------------
  |  Branch (791:11): [True: 0, False: 0]
  ------------------
  792|      0|        p->line++;
  793|      0|        p->column = 0;
  794|      0|      } else {
  795|      0|        p->column++;
  796|      0|      }
  797|      0|      if (ch == '\036')
  ------------------
  |  Branch (797:11): [True: 0, False: 0]
  ------------------
  798|      0|        p->st = JV_PARSER_NORMAL;
  799|      0|      continue; // need to resync, wait for RS
  800|      0|    }
  801|  74.5M|    msg = scan(p, ch, &value);
  802|  74.5M|  }
  803|  3.96k|  if (msg == OK) {
  ------------------
  |  Branch (803:7): [True: 809, False: 3.15k]
  ------------------
  804|    809|    return value;
  805|  3.15k|  } else if (msg) {
  ------------------
  |  Branch (805:14): [True: 444, False: 2.70k]
  ------------------
  806|    444|    jv_free(value);
  807|    444|    if (ch != '\036' && (p->flags & JV_PARSE_SEQ)) {
  ------------------
  |  Branch (807:9): [True: 444, False: 0]
  |  Branch (807:25): [True: 0, False: 444]
  ------------------
  808|       |      // Skip to the next RS
  809|      0|      p->st = JV_PARSER_WAITING_FOR_RS;
  810|      0|      value = make_error(p, "%s at line %d, column %d (need RS to resync)", msg, p->line, p->column);
  811|      0|      parser_reset(p);
  812|      0|      return value;
  813|      0|    }
  814|    444|    value = make_error(p, "%s at line %d, column %d", msg, p->line, p->column);
  815|    444|    parser_reset(p);
  816|    444|    if (!(p->flags & JV_PARSE_SEQ)) {
  ------------------
  |  Branch (816:9): [True: 444, False: 0]
  ------------------
  817|       |      // We're not parsing a JSON text sequence; throw this buffer away.
  818|       |      // XXX We should fail permanently here.
  819|    444|      p->curr_buf = 0;
  820|    444|      p->curr_buf_pos = 0;
  821|    444|    } // Else ch must be RS; don't clear buf so we can start parsing again after this ch
  822|    444|    return value;
  823|  2.70k|  } else if (p->curr_buf_is_partial) {
  ------------------
  |  Branch (823:14): [True: 0, False: 2.70k]
  ------------------
  824|      0|    assert(p->curr_buf_pos == p->curr_buf_length);
  ------------------
  |  Branch (824:5): [True: 0, False: 0]
  |  Branch (824:5): [True: 0, False: 0]
  ------------------
  825|       |    // need another buffer
  826|      0|    return jv_invalid();
  827|  2.70k|  } else {
  828|       |    // at EOF
  829|  2.70k|    p->eof = 1;
  830|  2.70k|    assert(p->curr_buf_pos == p->curr_buf_length);
  ------------------
  |  Branch (830:5): [True: 0, False: 2.70k]
  |  Branch (830:5): [True: 2.70k, False: 0]
  ------------------
  831|  2.70k|    jv_free(value);
  832|  2.70k|    if (p->st == JV_PARSER_WAITING_FOR_RS)
  ------------------
  |  Branch (832:9): [True: 0, False: 2.70k]
  ------------------
  833|      0|      return make_error(p, "Unfinished abandoned text at EOF at line %d, column %d", p->line, p->column);
  834|  2.70k|    if (p->st != JV_PARSER_NORMAL) {
  ------------------
  |  Branch (834:9): [True: 104, False: 2.60k]
  ------------------
  835|    104|      value = make_error(p, "Unfinished string at EOF at line %d, column %d", p->line, p->column);
  836|    104|      parser_reset(p);
  837|    104|      p->st = JV_PARSER_WAITING_FOR_RS;
  838|    104|      return value;
  839|    104|    }
  840|  2.60k|    if ((msg = check_literal(p))) {
  ------------------
  |  Branch (840:9): [True: 720, False: 1.88k]
  ------------------
  841|    720|      value = make_error(p, "%s at EOF at line %d, column %d", msg, p->line, p->column);
  842|    720|      parser_reset(p);
  843|    720|      p->st = JV_PARSER_WAITING_FOR_RS;
  844|    720|      return value;
  845|    720|    }
  846|  1.88k|    if (((p->flags & JV_PARSE_STREAMING) && p->stacklen != 0) ||
  ------------------
  |  Branch (846:10): [True: 0, False: 1.88k]
  |  Branch (846:45): [True: 0, False: 0]
  ------------------
  847|  1.88k|        (!(p->flags & JV_PARSE_STREAMING) && p->stackpos != 0)) {
  ------------------
  |  Branch (847:10): [True: 1.88k, False: 0]
  |  Branch (847:46): [True: 743, False: 1.14k]
  ------------------
  848|    743|      value = make_error(p, "Unfinished JSON term at EOF at line %d, column %d", p->line, p->column);
  849|    743|      parser_reset(p);
  850|    743|      p->st = JV_PARSER_WAITING_FOR_RS;
  851|    743|      return value;
  852|    743|    }
  853|       |    // p->next is either invalid (nothing here, but no syntax error)
  854|       |    // or valid (this is the value). either way it's the thing to return
  855|  1.14k|    if ((p->flags & JV_PARSE_STREAMING) && jv_is_valid(p->next)) {
  ------------------
  |  Branch (855:9): [True: 0, False: 1.14k]
  |  Branch (855:44): [True: 0, False: 0]
  ------------------
  856|      0|      value = JV_ARRAY(jv_copy(p->path), p->next); // except in streaming mode we've got to make it [path,value]
  ------------------
  |  |  111|      0|  JV_ARRAY_IDX(__VA_ARGS__, JV_ARRAY_9, JV_ARRAY_8, JV_ARRAY_7, JV_ARRAY_6, JV_ARRAY_5, JV_ARRAY_4, JV_ARRAY_3, JV_ARRAY_2, JV_ARRAY_1, dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  109|      0|#define JV_ARRAY_IDX(_1,_2,_3,_4,_5,_6,_7,_8,_9,NAME,...) NAME
  |  |  |  |  ------------------
  |  |  |  |  |  |  111|      0|  JV_ARRAY_IDX(__VA_ARGS__, JV_ARRAY_9, JV_ARRAY_8, JV_ARRAY_7, JV_ARRAY_6, JV_ARRAY_5, JV_ARRAY_4, JV_ARRAY_3, JV_ARRAY_2, JV_ARRAY_1, dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  101|      0|#define JV_ARRAY_2(e1,e2) (jv_array_append(JV_ARRAY_1(e1),e2))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  100|      0|#define JV_ARRAY_1(e) (jv_array_append(jv_array(),e))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  857|  1.14k|    } else {
  858|  1.14k|      value = p->next;
  859|  1.14k|    }
  860|  1.14k|    p->next = jv_invalid();
  861|  1.14k|    if ((p->flags & JV_PARSE_SEQ) && !p->last_ch_was_ws && jv_get_kind(value) == JV_KIND_NUMBER) {
  ------------------
  |  Branch (861:9): [True: 0, False: 1.14k]
  |  Branch (861:38): [True: 0, False: 0]
  |  Branch (861:60): [True: 0, False: 0]
  ------------------
  862|      0|      jv_free(value);
  863|      0|      return make_error(p, "Potentially truncated top-level numeric value at EOF at line %d, column %d", p->line, p->column);
  864|      0|    }
  865|  1.14k|    return value;
  866|  1.14k|  }
  867|  3.96k|}
jv_parse_sized_custom_flags:
  869|  3.19k|jv jv_parse_sized_custom_flags(const char* string, int length, int flags) {
  870|  3.19k|  struct jv_parser parser;
  871|  3.19k|  parser_init(&parser, flags);
  872|  3.19k|  jv_parser_set_buf(&parser, string, length, 0);
  873|  3.19k|  jv value = jv_parser_next(&parser);
  874|  3.19k|  if (jv_is_valid(value)) {
  ------------------
  |  Branch (874:7): [True: 1.63k, False: 1.55k]
  ------------------
  875|  1.63k|    jv next = jv_parser_next(&parser);
  876|  1.63k|    if (jv_is_valid(next)) {
  ------------------
  |  Branch (876:9): [True: 38, False: 1.59k]
  ------------------
  877|       |      // multiple JSON values, we only wanted one
  878|     38|      jv_free(value);
  879|     38|      jv_free(next);
  880|     38|      value = jv_invalid_with_msg(jv_string("Unexpected extra JSON values"));
  881|  1.59k|    } else if (jv_invalid_has_msg(jv_copy(next))) {
  ------------------
  |  Branch (881:16): [True: 516, False: 1.08k]
  ------------------
  882|       |      // parser error after the first JSON value
  883|    516|      jv_free(value);
  884|    516|      value = next;
  885|  1.08k|    } else {
  886|       |      // a single valid JSON value
  887|  1.08k|      jv_free(next);
  888|  1.08k|    }
  889|  1.63k|  } else if (jv_invalid_has_msg(jv_copy(value))) {
  ------------------
  |  Branch (889:14): [True: 1.51k, False: 36]
  ------------------
  890|       |    // parse error, we'll return it
  891|  1.51k|  } else {
  892|       |    // no value at all
  893|     36|    jv_free(value);
  894|     36|    value = jv_invalid_with_msg(jv_string("Expected JSON value"));
  895|     36|  }
  896|  3.19k|  parser_free(&parser);
  897|       |
  898|  3.19k|  if (!jv_is_valid(value) && jv_invalid_has_msg(jv_copy(value))) {
  ------------------
  |  Branch (898:7): [True: 2.10k, False: 1.08k]
  |  Branch (898:30): [True: 2.10k, False: 0]
  ------------------
  899|  2.10k|    jv msg = jv_invalid_get_msg(value);
  900|  2.10k|    value = jv_invalid_with_msg(jv_string_fmt("%s (while parsing '%.*s')",
  901|  2.10k|                                              jv_string_value(msg),
  902|  2.10k|                                              length,
  903|  2.10k|                                              string));
  904|  2.10k|    jv_free(msg);
  905|  2.10k|  }
  906|  3.19k|  return value;
  907|  3.19k|}
jv_parse_sized:
  909|  3.19k|jv jv_parse_sized(const char* string, int length) {
  910|  3.19k|  return jv_parse_sized_custom_flags(string, length, 0);
  911|  3.19k|}
jv_parse:
  913|  3.19k|jv jv_parse(const char* string) {
  914|  3.19k|  return jv_parse_sized(string, strlen(string));
  915|  3.19k|}
jv_parse.c:parser_init:
   70|  3.19k|static void parser_init(struct jv_parser* p, int flags) {
   71|  3.19k|  p->flags = flags;
   72|  3.19k|  if ((p->flags & JV_PARSE_STREAMING)) {
  ------------------
  |  Branch (72:7): [True: 0, False: 3.19k]
  ------------------
   73|      0|    p->path = jv_array();
   74|  3.19k|  } else {
   75|  3.19k|    p->path = jv_invalid();
   76|  3.19k|    p->flags &= ~(JV_PARSE_STREAM_ERRORS);
   77|  3.19k|  }
   78|  3.19k|  p->stack = 0;
   79|  3.19k|  p->stacklen = p->stackpos = 0;
   80|  3.19k|  p->last_seen = JV_LAST_NONE;
   81|  3.19k|  p->output = jv_invalid();
   82|  3.19k|  p->next = jv_invalid();
   83|  3.19k|  p->tokenlen = 256;
   84|  3.19k|  p->tokenbuf = jv_mem_alloc(p->tokenlen);
   85|  3.19k|  p->tokenpos = 0;
   86|  3.19k|  if ((p->flags & JV_PARSE_SEQ))
  ------------------
  |  Branch (86:7): [True: 0, False: 3.19k]
  ------------------
   87|      0|    p->st = JV_PARSER_WAITING_FOR_RS;
   88|  3.19k|  else
   89|  3.19k|    p->st = JV_PARSER_NORMAL;
   90|  3.19k|  p->eof = 0;
   91|  3.19k|  p->curr_buf = 0;
   92|  3.19k|  p->curr_buf_length = p->curr_buf_pos = p->curr_buf_is_partial = 0;
   93|  3.19k|  p->bom_strip_position = 0;
   94|  3.19k|  p->last_ch_was_ws = 0;
   95|  3.19k|  p->line = 1;
   96|  3.19k|  p->column = 0;
   97|  3.19k|  jvp_dtoa_context_init(&p->dtoa);
   98|  3.19k|}
jv_parse.c:parser_free:
  118|  3.19k|static void parser_free(struct jv_parser* p) {
  119|  3.19k|  parser_reset(p);
  120|  3.19k|  jv_free(p->path);
  121|  3.19k|  jv_free(p->output);
  122|  3.19k|  jv_mem_free(p->stack);
  123|  3.19k|  jv_mem_free(p->tokenbuf);
  124|  3.19k|  jvp_dtoa_context_free(&p->dtoa);
  125|  3.19k|}
jv_parse.c:parser_reset:
  100|  5.20k|static void parser_reset(struct jv_parser* p) {
  101|  5.20k|  if ((p->flags & JV_PARSE_STREAMING)) {
  ------------------
  |  Branch (101:7): [True: 0, False: 5.20k]
  ------------------
  102|      0|    jv_free(p->path);
  103|      0|    p->path = jv_array();
  104|      0|    p->stacklen = 0;
  105|      0|  }
  106|  5.20k|  p->last_seen = JV_LAST_NONE;
  107|  5.20k|  jv_free(p->output);
  108|  5.20k|  p->output = jv_invalid();
  109|  5.20k|  jv_free(p->next);
  110|  5.20k|  p->next = jv_invalid();
  111|   418k|  for (int i=0; i<p->stackpos; i++)
  ------------------
  |  Branch (111:17): [True: 412k, False: 5.20k]
  ------------------
  112|   412k|    jv_free(p->stack[i]);
  113|  5.20k|  p->stackpos = 0;
  114|  5.20k|  p->tokenpos = 0;
  115|  5.20k|  p->st = JV_PARSER_NORMAL;
  116|  5.20k|}
jv_parse.c:scan:
  649|  74.5M|static pfunc scan(struct jv_parser* p, char ch, jv* out) {
  650|  74.5M|  p->column++;
  651|  74.5M|  if (ch == '\n') {
  ------------------
  |  Branch (651:7): [True: 42.2k, False: 74.5M]
  ------------------
  652|  42.2k|    p->line++;
  653|  42.2k|    p->column = 0;
  654|  42.2k|  }
  655|  74.5M|  if ((p->flags & JV_PARSE_SEQ)
  ------------------
  |  Branch (655:7): [True: 0, False: 74.5M]
  ------------------
  656|      0|      && ch == '\036' /* ASCII RS; see draft-ietf-json-sequence-07 */) {
  ------------------
  |  Branch (656:10): [True: 0, False: 0]
  ------------------
  657|      0|    if (check_truncation(p)) {
  ------------------
  |  |  644|      0|   (((p)->flags & JV_PARSE_STREAMING) ? stream_seq_check_truncation((p)) : seq_check_truncation((p)))
  |  |  ------------------
  |  |  |  Branch (644:4): [True: 0, False: 0]
  |  |  |  Branch (644:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  658|      0|      if (check_literal(p) == 0 && is_top_num(p))
  ------------------
  |  |  647|      0|   (((p)->flags & JV_PARSE_STREAMING) ? stream_is_top_num((p)) : parse_is_top_num((p)))
  |  |  ------------------
  |  |  |  Branch (647:4): [True: 0, False: 0]
  |  |  |  Branch (647:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (658:11): [True: 0, False: 0]
  ------------------
  659|      0|        return "Potentially truncated top-level numeric value";
  660|      0|      return "Truncated value";
  661|      0|    }
  662|      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]
  |  |  ------------------
  ------------------
  663|      0|    if (p->st == JV_PARSER_NORMAL && check_done(p, out))
  ------------------
  |  |  638|      0|   (((p)->flags & JV_PARSE_STREAMING) ? stream_check_done((p), (o)) : parse_check_done((p), (o)))
  |  |  ------------------
  |  |  |  Branch (638:4): [True: 0, False: 0]
  |  |  |  Branch (638:5): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (663:9): [True: 0, False: 0]
  ------------------
  664|      0|      return OK;
  665|       |    // shouldn't happen?
  666|      0|    assert(!jv_is_valid(*out));
  ------------------
  |  Branch (666:5): [True: 0, False: 0]
  |  Branch (666:5): [True: 0, False: 0]
  ------------------
  667|      0|    parser_reset(p);
  668|      0|    jv_free(*out);
  669|      0|    *out = jv_invalid();
  670|      0|    return OK;
  671|      0|  }
  672|  74.5M|  presult answer = 0;
  673|  74.5M|  p->last_ch_was_ws = 0;
  674|  74.5M|  if (p->st == JV_PARSER_NORMAL) {
  ------------------
  |  Branch (674:7): [True: 61.6M, False: 12.8M]
  ------------------
  675|  61.6M|    chclass cls = classify(ch);
  676|  61.6M|    if (cls == WHITESPACE)
  ------------------
  |  Branch (676:9): [True: 413k, False: 61.2M]
  ------------------
  677|   413k|      p->last_ch_was_ws = 1;
  678|  61.6M|    if (cls != LITERAL) {
  ------------------
  |  Branch (678:9): [True: 7.08M, False: 54.6M]
  ------------------
  679|  7.08M|      TRY(check_literal(p));
  ------------------
  |  |   18|  7.08M|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 49, False: 7.08M]
  |  |  |  Branch (18:74): [Folded, False: 7.08M]
  |  |  ------------------
  ------------------
  680|  7.08M|      if (check_done(p, out)) answer = OK;
  ------------------
  |  |  638|  7.08M|   (((p)->flags & JV_PARSE_STREAMING) ? stream_check_done((p), (o)) : parse_check_done((p), (o)))
  |  |  ------------------
  |  |  |  Branch (638:4): [True: 402, False: 7.08M]
  |  |  |  Branch (638:5): [True: 0, False: 7.08M]
  |  |  ------------------
  ------------------
  681|  7.08M|    }
  682|  61.6M|    switch (cls) {
  ------------------
  |  Branch (682:13): [True: 61.6M, False: 0]
  ------------------
  683|  54.6M|    case LITERAL:
  ------------------
  |  Branch (683:5): [True: 54.6M, False: 7.08M]
  ------------------
  684|  54.6M|      TRY(tokenadd(p, ch));
  ------------------
  |  |   18|  54.6M|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 0, False: 54.6M]
  |  |  |  Branch (18:74): [Folded, False: 54.6M]
  |  |  ------------------
  ------------------
  685|  54.6M|      break;
  686|  54.6M|    case WHITESPACE:
  ------------------
  |  Branch (686:5): [True: 413k, False: 61.2M]
  ------------------
  687|   413k|      break;
  688|  69.5k|    case QUOTE:
  ------------------
  |  Branch (688:5): [True: 69.5k, False: 61.6M]
  ------------------
  689|  69.5k|      p->st = JV_PARSER_STRING;
  690|  69.5k|      break;
  691|  6.60M|    case STRUCTURE:
  ------------------
  |  Branch (691:5): [True: 6.60M, False: 55.0M]
  ------------------
  692|  6.60M|      TRY(token(p, ch));
  ------------------
  |  |   18|  13.2M|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:37): [True: 0, False: 6.60M]
  |  |  |  Branch (18:45): [True: 188, False: 6.60M]
  |  |  |  Branch (18:74): [Folded, False: 6.60M]
  |  |  ------------------
  ------------------
  693|  6.60M|      break;
  694|  6.60M|    case INVALID:
  ------------------
  |  Branch (694:5): [True: 0, False: 61.6M]
  ------------------
  695|      0|      return "Invalid character";
  696|  61.6M|    }
  697|  61.6M|    if (check_done(p, out)) answer = OK;
  ------------------
  |  |  638|  61.6M|   (((p)->flags & JV_PARSE_STREAMING) ? stream_check_done((p), (o)) : parse_check_done((p), (o)))
  |  |  ------------------
  |  |  |  Branch (638:4): [True: 122, False: 61.6M]
  |  |  |  Branch (638:5): [True: 0, False: 61.6M]
  |  |  ------------------
  ------------------
  698|  61.6M|  } else {
  699|  12.8M|    if (ch == '"' && p->st == JV_PARSER_STRING) {
  ------------------
  |  Branch (699:9): [True: 71.8k, False: 12.8M]
  |  Branch (699:22): [True: 69.4k, False: 2.36k]
  ------------------
  700|  69.4k|      TRY(found_string(p));
  ------------------
  |  |   18|  69.4k|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 207, False: 69.2k]
  |  |  |  Branch (18:74): [Folded, False: 69.2k]
  |  |  ------------------
  ------------------
  701|  69.2k|      p->st = JV_PARSER_NORMAL;
  702|  69.2k|      if (check_done(p, out)) answer = OK;
  ------------------
  |  |  638|  69.2k|   (((p)->flags & JV_PARSE_STREAMING) ? stream_check_done((p), (o)) : parse_check_done((p), (o)))
  |  |  ------------------
  |  |  |  Branch (638:4): [True: 291, False: 68.9k]
  |  |  |  Branch (638:5): [True: 0, False: 69.2k]
  |  |  ------------------
  ------------------
  703|  12.8M|    } else {
  704|  12.8M|      TRY(tokenadd(p, ch));
  ------------------
  |  |   18|  12.8M|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 0, False: 12.8M]
  |  |  |  Branch (18:74): [Folded, False: 12.8M]
  |  |  ------------------
  ------------------
  705|  12.8M|      if (ch == '\\' && p->st == JV_PARSER_STRING) {
  ------------------
  |  Branch (705:11): [True: 41.0k, False: 12.7M]
  |  Branch (705:25): [True: 39.2k, False: 1.77k]
  ------------------
  706|  39.2k|        p->st = JV_PARSER_STRING_ESCAPE;
  707|  12.7M|      } else {
  708|  12.7M|        p->st = JV_PARSER_STRING;
  709|  12.7M|      }
  710|  12.8M|    }
  711|  12.8M|  }
  712|  74.5M|  return answer;
  713|  74.5M|}
jv_parse.c:parse_check_done:
  588|  68.8M|static int parse_check_done(struct jv_parser* p, jv* out) {
  589|  68.8M|  if (p->stackpos == 0 && jv_is_valid(p->next)) {
  ------------------
  |  Branch (589:7): [True: 45.7M, False: 23.0M]
  |  Branch (589:27): [True: 815, False: 45.7M]
  ------------------
  590|    815|    *out = p->next;
  591|    815|    p->next = jv_invalid();
  592|    815|    return 1;
  593|  68.8M|  } else {
  594|  68.8M|    return 0;
  595|  68.8M|  }
  596|  68.8M|}
jv_parse.c:classify:
  564|  61.6M|static chclass classify(char c) {
  565|  61.6M|  switch (c) {
  566|   377k|  case ' ':
  ------------------
  |  Branch (566:3): [True: 377k, False: 61.3M]
  ------------------
  567|   378k|  case '\t':
  ------------------
  |  Branch (567:3): [True: 379, False: 61.6M]
  ------------------
  568|   378k|  case '\r':
  ------------------
  |  Branch (568:3): [True: 273, False: 61.6M]
  ------------------
  569|   413k|  case '\n':
  ------------------
  |  Branch (569:3): [True: 34.4k, False: 61.6M]
  ------------------
  570|   413k|    return WHITESPACE;
  571|  69.5k|  case '"':
  ------------------
  |  Branch (571:3): [True: 69.5k, False: 61.6M]
  ------------------
  572|  69.5k|    return QUOTE;
  573|   287k|  case '[':
  ------------------
  |  Branch (573:3): [True: 287k, False: 61.4M]
  ------------------
  574|  6.33M|  case ',':
  ------------------
  |  Branch (574:3): [True: 6.05M, False: 55.6M]
  ------------------
  575|  6.35M|  case ']':
  ------------------
  |  Branch (575:3): [True: 14.5k, False: 61.6M]
  ------------------
  576|  6.51M|  case '{':
  ------------------
  |  Branch (576:3): [True: 165k, False: 61.5M]
  ------------------
  577|  6.57M|  case ':':
  ------------------
  |  Branch (577:3): [True: 58.3k, False: 61.6M]
  ------------------
  578|  6.60M|  case '}':
  ------------------
  |  Branch (578:3): [True: 27.9k, False: 61.6M]
  ------------------
  579|  6.60M|    return STRUCTURE;
  580|  54.6M|  default:
  ------------------
  |  Branch (580:3): [True: 54.6M, False: 7.08M]
  ------------------
  581|  54.6M|    return LITERAL;
  582|  61.6M|  }
  583|  61.6M|}
jv_parse.c:tokenadd:
  423|  67.4M|static pfunc tokenadd(struct jv_parser* p, char c) {
  424|  67.4M|  assert(p->tokenpos <= p->tokenlen);
  ------------------
  |  Branch (424:3): [True: 0, False: 67.4M]
  |  Branch (424:3): [True: 67.4M, False: 0]
  ------------------
  425|  67.4M|  if (p->tokenpos >= (p->tokenlen - 1)) {
  ------------------
  |  Branch (425:7): [True: 2.76k, False: 67.4M]
  ------------------
  426|  2.76k|    if (p->tokenlen > INT_MAX / 2)
  ------------------
  |  Branch (426:9): [True: 0, False: 2.76k]
  ------------------
  427|      0|      return "Token too long";
  428|  2.76k|    p->tokenlen *= 2;
  429|  2.76k|    p->tokenbuf = jv_mem_realloc(p->tokenbuf, p->tokenlen);
  430|  2.76k|  }
  431|  67.4M|  assert(p->tokenpos < p->tokenlen);
  ------------------
  |  Branch (431:3): [True: 0, False: 67.4M]
  |  Branch (431:3): [True: 67.4M, False: 0]
  ------------------
  432|  67.4M|  p->tokenbuf[p->tokenpos++] = c;
  433|  67.4M|  return 0;
  434|  67.4M|}
jv_parse.c:parse_token:
  158|  6.60M|static pfunc parse_token(struct jv_parser* p, char ch) {
  159|  6.60M|  switch (ch) {
  ------------------
  |  Branch (159:11): [True: 6.60M, False: 0]
  ------------------
  160|   287k|  case '[':
  ------------------
  |  Branch (160:3): [True: 287k, False: 6.31M]
  ------------------
  161|   287k|    if (p->stackpos >= MAX_PARSING_DEPTH) return "Exceeds depth limit for parsing";
  ------------------
  |  |   15|   287k|#define MAX_PARSING_DEPTH (10000)
  ------------------
  |  Branch (161:9): [True: 1, False: 287k]
  ------------------
  162|   287k|    if (jv_is_valid(p->next)) return "Expected separator between values";
  ------------------
  |  Branch (162:9): [True: 10, False: 287k]
  ------------------
  163|   287k|    push(p, jv_array());
  164|   287k|    break;
  165|       |
  166|   165k|  case '{':
  ------------------
  |  Branch (166:3): [True: 165k, False: 6.44M]
  ------------------
  167|   165k|    if (p->stackpos >= MAX_PARSING_DEPTH) return "Exceeds depth limit for parsing";
  ------------------
  |  |   15|   165k|#define MAX_PARSING_DEPTH (10000)
  ------------------
  |  Branch (167:9): [True: 1, False: 165k]
  ------------------
  168|   165k|    if (jv_is_valid(p->next)) return "Expected separator between values";
  ------------------
  |  Branch (168:9): [True: 5, False: 165k]
  ------------------
  169|   165k|    push(p, jv_object());
  170|   165k|    break;
  171|       |
  172|  58.3k|  case ':':
  ------------------
  |  Branch (172:3): [True: 58.3k, False: 6.54M]
  ------------------
  173|  58.3k|    if (!jv_is_valid(p->next))
  ------------------
  |  Branch (173:9): [True: 13, False: 58.3k]
  ------------------
  174|     13|      return "Expected string key before ':'";
  175|  58.3k|    if (p->stackpos == 0 || jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_OBJECT)
  ------------------
  |  Branch (175:9): [True: 0, False: 58.3k]
  |  Branch (175:29): [True: 11, False: 58.3k]
  ------------------
  176|     11|      return "':' not as part of an object";
  177|  58.3k|    if (jv_get_kind(p->next) != JV_KIND_STRING)
  ------------------
  |  Branch (177:9): [True: 8, False: 58.3k]
  ------------------
  178|      8|      return "Object keys must be strings";
  179|  58.3k|    push(p, p->next);
  180|  58.3k|    p->next = jv_invalid();
  181|  58.3k|    break;
  182|       |
  183|  6.05M|  case ',':
  ------------------
  |  Branch (183:3): [True: 6.05M, False: 554k]
  ------------------
  184|  6.05M|    if (!jv_is_valid(p->next))
  ------------------
  |  Branch (184:9): [True: 17, False: 6.05M]
  ------------------
  185|     17|      return "Expected value before ','";
  186|  6.05M|    if (p->stackpos == 0)
  ------------------
  |  Branch (186:9): [True: 0, False: 6.05M]
  ------------------
  187|      0|      return "',' not as part of an object or array";
  188|  6.05M|    if (jv_get_kind(p->stack[p->stackpos-1]) == JV_KIND_ARRAY) {
  ------------------
  |  Branch (188:9): [True: 6.00M, False: 48.4k]
  ------------------
  189|  6.00M|      p->stack[p->stackpos-1] = jv_array_append(p->stack[p->stackpos-1], p->next);
  190|  6.00M|      p->next = jv_invalid();
  191|  6.00M|    } else if (jv_get_kind(p->stack[p->stackpos-1]) == JV_KIND_STRING) {
  ------------------
  |  Branch (191:16): [True: 48.4k, False: 11]
  ------------------
  192|  48.4k|      assert(p->stackpos > 1 && jv_get_kind(p->stack[p->stackpos-2]) == JV_KIND_OBJECT);
  ------------------
  |  Branch (192:7): [True: 0, False: 48.4k]
  |  Branch (192:7): [True: 0, False: 0]
  |  Branch (192:7): [True: 48.4k, False: 0]
  |  Branch (192:7): [True: 48.4k, False: 0]
  ------------------
  193|  48.4k|      p->stack[p->stackpos-2] = jv_object_set(p->stack[p->stackpos-2],
  194|  48.4k|                                              p->stack[p->stackpos-1], p->next);
  195|  48.4k|      p->stackpos--;
  196|  48.4k|      p->next = jv_invalid();
  197|  48.4k|    } else {
  198|       |      // this case hits on input like {"a", "b"}
  199|     11|      return "Objects must consist of key:value pairs";
  200|     11|    }
  201|  6.05M|    break;
  202|       |
  203|  6.05M|  case ']':
  ------------------
  |  Branch (203:3): [True: 14.5k, False: 6.59M]
  ------------------
  204|  14.5k|    if (p->stackpos == 0 || jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_ARRAY)
  ------------------
  |  Branch (204:9): [True: 13, False: 14.5k]
  |  Branch (204:29): [True: 8, False: 14.4k]
  ------------------
  205|     21|      return "Unmatched ']'";
  206|  14.4k|    if (jv_is_valid(p->next)) {
  ------------------
  |  Branch (206:9): [True: 910, False: 13.5k]
  ------------------
  207|    910|      p->stack[p->stackpos-1] = jv_array_append(p->stack[p->stackpos-1], p->next);
  208|    910|      p->next = jv_invalid();
  209|  13.5k|    } else {
  210|  13.5k|      if (jv_array_length(jv_copy(p->stack[p->stackpos-1])) != 0) {
  ------------------
  |  Branch (210:11): [True: 41, False: 13.5k]
  ------------------
  211|       |        // this case hits on input like [1,2,3,]
  212|     41|        return "Expected another array element";
  213|     41|      }
  214|  13.5k|    }
  215|  14.4k|    jv_free(p->next);
  216|  14.4k|    p->next = p->stack[--p->stackpos];
  217|  14.4k|    break;
  218|       |
  219|  27.9k|  case '}':
  ------------------
  |  Branch (219:3): [True: 27.9k, False: 6.57M]
  ------------------
  220|  27.9k|    if (p->stackpos == 0)
  ------------------
  |  Branch (220:9): [True: 4, False: 27.9k]
  ------------------
  221|      4|      return "Unmatched '}'";
  222|  27.9k|    if (jv_is_valid(p->next)) {
  ------------------
  |  Branch (222:9): [True: 8.34k, False: 19.6k]
  ------------------
  223|  8.34k|      if (jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_STRING)
  ------------------
  |  Branch (223:11): [True: 11, False: 8.33k]
  ------------------
  224|     11|        return "Objects must consist of key:value pairs";
  225|  8.34k|      assert(p->stackpos > 1 && jv_get_kind(p->stack[p->stackpos-2]) == JV_KIND_OBJECT);
  ------------------
  |  Branch (225:7): [True: 0, False: 8.33k]
  |  Branch (225:7): [True: 0, False: 0]
  |  Branch (225:7): [True: 8.33k, False: 0]
  |  Branch (225:7): [True: 8.33k, False: 0]
  ------------------
  226|  8.33k|      p->stack[p->stackpos-2] = jv_object_set(p->stack[p->stackpos-2],
  227|  8.33k|                                              p->stack[p->stackpos-1], p->next);
  228|  8.33k|      p->stackpos--;
  229|  8.33k|      p->next = jv_invalid();
  230|  19.6k|    } else {
  231|  19.6k|      if (jv_get_kind(p->stack[p->stackpos-1]) != JV_KIND_OBJECT)
  ------------------
  |  Branch (231:11): [True: 16, False: 19.6k]
  ------------------
  232|     16|        return "Unmatched '}'";
  233|  19.6k|      if (jv_object_length(jv_copy(p->stack[p->stackpos-1])) != 0)
  ------------------
  |  Branch (233:11): [True: 18, False: 19.6k]
  ------------------
  234|     18|        return "Expected another key-value pair";
  235|  19.6k|    }
  236|  27.9k|    jv_free(p->next);
  237|  27.9k|    p->next = p->stack[--p->stackpos];
  238|  27.9k|    break;
  239|  6.60M|  }
  240|  6.60M|  return 0;
  241|  6.60M|}
jv_parse.c:push:
  148|   512k|static void push(struct jv_parser* p, jv v) {
  149|   512k|  assert(p->stackpos <= p->stacklen);
  ------------------
  |  Branch (149:3): [True: 0, False: 512k]
  |  Branch (149:3): [True: 512k, False: 0]
  ------------------
  150|   512k|  if (p->stackpos == p->stacklen) {
  ------------------
  |  Branch (150:7): [True: 2.24k, False: 509k]
  ------------------
  151|  2.24k|    p->stacklen = p->stacklen * 2 + 10;
  152|  2.24k|    p->stack = jv_mem_realloc(p->stack, p->stacklen * sizeof(jv));
  153|  2.24k|  }
  154|   512k|  assert(p->stackpos < p->stacklen);
  ------------------
  |  Branch (154:3): [True: 0, False: 512k]
  |  Branch (154:3): [True: 512k, False: 0]
  ------------------
  155|   512k|  p->stack[p->stackpos++] = v;
  156|   512k|}
jv_parse.c:found_string:
  451|  69.4k|static pfunc found_string(struct jv_parser* p) {
  452|  69.4k|  char* in = p->tokenbuf;
  453|  69.4k|  char* out = p->tokenbuf;
  454|  69.4k|  char* end = p->tokenbuf + p->tokenpos;
  455|       |
  456|  5.56M|  while (in < end) {
  ------------------
  |  Branch (456:10): [True: 5.50M, False: 69.2k]
  ------------------
  457|  5.50M|    char c = *in++;
  458|  5.50M|    if (c == '\\') {
  ------------------
  |  Branch (458:9): [True: 9.85k, False: 5.49M]
  ------------------
  459|  9.85k|      if (in >= end)
  ------------------
  |  Branch (459:11): [True: 0, False: 9.85k]
  ------------------
  460|      0|        return "Expected escape character at end of string";
  461|  9.85k|      c = *in++;
  462|  9.85k|      switch (c) {
  463|  1.22k|      case '\\':
  ------------------
  |  Branch (463:7): [True: 1.22k, False: 8.63k]
  ------------------
  464|  2.37k|      case '"':
  ------------------
  |  Branch (464:7): [True: 1.15k, False: 8.70k]
  ------------------
  465|  2.99k|      case '/': *out++ = c;    break;
  ------------------
  |  Branch (465:7): [True: 613, False: 9.24k]
  ------------------
  466|  1.97k|      case 'b': *out++ = '\b'; break;
  ------------------
  |  Branch (466:7): [True: 1.97k, False: 7.88k]
  ------------------
  467|    194|      case 'f': *out++ = '\f'; break;
  ------------------
  |  Branch (467:7): [True: 194, False: 9.66k]
  ------------------
  468|  1.49k|      case 't': *out++ = '\t'; break;
  ------------------
  |  Branch (468:7): [True: 1.49k, False: 8.36k]
  ------------------
  469|    489|      case 'n': *out++ = '\n'; break;
  ------------------
  |  Branch (469:7): [True: 489, False: 9.36k]
  ------------------
  470|    424|      case 'r': *out++ = '\r'; break;
  ------------------
  |  Branch (470:7): [True: 424, False: 9.43k]
  ------------------
  471|       |
  472|  2.29k|      case 'u':
  ------------------
  |  Branch (472:7): [True: 2.29k, False: 7.56k]
  ------------------
  473|       |        /* ahh, the complicated case */
  474|  2.29k|        if (in + 4 > end)
  ------------------
  |  Branch (474:13): [True: 2, False: 2.29k]
  ------------------
  475|      2|          return "Invalid \\uXXXX escape";
  476|  2.29k|        int hexvalue = unhex4(in);
  477|  2.29k|        if (hexvalue < 0)
  ------------------
  |  Branch (477:13): [True: 28, False: 2.26k]
  ------------------
  478|     28|          return "Invalid characters in \\uXXXX escape";
  479|  2.26k|        unsigned long codepoint = (unsigned long)hexvalue;
  480|  2.26k|        in += 4;
  481|  2.26k|        if (0xD800 <= codepoint && codepoint <= 0xDBFF) {
  ------------------
  |  Branch (481:13): [True: 1.52k, False: 736]
  |  Branch (481:36): [True: 623, False: 906]
  ------------------
  482|       |          /* who thought UTF-16 surrogate pairs were a good idea? */
  483|    623|          if (in + 6 > end || in[0] != '\\' || in[1] != 'u')
  ------------------
  |  Branch (483:15): [True: 12, False: 611]
  |  Branch (483:31): [True: 11, False: 600]
  |  Branch (483:48): [True: 12, False: 588]
  ------------------
  484|     35|            return "Invalid \\uXXXX\\uXXXX surrogate pair escape";
  485|    588|          unsigned long surrogate = unhex4(in+2);
  486|    588|          if (!(0xDC00 <= surrogate && surrogate <= 0xDFFF))
  ------------------
  |  Branch (486:17): [True: 565, False: 23]
  |  Branch (486:40): [True: 531, False: 34]
  ------------------
  487|     57|            return "Invalid \\uXXXX\\uXXXX surrogate pair escape";
  488|    531|          in += 6;
  489|    531|          codepoint = 0x10000 + (((codepoint - 0xD800) << 10)
  490|    531|                                 |(surrogate - 0xDC00));
  491|    531|        }
  492|  2.17k|        if (codepoint > 0x10FFFF)
  ------------------
  |  Branch (492:13): [True: 0, False: 2.17k]
  ------------------
  493|      0|          codepoint = 0xFFFD; // U+FFFD REPLACEMENT CHARACTER
  494|  2.17k|        out += jvp_utf8_encode(codepoint, out);
  495|  2.17k|        break;
  496|       |
  497|      1|      default:
  ------------------
  |  Branch (497:7): [True: 1, False: 9.85k]
  ------------------
  498|      1|        return "Invalid escape";
  499|  9.85k|      }
  500|  5.49M|    } else {
  501|  5.49M|      if (!(c & ~0x1F))
  ------------------
  |  Branch (501:11): [True: 62, False: 5.49M]
  ------------------
  502|     62|        return "Invalid string: control characters from U+0000 through U+001F must be escaped";
  503|  5.49M|      *out++ = c;
  504|  5.49M|    }
  505|  5.50M|  }
  506|  69.2k|  TRY(value(p, jv_string_sized(p->tokenbuf, out - p->tokenbuf)));
  ------------------
  |  |   18|  69.2k|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 22, False: 69.2k]
  |  |  |  Branch (18:74): [Folded, False: 69.2k]
  |  |  ------------------
  ------------------
  507|  69.2k|  p->tokenpos = 0;
  508|  69.2k|  return 0;
  509|  69.2k|}
jv_parse.c:unhex4:
  436|  2.88k|static int unhex4(char* hex) {
  437|  2.88k|  int r = 0;
  438|  14.2k|  for (int i=0; i<4; i++) {
  ------------------
  |  Branch (438:17): [True: 11.4k, False: 2.82k]
  ------------------
  439|  11.4k|    char c = *hex++;
  440|  11.4k|    int n;
  441|  11.4k|    if ('0' <= c && c <= '9') n = c - '0';
  ------------------
  |  Branch (441:9): [True: 11.4k, False: 29]
  |  Branch (441:21): [True: 4.47k, False: 6.94k]
  ------------------
  442|  6.97k|    else if ('a' <= c && c <= 'f') n = c - 'a' + 10;
  ------------------
  |  Branch (442:14): [True: 4.73k, False: 2.24k]
  |  Branch (442:26): [True: 4.72k, False: 10]
  ------------------
  443|  2.25k|    else if ('A' <= c && c <= 'F') n = c - 'A' + 10;
  ------------------
  |  Branch (443:14): [True: 2.21k, False: 35]
  |  Branch (443:26): [True: 2.19k, False: 22]
  ------------------
  444|     57|    else return -1;
  445|  11.3k|    r <<= 4;
  446|  11.3k|    r |= n;
  447|  11.3k|  }
  448|  2.82k|  return r;
  449|  2.88k|}
jv_parse.c:value:
  127|  6.07M|static pfunc value(struct jv_parser* p, jv val) {
  128|  6.07M|  if ((p->flags & JV_PARSE_STREAMING)) {
  ------------------
  |  Branch (128:7): [True: 0, False: 6.07M]
  ------------------
  129|      0|    if (jv_is_valid(p->next) || p->last_seen == JV_LAST_VALUE) {
  ------------------
  |  Branch (129:9): [True: 0, False: 0]
  |  Branch (129:33): [True: 0, False: 0]
  ------------------
  130|      0|      jv_free(val);
  131|      0|      return "Expected separator between values";
  132|      0|    }
  133|      0|    if (p->stacklen > 0)
  ------------------
  |  Branch (133:9): [True: 0, False: 0]
  ------------------
  134|      0|      p->last_seen = JV_LAST_VALUE;
  135|      0|    else
  136|      0|      p->last_seen = JV_LAST_NONE;
  137|  6.07M|  } else {
  138|  6.07M|    if (jv_is_valid(p->next)) {
  ------------------
  |  Branch (138:9): [True: 42, False: 6.07M]
  ------------------
  139|     42|      jv_free(val);
  140|     42|      return "Expected separator between values";
  141|     42|    }
  142|  6.07M|  }
  143|  6.07M|  jv_free(p->next);
  144|  6.07M|  p->next = val;
  145|  6.07M|  return 0;
  146|  6.07M|}
jv_parse.c:make_error:
  762|  2.01k|static jv make_error(struct jv_parser* p, const char *fmt, ...) {
  763|  2.01k|  va_list ap;
  764|  2.01k|  va_start(ap, fmt);
  765|  2.01k|  jv e = jv_string_vfmt(fmt, ap);
  766|  2.01k|  va_end(ap);
  767|  2.01k|  if ((p->flags & JV_PARSE_STREAM_ERRORS))
  ------------------
  |  Branch (767:7): [True: 0, False: 2.01k]
  ------------------
  768|      0|    return JV_ARRAY(e, jv_copy(p->path));
  ------------------
  |  |  111|      0|  JV_ARRAY_IDX(__VA_ARGS__, JV_ARRAY_9, JV_ARRAY_8, JV_ARRAY_7, JV_ARRAY_6, JV_ARRAY_5, JV_ARRAY_4, JV_ARRAY_3, JV_ARRAY_2, JV_ARRAY_1, dummy)(__VA_ARGS__)
  |  |  ------------------
  |  |  |  |  109|      0|#define JV_ARRAY_IDX(_1,_2,_3,_4,_5,_6,_7,_8,_9,NAME,...) NAME
  |  |  |  |  ------------------
  |  |  |  |  |  |  111|      0|  JV_ARRAY_IDX(__VA_ARGS__, JV_ARRAY_9, JV_ARRAY_8, JV_ARRAY_7, JV_ARRAY_6, JV_ARRAY_5, JV_ARRAY_4, JV_ARRAY_3, JV_ARRAY_2, JV_ARRAY_1, dummy)(__VA_ARGS__)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  101|      0|#define JV_ARRAY_2(e1,e2) (jv_array_append(JV_ARRAY_1(e1),e2))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  |  |  100|      0|#define JV_ARRAY_1(e) (jv_array_append(jv_array(),e))
  |  |  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  769|  2.01k|  return jv_invalid_with_msg(e);
  770|  2.01k|}
jv_parse.c:check_literal:
  511|  7.09M|static pfunc check_literal(struct jv_parser* p) {
  512|  7.09M|  if (p->tokenpos == 0) return 0;
  ------------------
  |  Branch (512:7): [True: 1.08M, False: 6.01M]
  ------------------
  513|       |
  514|  6.01M|  const char* pattern = 0;
  515|  6.01M|  int plen;
  516|  6.01M|  jv v;
  517|  6.01M|  switch (p->tokenbuf[0]) {
  ------------------
  |  Branch (517:11): [True: 1.88k, False: 6.00M]
  ------------------
  518|    413|  case 't': pattern = "true"; plen = 4; v = jv_true(); break;
  ------------------
  |  Branch (518:3): [True: 413, False: 6.01M]
  ------------------
  519|    258|  case 'f': pattern = "false"; plen = 5; v = jv_false(); break;
  ------------------
  |  Branch (519:3): [True: 258, False: 6.01M]
  ------------------
  520|      8|  case '\'':
  ------------------
  |  Branch (520:3): [True: 8, False: 6.01M]
  ------------------
  521|      8|    return "Invalid string literal; expected \", but got '";
  522|  1.20k|  case 'n':
  ------------------
  |  Branch (522:3): [True: 1.20k, False: 6.00M]
  ------------------
  523|       |    // if it starts with 'n', it could be a literal "nan"
  524|  1.20k|    if (p->tokenpos > 1 && p->tokenbuf[1] == 'u') {
  ------------------
  |  Branch (524:9): [True: 1.19k, False: 8]
  |  Branch (524:28): [True: 252, False: 942]
  ------------------
  525|    252|      pattern = "null"; plen = 4; v = jv_null();
  526|    252|    }
  527|  6.01M|  }
  528|  6.01M|  if (pattern) {
  ------------------
  |  Branch (528:7): [True: 923, False: 6.00M]
  ------------------
  529|    923|    if (p->tokenpos != plen) return "Invalid literal";
  ------------------
  |  Branch (529:9): [True: 75, False: 848]
  ------------------
  530|  4.44k|    for (int i=0; i<plen; i++)
  ------------------
  |  Branch (530:19): [True: 3.60k, False: 834]
  ------------------
  531|  3.60k|      if (p->tokenbuf[i] != pattern[i])
  ------------------
  |  Branch (531:11): [True: 14, False: 3.59k]
  ------------------
  532|     14|        return "Invalid literal";
  533|    834|    TRY(value(p, v));
  ------------------
  |  |   18|    834|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 2, False: 832]
  |  |  |  Branch (18:74): [Folded, False: 832]
  |  |  ------------------
  ------------------
  534|  6.00M|  } else {
  535|       |    // FIXME: better parser
  536|  6.00M|    p->tokenbuf[p->tokenpos] = 0;
  537|  6.00M|#ifdef USE_DECNUM
  538|  6.00M|    jv number = jv_number_with_literal(p->tokenbuf);
  539|  6.00M|    if (jv_get_kind(number) == JV_KIND_INVALID) {
  ------------------
  |  Branch (539:9): [True: 652, False: 6.00M]
  ------------------
  540|    652|      return "Invalid numeric literal";
  541|    652|    }
  542|  6.00M|    TRY(value(p, number));
  ------------------
  |  |   18|  6.00M|#define TRY(x) do {presult msg__ = (x); if (msg__) return msg__; } while(0)
  |  |  ------------------
  |  |  |  Branch (18:45): [True: 18, False: 6.00M]
  |  |  |  Branch (18:74): [Folded, False: 6.00M]
  |  |  ------------------
  ------------------
  543|       |#else
  544|       |    char *end = 0;
  545|       |    double d = jvp_strtod(&p->dtoa, p->tokenbuf, &end);
  546|       |    if (end == 0 || *end != 0) {
  547|       |      return "Invalid numeric literal";
  548|       |    }
  549|       |    TRY(value(p, jv_number(d)));
  550|       |#endif
  551|  6.00M|  }
  552|  6.00M|  p->tokenpos = 0;
  553|  6.00M|  return 0;
  554|  6.01M|}

jvp_utf8_next:
   30|  58.3M|const char* jvp_utf8_next(const char* in, const char* end, int* codepoint_ret) {
   31|  58.3M|  assert(in <= end);
  ------------------
  |  Branch (31:3): [True: 0, False: 58.3M]
  |  Branch (31:3): [True: 58.3M, False: 0]
  ------------------
   32|  58.3M|  if (in == end) {
  ------------------
  |  Branch (32:7): [True: 73.4k, False: 58.2M]
  ------------------
   33|  73.4k|    return 0;
   34|  73.4k|  }
   35|  58.2M|  int codepoint = -1;
   36|  58.2M|  unsigned char first = (unsigned char)in[0];
   37|  58.2M|  int length = utf8_coding_length[first];
   38|  58.2M|  if ((first & 0x80) == 0) {
  ------------------
  |  Branch (38:7): [True: 50.5M, False: 7.73M]
  ------------------
   39|       |    /* Fast-path for ASCII */
   40|  50.5M|    codepoint = first;
   41|  50.5M|    length = 1;
   42|  50.5M|  } else if (length == 0 || length == UTF8_CONTINUATION_BYTE) {
  ------------------
  |  |    1|  6.95M|#define UTF8_CONTINUATION_BYTE ((unsigned char)255)
  ------------------
  |  Branch (42:14): [True: 770k, False: 6.95M]
  |  Branch (42:29): [True: 6.89M, False: 63.8k]
  ------------------
   43|       |    /* Bad single byte - either an invalid byte or an out-of-place continuation byte */
   44|  7.66M|    length = 1;
   45|  7.66M|  } else if (length > end - in) {
  ------------------
  |  Branch (45:14): [True: 2.28k, False: 61.5k]
  ------------------
   46|       |    /* String ends before UTF8 sequence ends */
   47|  2.28k|    length = end - in;
   48|  61.5k|  } else {
   49|  61.5k|    codepoint = ((unsigned)in[0]) & utf8_coding_bits[first];
   50|  77.4k|    for (int i=1; i<length; i++) {
  ------------------
  |  Branch (50:19): [True: 69.9k, False: 7.46k]
  ------------------
   51|  69.9k|      unsigned ch = (unsigned char)in[i];
   52|  69.9k|      if (utf8_coding_length[ch] != UTF8_CONTINUATION_BYTE){
  ------------------
  |  |    1|  69.9k|#define UTF8_CONTINUATION_BYTE ((unsigned char)255)
  ------------------
  |  Branch (52:11): [True: 54.1k, False: 15.8k]
  ------------------
   53|       |        /* Invalid UTF8 sequence - not followed by the right number of continuation bytes */
   54|  54.1k|        codepoint = -1;
   55|  54.1k|        length = i;
   56|  54.1k|        break;
   57|  54.1k|      }
   58|  15.8k|      codepoint = (codepoint << 6) | (ch & 0x3f);
   59|  15.8k|    }
   60|  61.5k|    if (codepoint < utf8_first_codepoint[length]) {
  ------------------
  |  Branch (60:9): [True: 54.1k, False: 7.46k]
  ------------------
   61|       |      /* Overlong UTF8 sequence */
   62|  54.1k|      codepoint = -1;
   63|  54.1k|    }
   64|  61.5k|    if (0xD800 <= codepoint && codepoint <= 0xDFFF) {
  ------------------
  |  Branch (64:9): [True: 4.20k, False: 57.3k]
  |  Branch (64:32): [True: 485, False: 3.71k]
  ------------------
   65|       |      /* Surrogate codepoints can't be encoded in UTF8 */
   66|    485|      codepoint = -1;
   67|    485|    }
   68|  61.5k|    if (codepoint > 0x10FFFF) {
  ------------------
  |  Branch (68:9): [True: 241, False: 61.3k]
  ------------------
   69|       |      /* Outside Unicode range */
   70|    241|      codepoint = -1;
   71|    241|    }
   72|  61.5k|  }
   73|  58.2M|  assert(length > 0);
  ------------------
  |  Branch (73:3): [True: 0, False: 58.2M]
  |  Branch (73:3): [True: 58.2M, False: 0]
  ------------------
   74|  58.2M|  *codepoint_ret = codepoint;
   75|  58.2M|  return in + length;
   76|  58.2M|}
jvp_utf8_is_valid:
   78|  73.4k|int jvp_utf8_is_valid(const char* in, const char* end) {
   79|  73.4k|  int codepoint;
   80|  26.9M|  while ((in = jvp_utf8_next(in, end, &codepoint))) {
  ------------------
  |  Branch (80:10): [True: 26.8M, False: 70.3k]
  ------------------
   81|  26.8M|    if (codepoint == -1) return 0;
  ------------------
  |  Branch (81:9): [True: 3.17k, False: 26.8M]
  ------------------
   82|  26.8M|  }
   83|  70.3k|  return 1;
   84|  73.4k|}
jvp_utf8_encode_length:
   94|  31.4M|int jvp_utf8_encode_length(int codepoint) {
   95|  31.4M|  if (codepoint <= 0x7F) return 1;
  ------------------
  |  Branch (95:7): [True: 23.7M, False: 7.72M]
  ------------------
   96|  7.72M|  else if (codepoint <= 0x7FF) return 2;
  ------------------
  |  Branch (96:12): [True: 2.21k, False: 7.72M]
  ------------------
   97|  7.72M|  else if (codepoint <= 0xFFFF) return 3;
  ------------------
  |  Branch (97:12): [True: 7.72M, False: 2.87k]
  ------------------
   98|  2.87k|  else return 4;
   99|  31.4M|}
jvp_utf8_encode:
  101|  31.4M|int jvp_utf8_encode(int codepoint, char* out) {
  102|  31.4M|  assert(codepoint >= 0 && codepoint <= 0x10FFFF);
  ------------------
  |  Branch (102:3): [True: 0, False: 31.4M]
  |  Branch (102:3): [True: 0, False: 0]
  |  Branch (102:3): [True: 31.4M, False: 0]
  |  Branch (102:3): [True: 31.4M, False: 0]
  ------------------
  103|  31.4M|  char* start = out;
  104|  31.4M|  if (codepoint <= 0x7F) {
  ------------------
  |  Branch (104:7): [True: 23.7M, False: 7.72M]
  ------------------
  105|  23.7M|    *out++ = codepoint;
  106|  23.7M|  } else if (codepoint <= 0x7FF) {
  ------------------
  |  Branch (106:14): [True: 2.21k, False: 7.72M]
  ------------------
  107|  2.21k|    *out++ = 0xC0 + ((codepoint & 0x7C0) >> 6);
  108|  2.21k|    *out++ = 0x80 + ((codepoint & 0x03F));
  109|  7.72M|  } else if(codepoint <= 0xFFFF) {
  ------------------
  |  Branch (109:13): [True: 7.72M, False: 2.87k]
  ------------------
  110|  7.72M|    *out++ = 0xE0 + ((codepoint & 0xF000) >> 12);
  111|  7.72M|    *out++ = 0x80 + ((codepoint & 0x0FC0) >> 6);
  112|  7.72M|    *out++ = 0x80 + ((codepoint & 0x003F));
  113|  7.72M|  } else {
  114|  2.87k|    *out++ = 0xF0 + ((codepoint & 0x1C0000) >> 18);
  115|  2.87k|    *out++ = 0x80 + ((codepoint & 0x03F000) >> 12);
  116|  2.87k|    *out++ = 0x80 + ((codepoint & 0x000FC0) >> 6);
  117|  2.87k|    *out++ = 0x80 + ((codepoint & 0x00003F));
  118|  2.87k|  }
  119|  31.4M|  assert(out - start == jvp_utf8_encode_length(codepoint));
  ------------------
  |  Branch (119:3): [True: 0, False: 31.4M]
  |  Branch (119:3): [True: 31.4M, False: 0]
  ------------------
  120|  31.4M|  return out - start;
  121|  31.4M|}

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

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

decNumberFromString:
  479|  6.00M|                                decContext *set) {
  480|  6.00M|  Int   exponent=0;                // working exponent [assume 0]
  ------------------
  |  |   92|  6.00M|  #define Int    int32_t
  ------------------
  481|  6.00M|  uByte bits=0;                    // working flags [assume +ve]
  ------------------
  |  |   89|  6.00M|  #define uByte  uint8_t
  ------------------
  482|  6.00M|  Unit  *res;                      // where result will be built
  ------------------
  |  |   94|  6.00M|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  6.00M|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
  483|  6.00M|  Unit  resbuff[SD2U(DECBUFFER+9)];// local buffer in case need temporary
  ------------------
  |  |   94|  6.00M|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  6.00M|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
  484|       |                                   // [+9 allows for ln() constants]
  485|  6.00M|  Unit  *allocres=NULL;            // -> allocated result, iff allocated
  ------------------
  |  |   94|  6.00M|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  6.00M|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
  486|  6.00M|  Int   d=0;                       // count of digits found in decimal part
  ------------------
  |  |   92|  6.00M|  #define Int    int32_t
  ------------------
  487|  6.00M|  const char *dotchar=NULL;        // where dot was found
  488|  6.00M|  const char *cfirst=chars;        // -> first character of decimal part
  489|  6.00M|  const char *last=NULL;           // -> last digit of decimal part
  490|  6.00M|  const char *c;                   // work
  491|  6.00M|  Unit  *up;                       // ..
  ------------------
  |  |   94|  6.00M|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  6.00M|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
  492|  6.00M|  #if DECDPUN>1
  493|  6.00M|  Int   cut, out;                  // ..
  ------------------
  |  |   92|  6.00M|  #define Int    int32_t
  ------------------
  494|  6.00M|  #endif
  495|  6.00M|  Int   residue;                   // rounding residue
  ------------------
  |  |   92|  6.00M|  #define Int    int32_t
  ------------------
  496|  6.00M|  uInt  status=0;                  // error code
  ------------------
  |  |   93|  6.00M|  #define uInt   uint32_t
  ------------------
  497|       |
  498|       |  #if DECCHECK
  499|       |  if (decCheckOperands(DECUNRESU, DECUNUSED, DECUNUSED, set))
  500|       |    return decNumberZero(dn);
  501|       |  #endif
  502|       |
  503|  6.00M|  do {                             // status & malloc protection
  504|  40.9M|    for (c=chars;; c++) {          // -> input character
  505|  40.9M|      if (*c>='0' && *c<='9') {    // test for Arabic digit
  ------------------
  |  Branch (505:11): [True: 34.9M, False: 5.97M]
  |  Branch (505:22): [True: 34.8M, False: 36.3k]
  ------------------
  506|  34.8M|        last=c;
  507|  34.8M|        d++;                       // count of real digits
  508|  34.8M|        continue;                  // still in decimal part
  509|  34.8M|        }
  510|  6.01M|      if (*c=='.' && dotchar==NULL) { // first '.'
  ------------------
  |  Branch (510:11): [True: 4.24k, False: 6.01M]
  |  Branch (510:22): [True: 4.24k, False: 1]
  ------------------
  511|  4.24k|        dotchar=c;                 // record offset into decimal part
  512|  4.24k|        if (c==cfirst) cfirst++;   // first digit must follow
  ------------------
  |  Branch (512:13): [True: 1.56k, False: 2.67k]
  ------------------
  513|  4.24k|        continue;}
  514|  6.01M|      if (c==chars) {              // first in string...
  ------------------
  |  Branch (514:11): [True: 5.07k, False: 6.00M]
  ------------------
  515|  5.07k|        if (*c=='-') {             // valid - sign
  ------------------
  |  Branch (515:13): [True: 433, False: 4.64k]
  ------------------
  516|    433|          cfirst++;
  517|    433|          bits=DECNEG;
  ------------------
  |  |   31|    433|  #define DECNEG    0x80      /* Sign; 1=negative, 0=positive or zero */
  ------------------
  518|    433|          continue;}
  519|  4.64k|        if (*c=='+') {             // valid + sign
  ------------------
  |  Branch (519:13): [True: 1.69k, False: 2.95k]
  ------------------
  520|  1.69k|          cfirst++;
  521|  1.69k|          continue;}
  522|  4.64k|        }
  523|       |      // *c is not a digit, or a valid +, -, or '.'
  524|  6.00M|      break;
  525|  6.01M|      } // c
  526|       |
  527|  6.00M|    if (last==NULL) {              // no digits yet
  ------------------
  |  Branch (527:9): [True: 2.98k, False: 6.00M]
  ------------------
  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: 28, 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: 2, False: 2.95k]
  ------------------
  536|  2.95k|      decNumberZero(dn);           // be optimistic
  537|  2.95k|      if (decBiStr(c, "infinity", "INFINITY")
  ------------------
  |  Branch (537:11): [True: 212, False: 2.74k]
  ------------------
  538|  2.74k|       || decBiStr(c, "inf", "INF")) {
  ------------------
  |  Branch (538:11): [True: 387, False: 2.35k]
  ------------------
  539|    599|        dn->bits=bits | DECINF;
  ------------------
  |  |   32|    599|  #define DECINF    0x40      /* 1=Infinity                           */
  ------------------
  540|    599|        status=0;                  // is OK
  541|    599|        break; // all done
  542|    599|        }
  543|       |      // a NaN expected
  544|       |      // 2003.09.10 NaNs are now permitted to have a sign
  545|  2.35k|      dn->bits=bits | DECNAN;      // assume simple NaN
  ------------------
  |  |   33|  2.35k|  #define DECNAN    0x20      /* 1=NaN                                */
  ------------------
  546|  2.35k|      if (*c=='s' || *c=='S') {    // looks like an sNaN
  ------------------
  |  Branch (546:11): [True: 194, False: 2.16k]
  |  Branch (546:22): [True: 200, False: 1.96k]
  ------------------
  547|    394|        c++;
  548|    394|        dn->bits=bits | DECSNAN;
  ------------------
  |  |   34|    394|  #define DECSNAN   0x10      /* 1=sNaN                               */
  ------------------
  549|    394|        }
  550|  2.35k|      if (*c!='n' && *c!='N') break;    // check caseless "NaN"
  ------------------
  |  Branch (550:11): [True: 1.16k, False: 1.19k]
  |  Branch (550:22): [True: 352, False: 813]
  ------------------
  551|  2.00k|      c++;
  552|  2.00k|      if (*c!='a' && *c!='A') break;    // ..
  ------------------
  |  Branch (552:11): [True: 582, False: 1.42k]
  |  Branch (552:22): [True: 58, False: 524]
  ------------------
  553|  1.94k|      c++;
  554|  1.94k|      if (*c!='n' && *c!='N') break;    // ..
  ------------------
  |  Branch (554:11): [True: 993, False: 954]
  |  Branch (554:22): [True: 35, False: 958]
  ------------------
  555|  1.91k|      c++;
  556|       |      // now either nothing, or nnnn payload, expected
  557|       |      // -> start of integer and skip leading 0s [including plain 0]
  558|  2.13k|      for (cfirst=c; *cfirst=='0';) cfirst++;
  ------------------
  |  Branch (558:22): [True: 220, False: 1.91k]
  ------------------
  559|  1.91k|      if (*cfirst=='\0') {         // "NaN" or "sNaN", maybe with all 0s
  ------------------
  |  Branch (559:11): [True: 1.84k, False: 67]
  ------------------
  560|  1.84k|        status=0;                  // it's good
  561|  1.84k|        break;                     // ..
  562|  1.84k|        }
  563|       |      // something other than 0s; setup last and d as usual [no dots]
  564|  1.73M|      for (c=cfirst;; c++, d++) {
  565|  1.73M|        if (*c<'0' || *c>'9') break; // test for Arabic digit
  ------------------
  |  Branch (565:13): [True: 60, False: 1.73M]
  |  Branch (565:23): [True: 7, False: 1.73M]
  ------------------
  566|  1.73M|        last=c;
  567|  1.73M|        }
  568|     67|      if (*c!='\0') break;         // not all digits
  ------------------
  |  Branch (568:11): [True: 19, False: 48]
  ------------------
  569|     48|      if (d>set->digits-1) {
  ------------------
  |  Branch (569:11): [True: 0, False: 48]
  ------------------
  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|     48|      status=0;                    // syntax is OK
  577|     48|      bits=dn->bits;               // for copy-back
  578|     48|      } // last==NULL
  579|       |
  580|  6.00M|     else if (*c!='\0') {          // more to process...
  ------------------
  |  Branch (580:15): [True: 33.6k, False: 5.97M]
  ------------------
  581|       |      // had some digits; exponent is only valid sequence now
  582|  33.6k|      Flag nege;                   // 1=negative exponent
  ------------------
  |  |   87|  33.6k|  #define Flag   uint8_t
  ------------------
  583|  33.6k|      const char *firstexp;        // -> first significant exponent digit
  584|  33.6k|      status=DEC_Conversion_syntax;// assume the worst
  ------------------
  |  |  128|  33.6k|    #define DEC_Conversion_syntax    0x00000001
  ------------------
  585|  33.6k|      uInt expa=0;                 // accumulator for exponent
  ------------------
  |  |   93|  33.6k|  #define uInt   uint32_t
  ------------------
  586|  33.6k|      if (*c!='e' && *c!='E') break;
  ------------------
  |  Branch (586:11): [True: 31.7k, False: 1.91k]
  |  Branch (586:22): [True: 43, False: 31.7k]
  ------------------
  587|       |      /* Found 'e' or 'E' -- now process explicit exponent */
  588|       |      // 1998.07.11: sign no longer required
  589|  33.6k|      nege=0;
  590|  33.6k|      c++;                         // to (possible) sign
  591|  33.6k|      if (*c=='-') {nege=1; c++;}
  ------------------
  |  Branch (591:11): [True: 9.24k, False: 24.3k]
  ------------------
  592|  24.3k|       else if (*c=='+') c++;
  ------------------
  |  Branch (592:17): [True: 220, False: 24.1k]
  ------------------
  593|  33.6k|      if (*c=='\0') break;
  ------------------
  |  Branch (593:11): [True: 29, False: 33.5k]
  ------------------
  594|       |
  595|  33.9k|      for (; *c=='0' && *(c+1)!='\0';) c++;  // strip insignificant zeros
  ------------------
  |  Branch (595:14): [True: 550, False: 33.4k]
  |  Branch (595:25): [True: 388, False: 162]
  ------------------
  596|  33.5k|      firstexp=c;                            // save exponent digit place
  597|  2.62M|      for (; ;c++) {
  598|  2.62M|        if (*c<'0' || *c>'9') break;         // not a digit
  ------------------
  |  Branch (598:13): [True: 33.5k, False: 2.59M]
  |  Branch (598:23): [True: 16, False: 2.59M]
  ------------------
  599|  2.59M|        expa=X10(expa)+(Int)*c-(Int)'0';
  ------------------
  |  |  163|  2.59M|  #define X10(i)  (((i)<<1)+((i)<<3))
  ------------------
  600|  2.59M|        } // c
  601|       |      // if not now on a '\0', *c must not be a digit
  602|  33.5k|      if (*c!='\0') break;
  ------------------
  |  Branch (602:11): [True: 38, False: 33.5k]
  ------------------
  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|  33.5k|      if (c>=firstexp+9+1) {
  ------------------
  |  Branch (607:11): [True: 30.2k, False: 3.28k]
  ------------------
  608|  30.2k|        if (c>firstexp+9+1 || *firstexp>'1') expa=DECNUMMAXE*2;
  ------------------
  |  |  183|  10.3k|  #define DECNUMMAXE 999999999  /* maximum adjusted exponent ditto    */
  ------------------
  |  Branch (608:13): [True: 9.64k, False: 20.6k]
  |  Branch (608:31): [True: 736, False: 19.8k]
  ------------------
  609|       |        // [up to 1999999999 is OK, for example 1E-1000000998]
  610|  30.2k|        }
  611|  33.5k|      exponent=(Int)expa;               // save exponent
  612|  33.5k|      if (nege) exponent=-exponent;     // was negative
  ------------------
  |  Branch (612:11): [True: 9.23k, False: 24.3k]
  ------------------
  613|  33.5k|      status=0;                         // is OK
  614|  33.5k|      } // stuff after digits
  615|       |
  616|       |    // Here when whole string has been inspected; syntax is good
  617|       |    // cfirst->first digit (never dot), last->last digit (ditto)
  618|       |
  619|       |    // strip leading zeros/dot [leave final 0 if all 0's]
  620|  6.00M|    if (*cfirst=='0') {                 // [cfirst has stepped over .]
  ------------------
  |  Branch (620:9): [True: 1.86M, False: 4.13M]
  ------------------
  621|  1.87M|      for (c=cfirst; c<last; c++, cfirst++) {
  ------------------
  |  Branch (621:22): [True: 11.6k, False: 1.86M]
  ------------------
  622|  11.6k|        if (*c=='.') continue;          // ignore dots
  ------------------
  |  Branch (622:13): [True: 1.68k, False: 9.98k]
  ------------------
  623|  9.98k|        if (*c!='0') break;             // non-zero found
  ------------------
  |  Branch (623:13): [True: 337, False: 9.64k]
  ------------------
  624|  9.64k|        d--;                            // 0 stripped
  625|  9.64k|        } // 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|  1.86M|      } // at least one leading 0
  634|       |
  635|       |    // Handle decimal point...
  636|  6.00M|    if (dotchar!=NULL && dotchar<last)  // non-trailing '.' found?
  ------------------
  |  Branch (636:9): [True: 4.22k, False: 6.00M]
  |  Branch (636:26): [True: 3.96k, False: 263]
  ------------------
  637|  3.96k|      exponent-=(last-dotchar);         // adjust exponent
  638|       |    // [we can now ignore the .]
  639|       |
  640|       |    // OK, the digits string is good.  Assemble in the decNumber, or in
  641|       |    // a temporary units array if rounding is needed
  642|  6.00M|    if (d<=set->digits) res=dn->lsu;    // fits into supplied decNumber
  ------------------
  |  Branch (642:9): [True: 6.00M, False: 0]
  ------------------
  643|      0|     else {                             // rounding needed
  644|      0|      Int needbytes=D2U(d)*sizeof(Unit);// bytes needed
  ------------------
  |  |   92|      0|  #define Int    int32_t
  ------------------
                    Int needbytes=D2U(d)*sizeof(Unit);// bytes needed
  ------------------
  |  |  264|      0|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|      0|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|      0|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|      0|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  645|      0|      res=resbuff;                      // assume use local buffer
  646|      0|      if (needbytes>(Int)sizeof(resbuff)) { // too big for local
  ------------------
  |  Branch (646:11): [True: 0, False: 0]
  ------------------
  647|      0|        allocres=(Unit *)malloc(needbytes);
  648|      0|        if (allocres==NULL) {status|=DEC_Insufficient_storage; break;}
  ------------------
  |  |  132|      0|    #define DEC_Insufficient_storage 0x00000010 /* [when malloc fails]  */
  ------------------
  |  Branch (648:13): [True: 0, False: 0]
  ------------------
  649|      0|        res=allocres;
  650|      0|        }
  651|      0|      }
  652|       |    // res now -> number lsu, buffer, or allocated storage for Unit array
  653|       |
  654|       |    // Place the coefficient into the selected Unit array
  655|       |    // [this is often 70% of the cost of this function when DECDPUN>1]
  656|  6.00M|    #if DECDPUN>1
  657|  6.00M|    out=0;                         // accumulator
  658|  6.00M|    up=res+D2U(d)-1;               // -> msu
  ------------------
  |  |  264|  6.00M|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|  6.00M|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|  1.11k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|  1.11k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 6.00M, False: 1.11k]
  |  |  ------------------
  ------------------
  659|  6.00M|    cut=d-(up-res)*DECDPUN;        // digits in top unit
  ------------------
  |  |   43|  6.00M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  660|  35.8M|    for (c=cfirst;; c++) {         // along the digits
  661|  35.8M|      if (*c=='.') continue;       // ignore '.' [don't decrement cut]
  ------------------
  |  Branch (661:11): [True: 720, False: 35.8M]
  ------------------
  662|  35.8M|      out=X10(out)+(Int)*c-(Int)'0';
  ------------------
  |  |  163|  35.8M|  #define X10(i)  (((i)<<1)+((i)<<3))
  ------------------
  663|  35.8M|      if (c==last) break;          // done [never get to trailing '.']
  ------------------
  |  Branch (663:11): [True: 6.00M, False: 29.8M]
  ------------------
  664|  29.8M|      cut--;
  665|  29.8M|      if (cut>0) continue;         // more for this unit
  ------------------
  |  Branch (665:11): [True: 19.9M, False: 9.89M]
  ------------------
  666|  9.89M|      *up=(Unit)out;               // write unit
  667|  9.89M|      up--;                        // prepare for unit below..
  668|  9.89M|      cut=DECDPUN;                 // ..
  ------------------
  |  |   43|  9.89M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  669|  9.89M|      out=0;                       // ..
  670|  9.89M|      } // c
  671|  6.00M|    *up=(Unit)out;                 // write lsu
  672|       |
  673|       |    #else
  674|       |    // DECDPUN==1
  675|       |    up=res;                        // -> lsu
  676|       |    for (c=last; c>=cfirst; c--) { // over each character, from least
  677|       |      if (*c=='.') continue;       // ignore . [don't step up]
  678|       |      *up=(Unit)((Int)*c-(Int)'0');
  679|       |      up++;
  680|       |      } // c
  681|       |    #endif
  682|       |
  683|  6.00M|    dn->bits=bits;
  684|  6.00M|    dn->exponent=exponent;
  685|  6.00M|    dn->digits=d;
  686|       |
  687|       |    // if not in number (too long) shorten into the number
  688|  6.00M|    if (d>set->digits) {
  ------------------
  |  Branch (688:9): [True: 0, False: 6.00M]
  ------------------
  689|      0|      residue=0;
  690|      0|      decSetCoeff(dn, set, res, d, &residue, &status);
  691|       |      // always check for overflow or subnormal and round as needed
  692|      0|      decFinalize(dn, set, &residue, &status);
  693|      0|      }
  694|  6.00M|     else { // no rounding, but may still have overflow or subnormal
  695|       |      // [these tests are just for performance; finalize repeats them]
  696|  6.00M|      if ((dn->exponent-1<set->emin-dn->digits)
  ------------------
  |  Branch (696:11): [True: 8.12k, False: 5.99M]
  ------------------
  697|  5.99M|       || (dn->exponent-1>set->emax-set->digits)) {
  ------------------
  |  Branch (697:11): [True: 22.6k, False: 5.97M]
  ------------------
  698|  30.7k|        residue=0;
  699|  30.7k|        decFinalize(dn, set, &residue, &status);
  700|  30.7k|        }
  701|  6.00M|      }
  702|       |    // decNumberShow(dn);
  703|  6.00M|    } while(0);                         // [for break]
  ------------------
  |  Branch (703:13): [Folded, False: 6.00M]
  ------------------
  704|       |
  705|  6.00M|  if (allocres!=NULL) free(allocres);   // drop any storage used
  ------------------
  |  Branch (705:7): [True: 0, False: 6.00M]
  ------------------
  706|  6.00M|  if (status!=0) decStatus(dn, status, set);
  ------------------
  |  Branch (706:7): [True: 30.8k, False: 5.97M]
  ------------------
  707|  6.00M|  return dn;
  708|  6.00M|  } /* decNumberFromString */
decNumberZero:
 3588|  25.3k|decNumber * decNumberZero(decNumber *dn) {
 3589|       |
 3590|       |  #if DECCHECK
 3591|       |  if (decCheckOperands(dn, DECUNUSED, DECUNUSED, DECUNCONT)) return dn;
 3592|       |  #endif
 3593|       |
 3594|  25.3k|  dn->bits=0;
 3595|  25.3k|  dn->exponent=0;
 3596|  25.3k|  dn->digits=1;
 3597|  25.3k|  dn->lsu[0]=0;
 3598|  25.3k|  return dn;
 3599|  25.3k|  } // decNumberZero
decNumber.c:decUnitAddSub:
 6339|  2.76k|                         Unit *c, Int m) {
 6340|  2.76k|  const Unit *alsu=a;              // A lsu [need to remember it]
 6341|  2.76k|  Unit *clsu=c;                    // C ditto
  ------------------
  |  |   94|  2.76k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  2.76k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6342|  2.76k|  Unit *minC;                      // low water mark for C
  ------------------
  |  |   94|  2.76k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  2.76k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6343|  2.76k|  Unit *maxC;                      // high water mark for C
  ------------------
  |  |   94|  2.76k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  2.76k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6344|  2.76k|  eInt carry=0;                    // carry integer (could be Long)
  ------------------
  |  |  203|  2.76k|  #define eInt  Int           // extended integer
  |  |  ------------------
  |  |  |  |   92|  2.76k|  #define Int    int32_t
  |  |  ------------------
  ------------------
 6345|  2.76k|  Int  add;                        // work
  ------------------
  |  |   92|  2.76k|  #define Int    int32_t
  ------------------
 6346|  2.76k|  #if DECDPUN<=4                   // myriadal, millenary, etc.
 6347|  2.76k|  Int  est;                        // estimated quotient
  ------------------
  |  |   92|  2.76k|  #define Int    int32_t
  ------------------
 6348|  2.76k|  #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.76k|  maxC=c+alength;                  // A is usually the longer
 6356|  2.76k|  minC=c+blength;                  // .. and B the shorter
 6357|  2.76k|  if (bshift!=0) {                 // B is shifted; low As copy across
  ------------------
  |  Branch (6357:7): [True: 0, False: 2.76k]
  ------------------
 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.76k|  if (minC>maxC) { // swap
  ------------------
  |  Branch (6369:7): [True: 0, False: 2.76k]
  ------------------
 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.52k|  for (; c<minC; c++) {
  ------------------
  |  Branch (6379:10): [True: 2.76k, False: 2.76k]
  ------------------
 6380|  2.76k|    carry+=*a;
 6381|  2.76k|    a++;
 6382|  2.76k|    carry+=((eInt)*b)*m;                // [special-casing m=1/-1
 6383|  2.76k|    b++;                                // here is not a win]
 6384|       |    // here carry is new Unit of digits; it could be +ve or -ve
 6385|  2.76k|    if ((ueInt)carry<=DECDPUNMAX) {     // fastpath 0-DECDPUNMAX
  ------------------
  |  |  209|  2.76k|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6385:9): [True: 2.46k, False: 298]
  ------------------
 6386|  2.46k|      *c=(Unit)carry;
 6387|  2.46k|      carry=0;
 6388|  2.46k|      continue;
 6389|  2.46k|      }
 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|    298|      if (carry>=0) {
  ------------------
  |  Branch (6409:11): [True: 298, False: 0]
  ------------------
 6410|    298|        est=(((ueInt)carry>>3)*16777)>>21;
 6411|    298|        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder
  ------------------
  |  |  209|    298|    #define DECDPUNMAX 999
  ------------------
 6412|    298|        carry=est;                           // likely quotient [99%]
 6413|    298|        if (*c<DECDPUNMAX+1) continue;       // estimate was correct
  ------------------
  |  |  209|    298|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6413:13): [True: 0, False: 298]
  ------------------
 6414|    298|        carry++;
 6415|    298|        *c-=DECDPUNMAX+1;
  ------------------
  |  |  209|    298|    #define DECDPUNMAX 999
  ------------------
 6416|    298|        continue;
 6417|    298|        }
 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|  3.12M|  if (c<maxC) for (; c<maxC; c++) {
  ------------------
  |  Branch (6460:7): [True: 1.49k, False: 1.27k]
  |  Branch (6460:22): [True: 3.12M, False: 1.49k]
  ------------------
 6461|  3.12M|    if (a<alsu+alength) {               // still in A
  ------------------
  |  Branch (6461:9): [True: 3.12M, False: 0]
  ------------------
 6462|  3.12M|      carry+=*a;
 6463|  3.12M|      a++;
 6464|  3.12M|      }
 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|  3.12M|    if ((ueInt)carry<=DECDPUNMAX) {     // fastpath 0-DECDPUNMAX
  ------------------
  |  |  209|  3.12M|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6471:9): [True: 2.44M, False: 676k]
  ------------------
 6472|  2.44M|      *c=(Unit)carry;
 6473|  2.44M|      carry=0;
 6474|  2.44M|      continue;
 6475|  2.44M|      }
 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|   676k|      if (carry>=0) {
  ------------------
  |  Branch (6496:11): [True: 676k, False: 0]
  ------------------
 6497|   676k|        est=(((ueInt)carry>>3)*16777)>>21;
 6498|   676k|        *c=(Unit)(carry-est*(DECDPUNMAX+1)); // remainder
  ------------------
  |  |  209|   676k|    #define DECDPUNMAX 999
  ------------------
 6499|   676k|        carry=est;                           // likely quotient [99%]
 6500|   676k|        if (*c<DECDPUNMAX+1) continue;       // estimate was correct
  ------------------
  |  |  209|   676k|    #define DECDPUNMAX 999
  ------------------
  |  Branch (6500:13): [True: 0, False: 676k]
  ------------------
 6501|   676k|        carry++;
 6502|   676k|        *c-=DECDPUNMAX+1;
  ------------------
  |  |  209|   676k|    #define DECDPUNMAX 999
  ------------------
 6503|   676k|        continue;
 6504|   676k|        }
 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.76k|  if (carry==0) return c-clsu;     // no carry, so no more to do
  ------------------
  |  Branch (6546:7): [True: 2.76k, 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|  7.41k|                          uInt *status) {
 7072|  7.41k|  Int  bump;                  // 1 if coefficient needs to be incremented
  ------------------
  |  |   92|  7.41k|  #define Int    int32_t
  ------------------
 7073|       |                              // -1 if coefficient needs to be decremented
 7074|       |
 7075|  7.41k|  if (residue==0) return;     // nothing to apply
  ------------------
  |  Branch (7075:7): [True: 1.46k, False: 5.95k]
  ------------------
 7076|       |
 7077|  5.95k|  bump=0;                     // assume a smooth ride
 7078|       |
 7079|       |  // now decide whether, and how, to round, depending on mode
 7080|  5.95k|  switch (set->round) {
 7081|      0|    case DEC_ROUND_05UP: {    // round zero or five up (for reround)
  ------------------
  |  Branch (7081:5): [True: 0, False: 5.95k]
  ------------------
 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: 5.95k]
  ------------------
 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: 5.95k]
  ------------------
 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: 5.95k]
  ------------------
 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|  5.95k|    case DEC_ROUND_HALF_UP: {
  ------------------
  |  Branch (7110:5): [True: 5.95k, False: 0]
  ------------------
 7111|  5.95k|      if (residue>=5) bump=1;
  ------------------
  |  Branch (7111:11): [True: 3.79k, False: 2.15k]
  ------------------
 7112|  5.95k|      break;} // r-h-u
 7113|       |
 7114|      0|    case DEC_ROUND_UP: {
  ------------------
  |  Branch (7114:5): [True: 0, False: 5.95k]
  ------------------
 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: 5.95k]
  ------------------
 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: 5.95k]
  ------------------
 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: 5.95k]
  ------------------
 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|  5.95k|    } // switch
 7147|       |
 7148|       |  // now bump the number, up or down, if need be
 7149|  5.95k|  if (bump==0) return;                       // no action required
  ------------------
  |  Branch (7149:7): [True: 2.15k, False: 3.79k]
  ------------------
 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.79k|  if (bump>0) {
  ------------------
  |  Branch (7156:7): [True: 3.79k, False: 0]
  ------------------
 7157|  3.79k|    Unit *up;                                // work
  ------------------
  |  |   94|  3.79k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  3.79k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 7158|  3.79k|    uInt count=dn->digits;                   // digits to be checked
  ------------------
  |  |   93|  3.79k|  #define uInt   uint32_t
  ------------------
 7159|  4.54M|    for (up=dn->lsu; ; up++) {
 7160|  4.54M|      if (count<=DECDPUN) {
  ------------------
  |  |   43|  4.54M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (7160:11): [True: 2.50k, False: 4.53M]
  ------------------
 7161|       |        // this is the last Unit (the msu)
 7162|  2.50k|        if (*up!=powers[count]-1) break;     // not still 9s
  ------------------
  |  |  177|  2.50k|#define powers      DECPOWERS      // old internal name
  ------------------
  |  Branch (7162:13): [True: 1.47k, False: 1.03k]
  ------------------
 7163|       |        // here if it, too, is all nines
 7164|  1.03k|        *up=(Unit)powers[count-1];           // here 999 -> 100 etc.
  ------------------
  |  |  177|  1.03k|#define powers      DECPOWERS      // old internal name
  ------------------
 7165|  3.86M|        for (up=up-1; up>=dn->lsu; up--) *up=0; // others all to 0
  ------------------
  |  Branch (7165:23): [True: 3.86M, False: 1.03k]
  ------------------
 7166|  1.03k|        dn->exponent++;                      // and bump exponent
 7167|       |        // [which, very rarely, could cause Overflow...]
 7168|  1.03k|        if ((dn->exponent+dn->digits)>set->emax+1) {
  ------------------
  |  Branch (7168:13): [True: 0, False: 1.03k]
  ------------------
 7169|      0|          decSetOverflow(dn, set, status);
 7170|      0|          }
 7171|  1.03k|        return;                              // done
 7172|  2.50k|        }
 7173|       |      // a full unit to check, with more to come
 7174|  4.53M|      if (*up!=DECDPUNMAX) break;            // not still 9s
  ------------------
  |  |  209|  4.53M|    #define DECDPUNMAX 999
  ------------------
  |  Branch (7174:11): [True: 1.29k, False: 4.53M]
  ------------------
 7175|  4.53M|      count-=DECDPUN;
  ------------------
  |  |   43|  4.53M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 7176|  4.53M|      } // up
 7177|  3.79k|    } // 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.76k|  decUnitAddSub(dn->lsu, D2U(dn->digits), uarrone, 1, 0, dn->lsu, bump);
  ------------------
  |  |  264|  2.76k|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|  2.76k|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    248|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    248|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 2.51k, False: 248]
  |  |  ------------------
  ------------------
 7220|  2.76k|  } // decApplyRound
decNumber.c:decSetOverflow:
 7348|  22.3k|static void decSetOverflow(decNumber *dn, decContext *set, uInt *status) {
 7349|  22.3k|  Flag needmax=0;                  // result is maximum finite value
  ------------------
  |  |   87|  22.3k|  #define Flag   uint8_t
  ------------------
 7350|  22.3k|  uByte sign=dn->bits&DECNEG;      // clean and save sign bit
  ------------------
  |  |   89|  22.3k|  #define uByte  uint8_t
  ------------------
                uByte sign=dn->bits&DECNEG;      // clean and save sign bit
  ------------------
  |  |   31|  22.3k|  #define DECNEG    0x80      /* Sign; 1=negative, 0=positive or zero */
  ------------------
 7351|       |
 7352|  22.3k|  if (ISZERO(dn)) {                // zero does not overflow magnitude
  ------------------
  |  |  255|  22.3k|  #define ISZERO(dn) decNumberIsZero(dn)     /* now just a local name */
  |  |  ------------------
  |  |  |  |  177|  22.3k|  #define decNumberIsZero(dn)      (*(dn)->lsu==0 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (177:37): [True: 783, False: 21.6k]
  |  |  |  |  ------------------
  |  |  |  |  178|  22.3k|                                    && (dn)->digits==1 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:40): [True: 572, False: 211]
  |  |  |  |  ------------------
  |  |  |  |  179|  22.3k|                                    && (((dn)->bits&DECSPECIAL)==0))
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|    572|  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|    572|  #define DECINF    0x40      /* 1=Infinity                           */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   33|    572|  #define DECNAN    0x20      /* 1=NaN                                */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   34|    572|  #define DECSNAN   0x10      /* 1=sNaN                               */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (179:40): [True: 572, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 7353|    572|    Int emax=set->emax;                      // limit value
  ------------------
  |  |   92|    572|  #define Int    int32_t
  ------------------
 7354|    572|    if (set->clamp) emax-=set->digits-1;     // lower if clamping
  ------------------
  |  Branch (7354:9): [True: 0, False: 572]
  ------------------
 7355|    572|    if (dn->exponent>emax) {                 // clamp required
  ------------------
  |  Branch (7355:9): [True: 572, False: 0]
  ------------------
 7356|    572|      dn->exponent=emax;
 7357|    572|      *status|=DEC_Clamped;
  ------------------
  |  |  140|    572|    #define DEC_Clamped              0x00000400
  ------------------
 7358|    572|      }
 7359|    572|    return;
 7360|    572|    }
 7361|       |
 7362|  21.8k|  decNumberZero(dn);
 7363|  21.8k|  switch (set->round) {
 7364|      0|    case DEC_ROUND_DOWN: {
  ------------------
  |  Branch (7364:5): [True: 0, False: 21.8k]
  ------------------
 7365|      0|      needmax=1;                   // never Infinity
 7366|      0|      break;} // r-d
 7367|      0|    case DEC_ROUND_05UP: {
  ------------------
  |  Branch (7367:5): [True: 0, False: 21.8k]
  ------------------
 7368|      0|      needmax=1;                   // never Infinity
 7369|      0|      break;} // r-05
 7370|      0|    case DEC_ROUND_CEILING: {
  ------------------
  |  Branch (7370:5): [True: 0, False: 21.8k]
  ------------------
 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: 21.8k]
  ------------------
 7374|      0|      if (!sign) needmax=1;        // Infinity if negative
  ------------------
  |  Branch (7374:11): [True: 0, False: 0]
  ------------------
 7375|      0|      break;} // r-f
 7376|  21.8k|    default: break;                // Infinity in all other cases
  ------------------
  |  Branch (7376:5): [True: 21.8k, False: 0]
  ------------------
 7377|  21.8k|    }
 7378|  21.8k|  if (needmax) {
  ------------------
  |  Branch (7378:7): [True: 0, False: 21.8k]
  ------------------
 7379|      0|    decSetMaxValue(dn, set);
 7380|      0|    dn->bits=sign;                 // set sign
 7381|      0|    }
 7382|  21.8k|   else dn->bits=sign|DECINF;      // Value is +/-Infinity
  ------------------
  |  |   32|  21.8k|  #define DECINF    0x40      /* 1=Infinity                           */
  ------------------
 7383|  21.8k|  *status|=DEC_Overflow | DEC_Inexact | DEC_Rounded;
  ------------------
  |  |  139|  21.8k|    #define DEC_Overflow             0x00000200
  ------------------
                *status|=DEC_Overflow | DEC_Inexact | DEC_Rounded;
  ------------------
  |  |  133|  21.8k|    #define DEC_Inexact              0x00000020
  ------------------
                *status|=DEC_Overflow | DEC_Inexact | DEC_Rounded;
  ------------------
  |  |  141|  21.8k|    #define DEC_Rounded              0x00000800
  ------------------
 7384|  21.8k|  } // decSetOverflow
decNumber.c:decShiftToMost:
 6685|  1.03k|static Int decShiftToMost(Unit *uar, Int digits, Int shift) {
 6686|  1.03k|  Unit  *target, *source, *first;  // work
  ------------------
  |  |   94|  1.03k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  1.03k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6687|  1.03k|  Int   cut;                       // odd 0's to add
  ------------------
  |  |   92|  1.03k|  #define Int    int32_t
  ------------------
 6688|  1.03k|  uInt  next;                      // work
  ------------------
  |  |   93|  1.03k|  #define uInt   uint32_t
  ------------------
 6689|       |
 6690|  1.03k|  if (shift==0) return digits;     // [fastpath] nothing to do
  ------------------
  |  Branch (6690:7): [True: 0, False: 1.03k]
  ------------------
 6691|  1.03k|  if ((digits+shift)<=DECDPUN) {   // [fastpath] single-unit case
  ------------------
  |  |   43|  1.03k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6691:7): [True: 212, False: 822]
  ------------------
 6692|    212|    *uar=(Unit)(*uar*powers[shift]);
  ------------------
  |  |  177|    212|#define powers      DECPOWERS      // old internal name
  ------------------
 6693|    212|    return digits+shift;
 6694|    212|    }
 6695|       |
 6696|    822|  next=0;                          // all paths
 6697|    822|  source=uar+D2U(digits)-1;        // where msu comes from
  ------------------
  |  |  264|    822|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|    822|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    344|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    344|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 478, False: 344]
  |  |  ------------------
  ------------------
 6698|    822|  target=source+D2U(shift);        // where upper part of first cut goes
  ------------------
  |  |  264|    822|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|    822|  #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: 822, False: 0]
  |  |  ------------------
  ------------------
 6699|    822|  cut=DECDPUN-MSUDIGITS(shift);    // where to slice
  ------------------
  |  |   43|    822|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
                cut=DECDPUN-MSUDIGITS(shift);    // where to slice
  ------------------
  |  |  271|    822|  #define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN)
  |  |  ------------------
  |  |  |  |  264|    822|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  |  |  ------------------
  |  |  |  |  |  |  249|    822|  #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: 822, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |                 #define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    822|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  ------------------
 6700|    822|  if (cut==0) {                    // unit-boundary case
  ------------------
  |  Branch (6700:7): [True: 0, False: 822]
  ------------------
 6701|      0|    for (; source>=uar; source--, target--) *target=*source;
  ------------------
  |  Branch (6701:12): [True: 0, False: 0]
  ------------------
 6702|      0|    }
 6703|    822|   else {
 6704|    822|    first=uar+D2U(digits+shift)-1; // where msu of source will end up
  ------------------
  |  |  264|    822|    #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |  249|    822|  #define DECMAXD2U 49
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    511|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |                   #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN)
  |  |  ------------------
  |  |  |  |   43|    511|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  |  |  ------------------
  |  |  |  Branch (264:21): [True: 311, False: 511]
  |  |  ------------------
  ------------------
 6705|  3.86M|    for (; source>=uar; source--, target--) {
  ------------------
  |  Branch (6705:12): [True: 3.86M, False: 822]
  ------------------
 6706|       |      // split the source Unit and accumulate remainder for next
 6707|  3.86M|      #if DECDPUN<=4
 6708|  3.86M|        uInt quot=QUOT10(*source, cut);
  ------------------
  |  |   93|  3.86M|  #define uInt   uint32_t
  ------------------
                      uInt quot=QUOT10(*source, cut);
  ------------------
  |  |  210|  3.86M|  #define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17)
  ------------------
 6709|  3.86M|        uInt rem=*source-quot*powers[cut];
  ------------------
  |  |   93|  3.86M|  #define uInt   uint32_t
  ------------------
                      uInt rem=*source-quot*powers[cut];
  ------------------
  |  |  177|  3.86M|#define powers      DECPOWERS      // old internal name
  ------------------
 6710|  3.86M|        next+=quot;
 6711|       |      #else
 6712|       |        uInt rem=*source%powers[cut];
 6713|       |        next+=*source/powers[cut];
 6714|       |      #endif
 6715|  3.86M|      if (target<=first) *target=(Unit)next;   // write to target iff valid
  ------------------
  |  Branch (6715:11): [True: 3.86M, False: 698]
  ------------------
 6716|  3.86M|      next=rem*powers[DECDPUN-cut];            // save remainder for next Unit
  ------------------
  |  |  177|  3.86M|#define powers      DECPOWERS      // old internal name
  ------------------
                    next=rem*powers[DECDPUN-cut];            // save remainder for next Unit
  ------------------
  |  |   43|  3.86M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 6717|  3.86M|      }
 6718|    822|    } // shift-move
 6719|       |
 6720|       |  // propagate any partial unit to one below and clear the rest
 6721|  1.64k|  for (; target>=uar; target--) {
  ------------------
  |  Branch (6721:10): [True: 822, False: 822]
  ------------------
 6722|    822|    *target=(Unit)next;
 6723|    822|    next=0;
 6724|    822|    }
 6725|    822|  return digits+shift;
 6726|  1.03k|  } // decShiftToMost
decNumber.c:decSetCoeff:
 6890|  7.41k|                        Int len, Int *residue, uInt *status) {
 6891|  7.41k|  Int   discard;              // number of digits to discard
  ------------------
  |  |   92|  7.41k|  #define Int    int32_t
  ------------------
 6892|  7.41k|  uInt  cut;                  // cut point in Unit
  ------------------
  |  |   93|  7.41k|  #define uInt   uint32_t
  ------------------
 6893|  7.41k|  const Unit *up;             // work
 6894|  7.41k|  Unit  *target;              // ..
  ------------------
  |  |   94|  7.41k|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|  7.41k|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
 6895|  7.41k|  Int   count;                // ..
  ------------------
  |  |   92|  7.41k|  #define Int    int32_t
  ------------------
 6896|  7.41k|  #if DECDPUN<=4
 6897|  7.41k|  uInt  temp;                 // ..
  ------------------
  |  |   93|  7.41k|  #define uInt   uint32_t
  ------------------
 6898|  7.41k|  #endif
 6899|       |
 6900|  7.41k|  discard=len-set->digits;    // digits to discard
 6901|  7.41k|  if (discard<=0) {           // no digits are being discarded
  ------------------
  |  Branch (6901:7): [True: 0, False: 7.41k]
  ------------------
 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|  7.41k|  dn->exponent+=discard;      // maintain numerical value
 6917|  7.41k|  *status|=DEC_Rounded;       // accumulate Rounded status
  ------------------
  |  |  141|  7.41k|    #define DEC_Rounded              0x00000800
  ------------------
 6918|  7.41k|  if (*residue>1) *residue=1; // previous residue now to right, so reduce
  ------------------
  |  Branch (6918:7): [True: 0, False: 7.41k]
  ------------------
 6919|       |
 6920|  7.41k|  if (discard>len) {          // everything, +1, is being discarded
  ------------------
  |  Branch (6920:7): [True: 1.82k, False: 5.58k]
  ------------------
 6921|       |    // guard digit is 0
 6922|       |    // residue is all the number [NB could be all 0s]
 6923|  1.82k|    if (*residue<=0) {        // not already positive
  ------------------
  |  Branch (6923:9): [True: 1.82k, False: 0]
  ------------------
 6924|  1.82k|      count=len;              // avoids D2U
 6925|   183k|      for (up=lsu; count>0; up++, count-=DECDPUN) if (*up!=0) { // found non-0
  ------------------
  |  |   43|   182k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6925:20): [True: 183k, False: 0]
  |  Branch (6925:55): [True: 1.82k, False: 182k]
  ------------------
 6926|  1.82k|        *residue=1;
 6927|  1.82k|        break;                // no need to check any others
 6928|  1.82k|        }
 6929|  1.82k|      }
 6930|  1.82k|    if (*residue!=0) *status|=DEC_Inexact; // record inexactitude
  ------------------
  |  |  133|  1.82k|    #define DEC_Inexact              0x00000020
  ------------------
  |  Branch (6930:9): [True: 1.82k, False: 0]
  ------------------
 6931|  1.82k|    *dn->lsu=0;               // coefficient will now be 0
 6932|  1.82k|    dn->digits=1;             // ..
 6933|  1.82k|    return;
 6934|  1.82k|    } // 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|  5.58k|  count=0;
 6943|   295k|  for (up=lsu;; up++) {
 6944|   295k|    count+=DECDPUN;
  ------------------
  |  |   43|   295k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 6945|   295k|    if (count>=discard) break; // full ones all checked
  ------------------
  |  Branch (6945:9): [True: 5.58k, False: 289k]
  ------------------
 6946|   289k|    if (*up!=0) *residue=1;
  ------------------
  |  Branch (6946:9): [True: 105k, False: 184k]
  ------------------
 6947|   289k|    } // up
 6948|       |
 6949|       |  // here up -> Unit with first discarded digit
 6950|  5.58k|  cut=discard-(count-DECDPUN)-1;
  ------------------
  |  |   43|  5.58k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 6951|  5.58k|  if (cut==DECDPUN-1) {       // unit-boundary case (fast)
  ------------------
  |  |   43|  5.58k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6951:7): [True: 902, False: 4.68k]
  ------------------
 6952|    902|    Unit half=(Unit)powers[DECDPUN]>>1;
  ------------------
  |  |   94|    902|  #define Unit   decNumberUnit
  |  |  ------------------
  |  |  |  |   59|    902|    #define decNumberUnit uint16_t
  |  |  ------------------
  ------------------
                  Unit half=(Unit)powers[DECDPUN]>>1;
  ------------------
  |  |  177|    902|#define powers      DECPOWERS      // old internal name
  ------------------
                  Unit half=(Unit)powers[DECDPUN]>>1;
  ------------------
  |  |   43|    902|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 6953|       |    // set residue directly
 6954|    902|    if (*up>=half) {
  ------------------
  |  Branch (6954:9): [True: 429, False: 473]
  ------------------
 6955|    429|      if (*up>half) *residue=7;
  ------------------
  |  Branch (6955:11): [True: 230, False: 199]
  ------------------
 6956|    199|      else *residue+=5;       // add sticky bit
 6957|    429|      }
 6958|    473|     else { // <half
 6959|    473|      if (*up!=0) *residue=3; // [else is 0, leave as sticky bit]
  ------------------
  |  Branch (6959:11): [True: 218, False: 255]
  ------------------
 6960|    473|      }
 6961|    902|    if (set->digits<=0) {     // special for Quantize/Subnormal :-(
  ------------------
  |  Branch (6961:9): [True: 610, False: 292]
  ------------------
 6962|    610|      *dn->lsu=0;             // .. result is 0
 6963|    610|      dn->digits=1;           // ..
 6964|    610|      }
 6965|    292|     else {                   // shift to least
 6966|    292|      count=set->digits;      // now digits to end up with
 6967|    292|      dn->digits=count;       // set the new length
 6968|    292|      up++;                   // move to next
 6969|       |      // on unit boundary, so shift-down copy loop is simple
 6970|   756k|      for (target=dn->lsu; count>0; target++, up++, count-=DECDPUN)
  ------------------
  |  |   43|   756k|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
  |  Branch (6970:28): [True: 756k, False: 292]
  ------------------
 6971|   756k|        *target=*up;
 6972|    292|      }
 6973|    902|    } // unit-boundary case
 6974|       |
 6975|  4.68k|   else { // discard digit is in low digit(s), and not top digit
 6976|  4.68k|    uInt  discard1;                // first discarded digit
  ------------------
  |  |   93|  4.68k|  #define uInt   uint32_t
  ------------------
 6977|  4.68k|    uInt  quot, rem;               // for divisions
  ------------------
  |  |   93|  4.68k|  #define uInt   uint32_t
  ------------------
 6978|  4.68k|    if (cut==0) quot=*up;          // is at bottom of unit
  ------------------
  |  Branch (6978:9): [True: 4.02k, False: 666]
  ------------------
 6979|    666|     else /* cut>0 */ {            // it's not at bottom of unit
 6980|    666|      #if DECDPUN<=4
 6981|    666|        quot=QUOT10(*up, cut);
  ------------------
  |  |  210|    666|  #define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17)
  ------------------
 6982|    666|        rem=*up-quot*powers[cut];
  ------------------
  |  |  177|    666|#define powers      DECPOWERS      // old internal name
  ------------------
 6983|       |      #else
 6984|       |        rem=*up%powers[cut];
 6985|       |        quot=*up/powers[cut];
 6986|       |      #endif
 6987|    666|      if (rem!=0) *residue=1;
  ------------------
  |  Branch (6987:11): [True: 254, False: 412]
  ------------------
 6988|    666|      }
 6989|       |    // discard digit is now at bottom of quot
 6990|  4.68k|    #if DECDPUN<=4
 6991|  4.68k|      temp=(quot*6554)>>16;        // fast /10
 6992|       |      // Vowels algorithm here not a win (9 instructions)
 6993|  4.68k|      discard1=quot-X10(temp);
  ------------------
  |  |  163|  4.68k|  #define X10(i)  (((i)<<1)+((i)<<3))
  ------------------
 6994|  4.68k|      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|  4.68k|    *residue+=resmap[discard1];
 7002|  4.68k|    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|  4.68k|    if (set->digits<=0) {          // special for Quantize/Subnormal :-(
  ------------------
  |  Branch (7006:9): [True: 859, False: 3.82k]
  ------------------
 7007|    859|      *dn->lsu=0;                  // .. result is 0
 7008|    859|      dn->digits=1;                // ..
 7009|    859|      }
 7010|  3.82k|     else {                        // shift to least needed
 7011|  3.82k|      count=set->digits;           // now digits to end up with
 7012|  3.82k|      dn->digits=count;            // set the new length
 7013|       |      // shift-copy the coefficient array to the result number
 7014|  7.27M|      for (target=dn->lsu; ; target++) {
 7015|  7.27M|        *target=(Unit)quot;
 7016|  7.27M|        count-=(DECDPUN-cut);
  ------------------
  |  |   43|  7.27M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 7017|  7.27M|        if (count<=0) break;
  ------------------
  |  Branch (7017:13): [True: 2.57k, False: 7.27M]
  ------------------
 7018|  7.27M|        up++;
 7019|  7.27M|        quot=*up;
 7020|  7.27M|        #if DECDPUN<=4
 7021|  7.27M|          quot=QUOT10(quot, cut);
  ------------------
  |  |  210|  7.27M|  #define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17)
  ------------------
 7022|  7.27M|          rem=*up-quot*powers[cut];
  ------------------
  |  |  177|  7.27M|#define powers      DECPOWERS      // old internal name
  ------------------
 7023|       |        #else
 7024|       |          rem=quot%powers[cut];
 7025|       |          quot=quot/powers[cut];
 7026|       |        #endif
 7027|  7.27M|        *target=(Unit)(*target+rem*powers[DECDPUN-cut]);
  ------------------
  |  |  177|  7.27M|#define powers      DECPOWERS      // old internal name
  ------------------
                      *target=(Unit)(*target+rem*powers[DECDPUN-cut]);
  ------------------
  |  |   43|  7.27M|  #define DECDPUN 3           /* DECimal Digits Per UNit [must be >0  */
  ------------------
 7028|  7.27M|        count-=cut;
 7029|  7.27M|        if (count<=0) break;
  ------------------
  |  Branch (7029:13): [True: 1.25k, False: 7.27M]
  ------------------
 7030|  7.27M|        } // shift-copy loop
 7031|  3.82k|      } // shift to least
 7032|  4.68k|    } // not unit boundary
 7033|       |
 7034|  5.58k|  if (*residue!=0) *status|=DEC_Inexact; // record inexactitude
  ------------------
  |  |  133|  4.12k|    #define DEC_Inexact              0x00000020
  ------------------
  |  Branch (7034:7): [True: 4.12k, False: 1.46k]
  ------------------
 7035|  5.58k|  return;
 7036|  7.41k|  } // decSetCoeff
decNumber.c:decFinalize:
 7275|  30.7k|                        uInt *status) {
 7276|  30.7k|  Int shift;                            // shift needed if clamping
  ------------------
  |  |   92|  30.7k|  #define Int    int32_t
  ------------------
 7277|  30.7k|  Int tinyexp=set->emin-dn->digits+1;   // precalculate subnormal boundary
  ------------------
  |  |   92|  30.7k|  #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|  30.7k|  if (dn->exponent<=tinyexp) {          // prefilter
  ------------------
  |  Branch (7285:7): [True: 8.12k, False: 22.6k]
  ------------------
 7286|  8.12k|    Int comp;
  ------------------
  |  |   92|  8.12k|  #define Int    int32_t
  ------------------
 7287|  8.12k|    decNumber nmin;
 7288|       |    // A very nasty case here is dn == Nmin and residue<0
 7289|  8.12k|    if (dn->exponent<tinyexp) {
  ------------------
  |  Branch (7289:9): [True: 8.12k, False: 0]
  ------------------
 7290|       |      // Go handle subnormals; this will apply round if needed.
 7291|  8.12k|      decSetSubnormal(dn, set, residue, status);
 7292|  8.12k|      return;
 7293|  8.12k|      }
 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|  22.6k|  if (*residue!=0) decApplyRound(dn, set, *residue, status);
  ------------------
  |  Branch (7311:7): [True: 0, False: 22.6k]
  ------------------
 7312|       |
 7313|       |  // Check for overflow [redundant in the 'rare' case] or clamp
 7314|  22.6k|  if (dn->exponent<=set->emax-set->digits+1) return;   // neither needed
  ------------------
  |  Branch (7314:7): [True: 0, False: 22.6k]
  ------------------
 7315|       |
 7316|       |
 7317|       |  // here when might have an overflow or clamp to do
 7318|  22.6k|  if (dn->exponent>set->emax-dn->digits+1) {           // too big
  ------------------
  |  Branch (7318:7): [True: 22.3k, False: 262]
  ------------------
 7319|  22.3k|    decSetOverflow(dn, set, status);
 7320|  22.3k|    return;
 7321|  22.3k|    }
 7322|       |  // here when the result is normal but in clamp range
 7323|    262|  if (!set->clamp) return;
  ------------------
  |  Branch (7323:7): [True: 262, 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|    262|  } // decFinalize
decNumber.c:decSetSubnormal:
 7429|  8.12k|                            uInt *status) {
 7430|  8.12k|  decContext workset;         // work
 7431|  8.12k|  Int        etiny, adjust;   // ..
  ------------------
  |  |   92|  8.12k|  #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|  8.12k|  etiny=set->emin-(set->digits-1);      // smallest allowed exponent
 7446|       |
 7447|  8.12k|  if ISZERO(dn) {                       // value is zero
  ------------------
  |  |  255|  8.12k|  #define ISZERO(dn) decNumberIsZero(dn)     /* now just a local name */
  |  |  ------------------
  |  |  |  |  177|  8.12k|  #define decNumberIsZero(dn)      (*(dn)->lsu==0 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (177:37): [True: 989, False: 7.14k]
  |  |  |  |  ------------------
  |  |  |  |  178|  8.12k|                                    && (dn)->digits==1 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:40): [True: 474, False: 515]
  |  |  |  |  ------------------
  |  |  |  |  179|  8.12k|                                    && (((dn)->bits&DECSPECIAL)==0))
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|    474|  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|    474|  #define DECINF    0x40      /* 1=Infinity                           */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   33|    474|  #define DECNAN    0x20      /* 1=NaN                                */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   34|    474|  #define DECSNAN   0x10      /* 1=sNaN                               */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (179:40): [True: 474, 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|    474|    if (dn->exponent<etiny) {           // clamp required
  ------------------
  |  Branch (7455:9): [True: 219, False: 255]
  ------------------
 7456|    219|      dn->exponent=etiny;
 7457|    219|      *status|=DEC_Clamped;
  ------------------
  |  |  140|    219|    #define DEC_Clamped              0x00000400
  ------------------
 7458|    219|      }
 7459|    474|    return;
 7460|    474|    }
 7461|       |
 7462|  7.65k|  *status|=DEC_Subnormal;               // have a non-zero subnormal
  ------------------
  |  |  142|  7.65k|    #define DEC_Subnormal            0x00001000
  ------------------
 7463|  7.65k|  adjust=etiny-dn->exponent;            // calculate digits to remove
 7464|  7.65k|  if (adjust<=0) {                      // not out of range; unrounded
  ------------------
  |  Branch (7464:7): [True: 240, False: 7.41k]
  ------------------
 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|    240|    if (*status&DEC_Inexact) *status|=DEC_Underflow;
  ------------------
  |  |  133|    240|    #define DEC_Inexact              0x00000020
  ------------------
                  if (*status&DEC_Inexact) *status|=DEC_Underflow;
  ------------------
  |  |  143|      0|    #define DEC_Underflow            0x00002000
  ------------------
  |  Branch (7468:9): [True: 0, False: 240]
  ------------------
 7469|    240|    return;
 7470|    240|    }
 7471|       |
 7472|       |  // adjust>0, so need to rescale the result so exponent becomes Etiny
 7473|       |  // [this code is similar to that in rescale]
 7474|  7.41k|  workset=*set;                         // clone rounding, etc.
 7475|  7.41k|  workset.digits=dn->digits-adjust;     // set requested length
 7476|  7.41k|  workset.emin-=adjust;                 // and adjust emin to match
 7477|       |  // [note that the latter can be <1, here, similar to Rescale case]
 7478|  7.41k|  decSetCoeff(dn, &workset, dn->lsu, dn->digits, residue, status);
 7479|  7.41k|  decApplyRound(dn, &workset, *residue, status);
 7480|       |
 7481|       |  // Use 754 default rule: Underflow is set iff Inexact
 7482|       |  // [independent of whether trapped]
 7483|  7.41k|  if (*status&DEC_Inexact) *status|=DEC_Underflow;
  ------------------
  |  |  133|  7.41k|    #define DEC_Inexact              0x00000020
  ------------------
                if (*status&DEC_Inexact) *status|=DEC_Underflow;
  ------------------
  |  |  143|  5.95k|    #define DEC_Underflow            0x00002000
  ------------------
  |  Branch (7483:7): [True: 5.95k, False: 1.46k]
  ------------------
 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|  7.41k|  if (dn->exponent>etiny) {
  ------------------
  |  Branch (7487:7): [True: 1.03k, False: 6.38k]
  ------------------
 7488|  1.03k|    dn->digits=decShiftToMost(dn->lsu, dn->digits, 1);
 7489|  1.03k|    dn->exponent--;                     // (re)adjust the exponent.
 7490|  1.03k|    }
 7491|       |
 7492|       |  // if rounded to zero, it is by definition clamped...
 7493|  7.41k|  if (ISZERO(dn)) *status|=DEC_Clamped;
  ------------------
  |  |  255|  7.41k|  #define ISZERO(dn) decNumberIsZero(dn)     /* now just a local name */
  |  |  ------------------
  |  |  |  |  177|  7.41k|  #define decNumberIsZero(dn)      (*(dn)->lsu==0 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (177:37): [True: 3.22k, False: 4.18k]
  |  |  |  |  ------------------
  |  |  |  |  178|  7.41k|                                    && (dn)->digits==1 \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:40): [True: 2.07k, False: 1.15k]
  |  |  |  |  ------------------
  |  |  |  |  179|  7.41k|                                    && (((dn)->bits&DECSPECIAL)==0))
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|  2.07k|  #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   32|  2.07k|  #define DECINF    0x40      /* 1=Infinity                           */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   33|  2.07k|  #define DECNAN    0x20      /* 1=NaN                                */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |                 #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value     */
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   34|  2.07k|  #define DECSNAN   0x10      /* 1=sNaN                               */
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (179:40): [True: 2.07k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                if (ISZERO(dn)) *status|=DEC_Clamped;
  ------------------
  |  |  140|  2.07k|    #define DEC_Clamped              0x00000400
  ------------------
 7494|  7.41k|  } // decSetSubnormal
decNumber.c:decBiStr:
 7667|  5.70k|static Flag decBiStr(const char *targ, const char *str1, const char *str2) {
 7668|  9.84k|  for (;;targ++, str1++, str2++) {
 7669|  9.84k|    if (*targ!=*str1 && *targ!=*str2) return 0;
  ------------------
  |  Branch (7669:9): [True: 7.44k, False: 2.40k]
  |  Branch (7669:25): [True: 5.10k, False: 2.34k]
  ------------------
 7670|       |    // *targ has a match in one (or both, if terminator)
 7671|  4.74k|    if (*targ=='\0') break;
  ------------------
  |  Branch (7671:9): [True: 599, False: 4.14k]
  ------------------
 7672|  4.74k|    } // forever
 7673|    599|  return 1;
 7674|  5.70k|  } // decBiStr
decNumber.c:decStatus:
 7741|  30.8k|static void decStatus(decNumber *dn, uInt status, decContext *set) {
 7742|  30.8k|  if (status & DEC_NaNs) {              // error status -> NaN
  ------------------
  |  |  187|  30.8k|  #define DEC_NaNs    DEC_IEEE_754_Invalid_operation
  |  |  ------------------
  |  |  |  |  173|  30.8k|  #define DEC_IEEE_754_Invalid_operation (DEC_Conversion_syntax |     \
  |  |  |  |  ------------------
  |  |  |  |  |  |  128|  30.8k|    #define DEC_Conversion_syntax    0x00000001
  |  |  |  |  ------------------
  |  |  |  |  174|  30.8k|                                          DEC_Division_impossible |   \
  |  |  |  |  ------------------
  |  |  |  |  |  |  130|  30.8k|    #define DEC_Division_impossible  0x00000004
  |  |  |  |  ------------------
  |  |  |  |  175|  30.8k|                                          DEC_Division_undefined |    \
  |  |  |  |  ------------------
  |  |  |  |  |  |  131|  30.8k|    #define DEC_Division_undefined   0x00000008
  |  |  |  |  ------------------
  |  |  |  |  176|  30.8k|                                          DEC_Insufficient_storage |  \
  |  |  |  |  ------------------
  |  |  |  |  |  |  132|  30.8k|    #define DEC_Insufficient_storage 0x00000010 /* [when malloc fails]  */
  |  |  |  |  ------------------
  |  |  |  |  177|  30.8k|                                          DEC_Invalid_context |       \
  |  |  |  |  ------------------
  |  |  |  |  |  |  134|  30.8k|    #define DEC_Invalid_context      0x00000040
  |  |  |  |  ------------------
  |  |  |  |  178|  30.8k|                                          DEC_Invalid_operation)
  |  |  |  |  ------------------
  |  |  |  |  |  |  135|  30.8k|    #define DEC_Invalid_operation    0x00000080
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (7742:7): [True: 604, False: 30.2k]
  ------------------
 7743|       |    // if cause was an sNaN, clear and propagate [NaN is already set up]
 7744|    604|    if (status & DEC_sNaN) status&=~DEC_sNaN;
  ------------------
  |  |  193|    604|#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: 604]
  ------------------
 7745|    604|     else {
 7746|    604|      decNumberZero(dn);                // other error: clean throughout
 7747|    604|      dn->bits=DECNAN;                  // and make a quiet NaN
  ------------------
  |  |   33|    604|  #define DECNAN    0x20      /* 1=NaN                                */
  ------------------
 7748|    604|      }
 7749|    604|    }
 7750|  30.8k|  decContextSetStatus(set, status);     // [may not return]
 7751|  30.8k|  return;
 7752|  30.8k|  } // decStatus

