_Z7to_charPKh:
   11|  13.5k|char *to_char(const uint8_t *x) {
   12|  13.5k|  return reinterpret_cast<char *>(const_cast<unsigned char *>(x));
   13|  13.5k|}
_Z11check_equalP9bignum_stP6mp_intm:
   22|  18.0k|void check_equal(BIGNUM *b, mp_int *m, size_t max_size) {
   23|  18.0k|  char *bnBc = BN_bn2hex(b);
   24|  18.0k|  char mpiMc[max_size];
   25|  18.0k|  mp_tohex(m, mpiMc);
  ------------------
  |  |  294|  18.0k|#define mp_tohex(M, S) mp_toradix((M), (S), 16)
  ------------------
   26|  18.0k|  std::string bnA(bnBc);
   27|  18.0k|  std::string mpiA(mpiMc);
   28|  18.0k|  OPENSSL_free(bnBc);
   29|       |  // We have to strip leading zeros from bignums, ignoring the sign.
   30|  18.0k|  if (bnA.at(0) != '-') {
  ------------------
  |  Branch (30:7): [True: 18.0k, False: 0]
  ------------------
   31|  18.0k|    bnA.erase(0, std::min(bnA.find_first_not_of('0'), bnA.size() - 1));
   32|  18.0k|  } else if (bnA.at(1) == '0') {
  ------------------
  |  Branch (32:14): [True: 0, False: 0]
  ------------------
   33|      0|    bnA.erase(1, std::min(bnA.find_first_not_of('0', 1) - 1, bnA.size() - 1));
   34|      0|  }
   35|       |
   36|  18.0k|  if (mpiA != bnA) {
  ------------------
  |  Branch (36:7): [True: 0, False: 18.0k]
  ------------------
   37|      0|    std::cout << "openssl: " << std::hex << bnA << std::endl;
   38|      0|    std::cout << "nss:     " << std::hex << mpiA << std::endl;
   39|      0|  }
   40|       |
   41|  18.0k|  assert(mpiA == bnA);
   42|  18.0k|}
_Z11parse_inputPKhmP9bignum_stS2_P6mp_intS4_:
   46|  4.51k|                 mp_int *a, mp_int *b) {
   47|       |  // Note that b might overlap a.
   48|  4.51k|  size_t len = (size_t)size / 2;
   49|  4.51k|  assert(mp_read_raw(a, to_char(data), len) == MP_OKAY);
   50|  4.51k|  assert(mp_read_raw(b, to_char(data) + len, len) == MP_OKAY);
   51|       |  // Force a positive sign.
   52|       |  // TODO: add tests for negatives.
   53|  4.51k|  MP_SIGN(a) = MP_ZPOS;
  ------------------
  |  |  144|  4.51k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
                MP_SIGN(a) = MP_ZPOS;
  ------------------
  |  |   37|  4.51k|#define MP_ZPOS 0
  ------------------
   54|  4.51k|  MP_SIGN(b) = MP_ZPOS;
  ------------------
  |  |  144|  4.51k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
                MP_SIGN(b) = MP_ZPOS;
  ------------------
  |  |   37|  4.51k|#define MP_ZPOS 0
  ------------------
   55|       |
   56|       |  // Skip the first byte as it's interpreted as sign by NSS.
   57|  4.51k|  assert(BN_bin2bn(data + 1, len - 1, A) != nullptr);
   58|  4.51k|  assert(BN_bin2bn(data + len + 1, len - 1, B) != nullptr);
   59|       |
   60|  4.51k|  check_equal(A, a, 2 * size + 1);
   61|  4.51k|  check_equal(B, b, 2 * size + 1);
   62|  4.51k|}
_Z11get_modulusPKhmP10bignum_ctx:
   80|  4.51k|                                         BN_CTX *ctx) {
   81|  4.51k|  BIGNUM *r1 = BN_CTX_get(ctx);
   82|  4.51k|  mp_int r2;
   83|  4.51k|  assert(mp_init(&r2) == MP_OKAY);
   84|       |
   85|  4.51k|  size_t len = static_cast<size_t>(size / 4);
   86|  4.51k|  if (len != 0) {
  ------------------
  |  Branch (86:7): [True: 4.48k, False: 25]
  ------------------
   87|  4.48k|    assert(mp_read_raw(&r2, to_char(data + len), len) == MP_OKAY);
   88|  4.48k|    MP_SIGN(&r2) = MP_ZPOS;
  ------------------
  |  |  144|  4.48k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
                  MP_SIGN(&r2) = MP_ZPOS;
  ------------------
  |  |   37|  4.48k|#define MP_ZPOS 0
  ------------------
   89|       |
   90|  4.48k|    assert(BN_bin2bn(data + len + 1, len - 1, r1) != nullptr);
   91|  4.48k|    check_equal(r1, &r2, 2 * len + 1);
   92|  4.48k|  }
   93|       |
   94|       |  // If we happen to get 0 for the modulus, take a random number.
   95|  4.51k|  if (mp_cmp_z(&r2) == 0 || len == 0) {
  ------------------
  |  Branch (95:7): [True: 488, False: 4.02k]
  |  Branch (95:29): [True: 0, False: 4.02k]
  ------------------
   96|    488|    mp_zero(&r2);
   97|    488|    BN_zero(r1);
   98|    488|    std::mt19937 rng(data[0]);
   99|    488|    std::uniform_int_distribution<mp_digit> dist(1, MP_DIGIT_MAX);
  ------------------
  |  |   74|    488|#define MP_DIGIT_MAX ULONG_MAX
  ------------------
  100|    488|    mp_digit x = dist(rng);
  101|    488|    mp_add_d(&r2, x, &r2);
  102|    488|    BN_add_word(r1, x);
  103|    488|  }
  104|       |
  105|  4.51k|  return std::make_tuple(r1, r2);
  106|  4.51k|}

LLVMFuzzerTestOneInput:
   12|  4.51k|extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   13|       |  // We require at least size 3 to get two integers from Data.
   14|  4.51k|  if (size < 3) {
  ------------------
  |  Branch (14:7): [True: 2, False: 4.51k]
  ------------------
   15|      2|    return 0;
   16|      2|  }
   17|  22.5k|  INIT_FOUR_NUMBERS
  ------------------
  |  |   31|  4.51k|  mp_int a, b, c, r;                     \
  |  |   32|  4.51k|  mp_int *m1 = nullptr;                  \
  |  |   33|  4.51k|  BN_CTX *ctx = BN_CTX_new();            \
  |  |   34|  4.51k|  BN_CTX_start(ctx);                     \
  |  |   35|  4.51k|  BIGNUM *A = BN_CTX_get(ctx);           \
  |  |   36|  4.51k|  BIGNUM *B = BN_CTX_get(ctx);           \
  |  |   37|  4.51k|  BIGNUM *C = BN_CTX_get(ctx);           \
  |  |   38|  4.51k|  BIGNUM *R = BN_CTX_get(ctx);           \
  |  |   39|  4.51k|  assert(mp_init(&a) == MP_OKAY);        \
  |  |   40|  4.51k|  assert(mp_init(&b) == MP_OKAY);        \
  |  |   41|  4.51k|  assert(mp_init(&c) == MP_OKAY);        \
  |  |   42|  4.51k|  assert(mp_init(&r) == MP_OKAY);        \
  |  |   43|  4.51k|  size_t max_size = 2 * size + 1;        \
  |  |   44|  4.51k|  parse_input(data, size, A, B, &a, &b); \
  |  |   45|  4.51k|  do {                                   \
  |  |   46|  4.51k|    (void)(R);                           \
  |  |   47|  4.51k|  } while (0);
  |  |  ------------------
  |  |  |  Branch (47:12): [Folded - Ignored]
  |  |  ------------------
  ------------------
   18|       |
   19|  22.5k|  auto modulus = get_modulus(data, size, ctx);
   20|       |  // Compare with OpenSSL sub mod
   21|  22.5k|  m1 = &std::get<1>(modulus);
   22|  22.5k|  assert(mp_submod(&a, &b, m1, &c) == MP_OKAY);
   23|  4.51k|  (void)BN_mod_sub(C, A, B, std::get<0>(modulus), ctx);
   24|  4.51k|  check_equal(C, &c, 2 * max_size);
   25|       |
   26|  4.51k|  CLEANUP_AND_RETURN
  ------------------
  |  |   68|  4.51k|  mp_clear(&a);            \
  |  |   69|  4.51k|  mp_clear(&b);            \
  |  |   70|  4.51k|  mp_clear(&c);            \
  |  |   71|  4.51k|  mp_clear(&r);            \
  |  |   72|  4.51k|  if (m1) {                \
  |  |  ------------------
  |  |  |  Branch (72:7): [True: 4.51k, False: 0]
  |  |  ------------------
  |  |   73|  4.51k|    mp_clear(m1);          \
  |  |   74|  4.51k|  }                        \
  |  |   75|  4.51k|  BN_CTX_end(ctx);         \
  |  |   76|  4.51k|  BN_CTX_free(ctx);        \
  |  |   77|  4.51k|  return 0;
  ------------------
   27|  22.5k|}

mp_init:
  121|  22.5k|{
  122|  22.5k|    return mp_init_size(mp, s_mp_defprec);
  123|       |
  124|  22.5k|} /* end mp_init() */
mp_init_size:
  140|  30.3k|{
  141|  30.3k|    ARGCHK(mp != NULL && prec > 0, MP_BADARG);
  ------------------
  |  |  350|  30.3k|#define ARGCHK(X, Y) assert(X)
  ------------------
  142|       |
  143|  30.3k|    prec = MP_ROUNDUP(prec, s_mp_defprec);
  ------------------
  |  |   89|  30.3k|#define MP_ROUNDUP(a, b) (MP_HOWMANY(a, b) * (b))
  |  |  ------------------
  |  |  |  |   88|  30.3k|#define MP_HOWMANY(a, b) (((a) + (b)-1) / (b))
  |  |  ------------------
  ------------------
  144|  30.3k|    if ((DIGITS(mp) = s_mp_alloc(prec, sizeof(mp_digit))) == NULL)
  ------------------
  |  |  330|  30.3k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|  30.3k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
  |  Branch (144:9): [True: 0, False: 30.3k]
  ------------------
  145|      0|        return MP_MEM;
  ------------------
  |  |   42|      0|#define MP_MEM -2    /* out of memory         */
  ------------------
  146|       |
  147|  30.3k|    SIGN(mp) = ZPOS;
  ------------------
  |  |  327|  30.3k|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|  30.3k|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                  SIGN(mp) = ZPOS;
  ------------------
  |  |  321|  30.3k|#define ZPOS MP_ZPOS
  |  |  ------------------
  |  |  |  |   37|  30.3k|#define MP_ZPOS 0
  |  |  ------------------
  ------------------
  148|  30.3k|    USED(mp) = 1;
  ------------------
  |  |  328|  30.3k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|  30.3k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  149|  30.3k|    ALLOC(mp) = prec;
  ------------------
  |  |  329|  30.3k|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|  30.3k|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
  150|       |
  151|  30.3k|    return MP_OKAY;
  ------------------
  |  |   39|  30.3k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  152|       |
  153|  30.3k|} /* end mp_init_size() */
mp_init_copy:
  169|   559k|{
  170|   559k|    ARGCHK(mp != NULL && from != NULL, MP_BADARG);
  ------------------
  |  |  350|   559k|#define ARGCHK(X, Y) assert(X)
  ------------------
  171|       |
  172|   559k|    if (mp == from)
  ------------------
  |  Branch (172:9): [True: 0, False: 559k]
  ------------------
  173|      0|        return MP_OKAY;
  ------------------
  |  |   39|      0|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  174|       |
  175|   559k|    if ((DIGITS(mp) = s_mp_alloc(ALLOC(from), sizeof(mp_digit))) == NULL)
  ------------------
  |  |  330|   559k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|   559k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
                  if ((DIGITS(mp) = s_mp_alloc(ALLOC(from), sizeof(mp_digit))) == NULL)
  ------------------
  |  |  329|   559k|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|   559k|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
  |  Branch (175:9): [True: 0, False: 559k]
  ------------------
  176|      0|        return MP_MEM;
  ------------------
  |  |   42|      0|#define MP_MEM -2    /* out of memory         */
  ------------------
  177|       |
  178|   559k|    s_mp_copy(DIGITS(from), DIGITS(mp), USED(from));
  ------------------
  |  |  330|   559k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|   559k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
                  s_mp_copy(DIGITS(from), DIGITS(mp), USED(from));
  ------------------
  |  |  330|   559k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|   559k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
                  s_mp_copy(DIGITS(from), DIGITS(mp), USED(from));
  ------------------
  |  |  328|   559k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|   559k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  179|   559k|    USED(mp) = USED(from);
  ------------------
  |  |  328|   559k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|   559k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
                  USED(mp) = USED(from);
  ------------------
  |  |  328|   559k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|   559k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  180|   559k|    ALLOC(mp) = ALLOC(from);
  ------------------
  |  |  329|   559k|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|   559k|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
                  ALLOC(mp) = ALLOC(from);
  ------------------
  |  |  329|   559k|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|   559k|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
  181|   559k|    SIGN(mp) = SIGN(from);
  ------------------
  |  |  327|   559k|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|   559k|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                  SIGN(mp) = SIGN(from);
  ------------------
  |  |  327|   559k|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|   559k|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
  182|       |
  183|   559k|    return MP_OKAY;
  ------------------
  |  |   39|   559k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  184|       |
  185|   559k|} /* end mp_init_copy() */
mp_copy:
  201|  1.62M|{
  202|  1.62M|    ARGCHK(from != NULL && to != NULL, MP_BADARG);
  ------------------
  |  |  350|  1.62M|#define ARGCHK(X, Y) assert(X)
  ------------------
  203|       |
  204|  1.62M|    if (from == to)
  ------------------
  |  Branch (204:9): [True: 1.60M, False: 13.2k]
  ------------------
  205|  1.60M|        return MP_OKAY;
  ------------------
  |  |   39|  1.60M|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  206|       |
  207|  13.2k|    { /* copy */
  208|  13.2k|        mp_digit *tmp;
  209|       |
  210|       |        /*
  211|       |          If the allocated buffer in 'to' already has enough space to hold
  212|       |          all the used digits of 'from', we'll re-use it to avoid hitting
  213|       |          the memory allocater more than necessary; otherwise, we'd have
  214|       |          to grow anyway, so we just allocate a hunk and make the copy as
  215|       |          usual
  216|       |         */
  217|  13.2k|        if (ALLOC(to) >= USED(from)) {
  ------------------
  |  |  329|  13.2k|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|  13.2k|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
                      if (ALLOC(to) >= USED(from)) {
  ------------------
  |  |  328|  13.2k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|  13.2k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  |  Branch (217:13): [True: 13.2k, False: 0]
  ------------------
  218|  13.2k|            s_mp_setz(DIGITS(to) + USED(from), ALLOC(to) - USED(from));
  ------------------
  |  |  330|  13.2k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|  13.2k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
                          s_mp_setz(DIGITS(to) + USED(from), ALLOC(to) - USED(from));
  ------------------
  |  |  328|  13.2k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|  13.2k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
                          s_mp_setz(DIGITS(to) + USED(from), ALLOC(to) - USED(from));
  ------------------
  |  |  329|  13.2k|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|  13.2k|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
                          s_mp_setz(DIGITS(to) + USED(from), ALLOC(to) - USED(from));
  ------------------
  |  |  328|  13.2k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|  13.2k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  219|  13.2k|            s_mp_copy(DIGITS(from), DIGITS(to), USED(from));
  ------------------
  |  |  330|  13.2k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|  13.2k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
                          s_mp_copy(DIGITS(from), DIGITS(to), USED(from));
  ------------------
  |  |  330|  13.2k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|  13.2k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
                          s_mp_copy(DIGITS(from), DIGITS(to), USED(from));
  ------------------
  |  |  328|  13.2k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|  13.2k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  220|       |
  221|  13.2k|        } else {
  222|      0|            if ((tmp = s_mp_alloc(ALLOC(from), sizeof(mp_digit))) == NULL)
  ------------------
  |  |  329|      0|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|      0|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
  |  Branch (222:17): [True: 0, False: 0]
  ------------------
  223|      0|                return MP_MEM;
  ------------------
  |  |   42|      0|#define MP_MEM -2    /* out of memory         */
  ------------------
  224|       |
  225|      0|            s_mp_copy(DIGITS(from), tmp, USED(from));
  ------------------
  |  |  330|      0|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|      0|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
                          s_mp_copy(DIGITS(from), tmp, USED(from));
  ------------------
  |  |  328|      0|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|      0|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  226|       |
  227|      0|            if (DIGITS(to) != NULL) {
  ------------------
  |  |  330|      0|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|      0|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
  |  Branch (227:17): [True: 0, False: 0]
  ------------------
  228|      0|                s_mp_setz(DIGITS(to), ALLOC(to));
  ------------------
  |  |  330|      0|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|      0|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
                              s_mp_setz(DIGITS(to), ALLOC(to));
  ------------------
  |  |  329|      0|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|      0|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
  229|      0|                s_mp_free(DIGITS(to));
  ------------------
  |  |  330|      0|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|      0|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
  230|      0|            }
  231|       |
  232|      0|            DIGITS(to) = tmp;
  ------------------
  |  |  330|      0|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|      0|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
  233|      0|            ALLOC(to) = ALLOC(from);
  ------------------
  |  |  329|      0|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|      0|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
                          ALLOC(to) = ALLOC(from);
  ------------------
  |  |  329|      0|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|      0|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
  234|      0|        }
  235|       |
  236|       |        /* Copy the precision and sign from the original */
  237|  13.2k|        USED(to) = USED(from);
  ------------------
  |  |  328|  13.2k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|  13.2k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
                      USED(to) = USED(from);
  ------------------
  |  |  328|  13.2k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|  13.2k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  238|  13.2k|        SIGN(to) = SIGN(from);
  ------------------
  |  |  327|  13.2k|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|  13.2k|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                      SIGN(to) = SIGN(from);
  ------------------
  |  |  327|  13.2k|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|  13.2k|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
  239|  13.2k|    } /* end copy */
  240|       |
  241|  13.2k|    return MP_OKAY;
  ------------------
  |  |   39|  13.2k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  242|       |
  243|  13.2k|} /* end mp_copy() */
mp_clear:
  285|   589k|{
  286|   589k|    if (mp == NULL)
  ------------------
  |  Branch (286:9): [True: 0, False: 589k]
  ------------------
  287|      0|        return;
  288|       |
  289|   589k|    if (DIGITS(mp) != NULL) {
  ------------------
  |  |  330|   589k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|   589k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
  |  Branch (289:9): [True: 589k, False: 0]
  ------------------
  290|   589k|        s_mp_setz(DIGITS(mp), ALLOC(mp));
  ------------------
  |  |  330|   589k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|   589k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
                      s_mp_setz(DIGITS(mp), ALLOC(mp));
  ------------------
  |  |  329|   589k|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|   589k|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
  291|   589k|        s_mp_free(DIGITS(mp));
  ------------------
  |  |  330|   589k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|   589k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
  292|   589k|        DIGITS(mp) = NULL;
  ------------------
  |  |  330|   589k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|   589k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
  293|   589k|    }
  294|       |
  295|   589k|    USED(mp) = 0;
  ------------------
  |  |  328|   589k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|   589k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  296|   589k|    ALLOC(mp) = 0;
  ------------------
  |  |  329|   589k|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|   589k|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
  297|       |
  298|   589k|} /* end mp_clear() */
mp_zero:
  312|  14.0k|{
  313|  14.0k|    if (mp == NULL)
  ------------------
  |  Branch (313:9): [True: 0, False: 14.0k]
  ------------------
  314|      0|        return;
  315|       |
  316|  14.0k|    s_mp_setz(DIGITS(mp), ALLOC(mp));
  ------------------
  |  |  330|  14.0k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|  14.0k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
                  s_mp_setz(DIGITS(mp), ALLOC(mp));
  ------------------
  |  |  329|  14.0k|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|  14.0k|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
  317|  14.0k|    USED(mp) = 1;
  ------------------
  |  |  328|  14.0k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|  14.0k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  318|  14.0k|    SIGN(mp) = ZPOS;
  ------------------
  |  |  327|  14.0k|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|  14.0k|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                  SIGN(mp) = ZPOS;
  ------------------
  |  |  321|  14.0k|#define ZPOS MP_ZPOS
  |  |  ------------------
  |  |  |  |   37|  14.0k|#define MP_ZPOS 0
  |  |  ------------------
  ------------------
  319|       |
  320|  14.0k|} /* end mp_zero() */
mp_add_d:
  408|   534k|{
  409|   534k|    mp_int tmp;
  410|   534k|    mp_err res;
  411|       |
  412|   534k|    ARGCHK(a != NULL && b != NULL, MP_BADARG);
  ------------------
  |  |  350|   534k|#define ARGCHK(X, Y) assert(X)
  ------------------
  413|       |
  414|   534k|    if ((res = mp_init_copy(&tmp, a)) != MP_OKAY)
  ------------------
  |  |   39|   534k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (414:9): [True: 0, False: 534k]
  ------------------
  415|      0|        return res;
  416|       |
  417|   534k|    if (SIGN(&tmp) == ZPOS) {
  ------------------
  |  |  327|   534k|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|   534k|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                  if (SIGN(&tmp) == ZPOS) {
  ------------------
  |  |  321|   534k|#define ZPOS MP_ZPOS
  |  |  ------------------
  |  |  |  |   37|   534k|#define MP_ZPOS 0
  |  |  ------------------
  ------------------
  |  Branch (417:9): [True: 534k, False: 0]
  ------------------
  418|   534k|        if ((res = s_mp_add_d(&tmp, d)) != MP_OKAY)
  ------------------
  |  |   39|   534k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (418:13): [True: 0, False: 534k]
  ------------------
  419|      0|            goto CLEANUP;
  420|   534k|    } else if (s_mp_cmp_d(&tmp, d) >= 0) {
  ------------------
  |  Branch (420:16): [True: 0, False: 0]
  ------------------
  421|      0|        if ((res = s_mp_sub_d(&tmp, d)) != MP_OKAY)
  ------------------
  |  |   39|      0|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (421:13): [True: 0, False: 0]
  ------------------
  422|      0|            goto CLEANUP;
  423|      0|    } else {
  424|      0|        mp_neg(&tmp, &tmp);
  425|       |
  426|      0|        DIGIT(&tmp, 0) = d - DIGIT(&tmp, 0);
  ------------------
  |  |  331|      0|#define DIGIT(MP, N) MP_DIGIT(MP, N)
  |  |  ------------------
  |  |  |  |  148|      0|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  |  |  ------------------
  ------------------
                      DIGIT(&tmp, 0) = d - DIGIT(&tmp, 0);
  ------------------
  |  |  331|      0|#define DIGIT(MP, N) MP_DIGIT(MP, N)
  |  |  ------------------
  |  |  |  |  148|      0|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  |  |  ------------------
  ------------------
  427|      0|    }
  428|       |
  429|   534k|    if (s_mp_cmp_d(&tmp, 0) == 0)
  ------------------
  |  Branch (429:9): [True: 61.0k, False: 473k]
  ------------------
  430|  61.0k|        SIGN(&tmp) = ZPOS;
  ------------------
  |  |  327|  61.0k|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|  61.0k|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                      SIGN(&tmp) = ZPOS;
  ------------------
  |  |  321|  61.0k|#define ZPOS MP_ZPOS
  |  |  ------------------
  |  |  |  |   37|  61.0k|#define MP_ZPOS 0
  |  |  ------------------
  ------------------
  431|       |
  432|   534k|    s_mp_exch(&tmp, b);
  433|       |
  434|   534k|CLEANUP:
  435|   534k|    mp_clear(&tmp);
  436|   534k|    return res;
  437|       |
  438|   534k|} /* end mp_add_d() */
mp_mul_d:
  499|   533k|{
  500|   533k|    mp_err res;
  501|       |
  502|   533k|    ARGCHK(a != NULL && b != NULL, MP_BADARG);
  ------------------
  |  |  350|   533k|#define ARGCHK(X, Y) assert(X)
  ------------------
  503|       |
  504|   533k|    if (d == 0) {
  ------------------
  |  Branch (504:9): [True: 0, False: 533k]
  ------------------
  505|      0|        mp_zero(b);
  506|      0|        return MP_OKAY;
  ------------------
  |  |   39|      0|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  507|      0|    }
  508|       |
  509|   533k|    if ((res = mp_copy(a, b)) != MP_OKAY)
  ------------------
  |  |   39|   533k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (509:9): [True: 0, False: 533k]
  ------------------
  510|      0|        return res;
  511|       |
  512|   533k|    res = s_mp_mul_d(b, d);
  513|       |
  514|   533k|    return res;
  515|       |
  516|   533k|} /* end mp_mul_d() */
mp_div_d:
  550|  1.07M|{
  551|  1.07M|    mp_err res;
  552|  1.07M|    mp_int qp;
  553|  1.07M|    mp_digit rem = 0;
  554|  1.07M|    int pow;
  555|       |
  556|  1.07M|    ARGCHK(a != NULL, MP_BADARG);
  ------------------
  |  |  350|  1.07M|#define ARGCHK(X, Y) assert(X)
  ------------------
  557|       |
  558|  1.07M|    if (d == 0)
  ------------------
  |  Branch (558:9): [True: 0, False: 1.07M]
  ------------------
  559|      0|        return MP_RANGE;
  ------------------
  |  |   43|      0|#define MP_RANGE -3  /* argument out of range */
  ------------------
  560|       |
  561|       |    /* Shortcut for powers of two ... */
  562|  1.07M|    if ((pow = s_mp_ispow2d(d)) >= 0) {
  ------------------
  |  Branch (562:9): [True: 1.07M, False: 0]
  ------------------
  563|  1.07M|        mp_digit mask;
  564|       |
  565|  1.07M|        mask = ((mp_digit)1 << pow) - 1;
  566|  1.07M|        rem = DIGIT(a, 0) & mask;
  ------------------
  |  |  331|  1.07M|#define DIGIT(MP, N) MP_DIGIT(MP, N)
  |  |  ------------------
  |  |  |  |  148|  1.07M|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  |  |  ------------------
  ------------------
  567|       |
  568|  1.07M|        if (q) {
  ------------------
  |  Branch (568:13): [True: 1.07M, False: 0]
  ------------------
  569|  1.07M|            if ((res = mp_copy(a, q)) != MP_OKAY) {
  ------------------
  |  |   39|  1.07M|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (569:17): [True: 0, False: 1.07M]
  ------------------
  570|      0|                return res;
  571|      0|            }
  572|  1.07M|            s_mp_div_2d(q, pow);
  573|  1.07M|        }
  574|       |
  575|  1.07M|        if (r)
  ------------------
  |  Branch (575:13): [True: 1.07M, False: 0]
  ------------------
  576|  1.07M|            *r = rem;
  577|       |
  578|  1.07M|        return MP_OKAY;
  ------------------
  |  |   39|  1.07M|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  579|  1.07M|    }
  580|       |
  581|      0|    if ((res = mp_init_copy(&qp, a)) != MP_OKAY)
  ------------------
  |  |   39|      0|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (581:9): [True: 0, False: 0]
  ------------------
  582|      0|        return res;
  583|       |
  584|      0|    res = s_mp_div_d(&qp, d, &rem);
  585|       |
  586|      0|    if (s_mp_cmp_d(&qp, 0) == 0)
  ------------------
  |  Branch (586:9): [True: 0, False: 0]
  ------------------
  587|      0|        SIGN(q) = ZPOS;
  ------------------
  |  |  327|      0|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|      0|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                      SIGN(q) = ZPOS;
  ------------------
  |  |  321|      0|#define ZPOS MP_ZPOS
  |  |  ------------------
  |  |  |  |   37|      0|#define MP_ZPOS 0
  |  |  ------------------
  ------------------
  588|       |
  589|      0|    if (r) {
  ------------------
  |  Branch (589:9): [True: 0, False: 0]
  ------------------
  590|      0|        *r = rem;
  591|      0|    }
  592|       |
  593|      0|    if (q)
  ------------------
  |  Branch (593:9): [True: 0, False: 0]
  ------------------
  594|      0|        s_mp_exch(&qp, q);
  595|       |
  596|      0|    mp_clear(&qp);
  597|      0|    return res;
  598|       |
  599|      0|} /* end mp_div_d() */
mp_add:
  741|  2.45k|{
  742|  2.45k|    mp_err res;
  743|       |
  744|  2.45k|    ARGCHK(a != NULL && b != NULL && c != NULL, MP_BADARG);
  ------------------
  |  |  350|  2.45k|#define ARGCHK(X, Y) assert(X)
  ------------------
  745|       |
  746|  2.45k|    if (SIGN(a) == SIGN(b)) { /* same sign:  add values, keep sign */
  ------------------
  |  |  327|  2.45k|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|  2.45k|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                  if (SIGN(a) == SIGN(b)) { /* same sign:  add values, keep sign */
  ------------------
  |  |  327|  2.45k|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|  2.45k|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
  |  Branch (746:9): [True: 0, False: 2.45k]
  ------------------
  747|      0|        MP_CHECKOK(s_mp_add_3arg(a, b, c));
  ------------------
  |  |  314|      0|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  315|      0|    goto CLEANUP
  ------------------
  748|  2.45k|    } else if (s_mp_cmp(a, b) >= 0) { /* different sign: |a| >= |b|   */
  ------------------
  |  Branch (748:16): [True: 0, False: 2.45k]
  ------------------
  749|      0|        MP_CHECKOK(s_mp_sub_3arg(a, b, c));
  ------------------
  |  |  314|      0|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  315|      0|    goto CLEANUP
  ------------------
  750|  2.45k|    } else { /* different sign: |a|  < |b|   */
  751|  2.45k|        MP_CHECKOK(s_mp_sub_3arg(b, a, c));
  ------------------
  |  |  314|  2.45k|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|  2.45k|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 2.45k]
  |  |  ------------------
  |  |  315|  2.45k|    goto CLEANUP
  ------------------
  752|  2.45k|    }
  753|       |
  754|  2.45k|    if (s_mp_cmp_d(c, 0) == MP_EQ)
  ------------------
  |  |   96|  2.45k|#define MP_EQ 0
  ------------------
  |  Branch (754:9): [True: 0, False: 2.45k]
  ------------------
  755|      0|        SIGN(c) = ZPOS;
  ------------------
  |  |  327|      0|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|      0|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                      SIGN(c) = ZPOS;
  ------------------
  |  |  321|      0|#define ZPOS MP_ZPOS
  |  |  ------------------
  |  |  |  |   37|      0|#define MP_ZPOS 0
  |  |  ------------------
  ------------------
  756|       |
  757|  2.45k|CLEANUP:
  758|  2.45k|    return res;
  759|       |
  760|  2.45k|} /* end mp_add() */
mp_sub:
  774|  4.51k|{
  775|  4.51k|    mp_err res;
  776|  4.51k|    int magDiff;
  777|       |
  778|  4.51k|    ARGCHK(a != NULL && b != NULL && c != NULL, MP_BADARG);
  ------------------
  |  |  350|  4.51k|#define ARGCHK(X, Y) assert(X)
  ------------------
  779|       |
  780|  4.51k|    if (a == b) {
  ------------------
  |  Branch (780:9): [True: 0, False: 4.51k]
  ------------------
  781|      0|        mp_zero(c);
  782|      0|        return MP_OKAY;
  ------------------
  |  |   39|      0|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  783|      0|    }
  784|       |
  785|  4.51k|    if (MP_SIGN(a) != MP_SIGN(b)) {
  ------------------
  |  |  144|  4.51k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
                  if (MP_SIGN(a) != MP_SIGN(b)) {
  ------------------
  |  |  144|  4.51k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
  |  Branch (785:9): [True: 0, False: 4.51k]
  ------------------
  786|      0|        MP_CHECKOK(s_mp_add_3arg(a, b, c));
  ------------------
  |  |  314|      0|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  315|      0|    goto CLEANUP
  ------------------
  787|  4.51k|    } else if (!(magDiff = s_mp_cmp(a, b))) {
  ------------------
  |  Branch (787:16): [True: 37, False: 4.47k]
  ------------------
  788|     37|        mp_zero(c);
  789|     37|        res = MP_OKAY;
  ------------------
  |  |   39|     37|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  790|  4.47k|    } else if (magDiff > 0) {
  ------------------
  |  Branch (790:16): [True: 1.90k, False: 2.57k]
  ------------------
  791|  1.90k|        MP_CHECKOK(s_mp_sub_3arg(a, b, c));
  ------------------
  |  |  314|  1.90k|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|  1.90k|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 1.90k]
  |  |  ------------------
  |  |  315|  1.90k|    goto CLEANUP
  ------------------
  792|  2.57k|    } else {
  793|  2.57k|        MP_CHECKOK(s_mp_sub_3arg(b, a, c));
  ------------------
  |  |  314|  2.57k|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|  2.57k|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 2.57k]
  |  |  ------------------
  |  |  315|  2.57k|    goto CLEANUP
  ------------------
  794|  2.57k|        MP_SIGN(c) = !MP_SIGN(a);
  ------------------
  |  |  144|  2.57k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
                      MP_SIGN(c) = !MP_SIGN(a);
  ------------------
  |  |  144|  2.57k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
  795|  2.57k|    }
  796|       |
  797|  4.51k|    if (s_mp_cmp_d(c, 0) == MP_EQ)
  ------------------
  |  |   96|  4.51k|#define MP_EQ 0
  ------------------
  |  Branch (797:9): [True: 37, False: 4.47k]
  ------------------
  798|     37|        MP_SIGN(c) = MP_ZPOS;
  ------------------
  |  |  144|     37|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
                      MP_SIGN(c) = MP_ZPOS;
  ------------------
  |  |   37|     37|#define MP_ZPOS 0
  ------------------
  799|       |
  800|  4.51k|CLEANUP:
  801|  4.51k|    return res;
  802|       |
  803|  4.51k|} /* end mp_sub() */
mp_div:
 1062|  4.09k|{
 1063|  4.09k|    mp_err res;
 1064|  4.09k|    mp_int *pQ, *pR;
 1065|  4.09k|    mp_int qtmp, rtmp, btmp;
 1066|  4.09k|    int cmp;
 1067|  4.09k|    mp_sign signA;
 1068|  4.09k|    mp_sign signB;
 1069|       |
 1070|  4.09k|    ARGCHK(a != NULL && b != NULL, MP_BADARG);
  ------------------
  |  |  350|  4.09k|#define ARGCHK(X, Y) assert(X)
  ------------------
 1071|       |
 1072|  4.09k|    signA = MP_SIGN(a);
  ------------------
  |  |  144|  4.09k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
 1073|  4.09k|    signB = MP_SIGN(b);
  ------------------
  |  |  144|  4.09k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
 1074|       |
 1075|  4.09k|    if (mp_cmp_z(b) == MP_EQ)
  ------------------
  |  |   96|  4.09k|#define MP_EQ 0
  ------------------
  |  Branch (1075:9): [True: 0, False: 4.09k]
  ------------------
 1076|      0|        return MP_RANGE;
  ------------------
  |  |   43|      0|#define MP_RANGE -3  /* argument out of range */
  ------------------
 1077|       |
 1078|  4.09k|    DIGITS(&qtmp) = 0;
  ------------------
  |  |  330|  4.09k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|  4.09k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
 1079|  4.09k|    DIGITS(&rtmp) = 0;
  ------------------
  |  |  330|  4.09k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|  4.09k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
 1080|  4.09k|    DIGITS(&btmp) = 0;
  ------------------
  |  |  330|  4.09k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|  4.09k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
 1081|       |
 1082|       |    /* Set up some temporaries... */
 1083|  4.09k|    if (!r || r == a || r == b) {
  ------------------
  |  Branch (1083:9): [True: 0, False: 4.09k]
  |  Branch (1083:15): [True: 4.09k, False: 0]
  |  Branch (1083:25): [True: 0, False: 0]
  ------------------
 1084|  4.09k|        MP_CHECKOK(mp_init_copy(&rtmp, a));
  ------------------
  |  |  314|  4.09k|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|  4.09k|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 4.09k]
  |  |  ------------------
  |  |  315|  4.09k|    goto CLEANUP
  ------------------
 1085|  4.09k|        pR = &rtmp;
 1086|  4.09k|    } else {
 1087|      0|        MP_CHECKOK(mp_copy(a, r));
  ------------------
  |  |  314|      0|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  315|      0|    goto CLEANUP
  ------------------
 1088|      0|        pR = r;
 1089|      0|    }
 1090|       |
 1091|  4.09k|    if (!q || q == a || q == b) {
  ------------------
  |  Branch (1091:9): [True: 4.09k, False: 0]
  |  Branch (1091:15): [True: 0, False: 0]
  |  Branch (1091:25): [True: 0, False: 0]
  ------------------
 1092|  4.09k|        MP_CHECKOK(mp_init_size(&qtmp, MP_USED(a)));
  ------------------
  |  |  314|  4.09k|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|  4.09k|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 4.09k]
  |  |  ------------------
  |  |  315|  4.09k|    goto CLEANUP
  ------------------
 1093|  4.09k|        pQ = &qtmp;
 1094|  4.09k|    } else {
 1095|      0|        MP_CHECKOK(s_mp_pad(q, MP_USED(a)));
  ------------------
  |  |  314|      0|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  315|      0|    goto CLEANUP
  ------------------
 1096|      0|        pQ = q;
 1097|      0|        mp_zero(pQ);
 1098|      0|    }
 1099|       |
 1100|       |    /*
 1101|       |      If |a| <= |b|, we can compute the solution without division;
 1102|       |      otherwise, we actually do the work required.
 1103|       |     */
 1104|  4.09k|    if ((cmp = s_mp_cmp(a, b)) <= 0) {
  ------------------
  |  Branch (1104:9): [True: 0, False: 4.09k]
  ------------------
 1105|      0|        if (cmp) {
  ------------------
  |  Branch (1105:13): [True: 0, False: 0]
  ------------------
 1106|       |            /* r was set to a above. */
 1107|      0|            mp_zero(pQ);
 1108|      0|        } else {
 1109|      0|            mp_set(pQ, 1);
 1110|      0|            mp_zero(pR);
 1111|      0|        }
 1112|  4.09k|    } else {
 1113|  4.09k|        MP_CHECKOK(mp_init_copy(&btmp, b));
  ------------------
  |  |  314|  4.09k|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|  4.09k|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 4.09k]
  |  |  ------------------
  |  |  315|  4.09k|    goto CLEANUP
  ------------------
 1114|  4.09k|        MP_CHECKOK(s_mp_div(pR, &btmp, pQ));
  ------------------
  |  |  314|  4.09k|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|  4.09k|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 4.09k]
  |  |  ------------------
  |  |  315|  4.09k|    goto CLEANUP
  ------------------
 1115|  4.09k|    }
 1116|       |
 1117|       |    /* Compute the signs for the output  */
 1118|  4.09k|    MP_SIGN(pR) = signA;        /* Sr = Sa              */
  ------------------
  |  |  144|  4.09k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
 1119|       |    /* Sq = ZPOS if Sa == Sb */ /* Sq = NEG if Sa != Sb */
 1120|  4.09k|    MP_SIGN(pQ) = (signA == signB) ? ZPOS : NEG;
  ------------------
  |  |  144|  4.09k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
                  MP_SIGN(pQ) = (signA == signB) ? ZPOS : NEG;
  ------------------
  |  |  321|  1.72k|#define ZPOS MP_ZPOS
  |  |  ------------------
  |  |  |  |   37|  1.72k|#define MP_ZPOS 0
  |  |  ------------------
  ------------------
                  MP_SIGN(pQ) = (signA == signB) ? ZPOS : NEG;
  ------------------
  |  |  320|  2.36k|#define NEG MP_NEG
  |  |  ------------------
  |  |  |  |   36|  6.45k|#define MP_NEG 1
  |  |  ------------------
  ------------------
  |  Branch (1120:19): [True: 1.72k, False: 2.36k]
  ------------------
 1121|       |
 1122|  4.09k|    if (s_mp_cmp_d(pQ, 0) == MP_EQ)
  ------------------
  |  |   96|  4.09k|#define MP_EQ 0
  ------------------
  |  Branch (1122:9): [True: 0, False: 4.09k]
  ------------------
 1123|      0|        SIGN(pQ) = ZPOS;
  ------------------
  |  |  327|      0|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|      0|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                      SIGN(pQ) = ZPOS;
  ------------------
  |  |  321|      0|#define ZPOS MP_ZPOS
  |  |  ------------------
  |  |  |  |   37|      0|#define MP_ZPOS 0
  |  |  ------------------
  ------------------
 1124|  4.09k|    if (s_mp_cmp_d(pR, 0) == MP_EQ)
  ------------------
  |  |   96|  4.09k|#define MP_EQ 0
  ------------------
  |  Branch (1124:9): [True: 180, False: 3.91k]
  ------------------
 1125|    180|        SIGN(pR) = ZPOS;
  ------------------
  |  |  327|    180|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|    180|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                      SIGN(pR) = ZPOS;
  ------------------
  |  |  321|    180|#define ZPOS MP_ZPOS
  |  |  ------------------
  |  |  |  |   37|    180|#define MP_ZPOS 0
  |  |  ------------------
  ------------------
 1126|       |
 1127|       |    /* Copy output, if it is needed      */
 1128|  4.09k|    if (q && q != pQ)
  ------------------
  |  Branch (1128:9): [True: 0, False: 4.09k]
  |  Branch (1128:14): [True: 0, False: 0]
  ------------------
 1129|      0|        s_mp_exch(pQ, q);
 1130|       |
 1131|  4.09k|    if (r && r != pR)
  ------------------
  |  Branch (1131:9): [True: 4.09k, False: 0]
  |  Branch (1131:14): [True: 4.09k, False: 0]
  ------------------
 1132|  4.09k|        s_mp_exch(pR, r);
 1133|       |
 1134|  4.09k|CLEANUP:
 1135|  4.09k|    mp_clear(&btmp);
 1136|  4.09k|    mp_clear(&rtmp);
 1137|  4.09k|    mp_clear(&qtmp);
 1138|       |
 1139|  4.09k|    return res;
 1140|       |
 1141|  4.09k|} /* end mp_div() */
mp_mod:
 1279|  4.51k|{
 1280|  4.51k|    mp_err res;
 1281|  4.51k|    int mag;
 1282|       |
 1283|  4.51k|    ARGCHK(a != NULL && m != NULL && c != NULL, MP_BADARG);
  ------------------
  |  |  350|  4.51k|#define ARGCHK(X, Y) assert(X)
  ------------------
 1284|       |
 1285|  4.51k|    if (SIGN(m) == NEG)
  ------------------
  |  |  327|  4.51k|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|  4.51k|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                  if (SIGN(m) == NEG)
  ------------------
  |  |  320|  4.51k|#define NEG MP_NEG
  |  |  ------------------
  |  |  |  |   36|  4.51k|#define MP_NEG 1
  |  |  ------------------
  ------------------
  |  Branch (1285:9): [True: 0, False: 4.51k]
  ------------------
 1286|      0|        return MP_RANGE;
  ------------------
  |  |   43|      0|#define MP_RANGE -3  /* argument out of range */
  ------------------
 1287|       |
 1288|       |    /*
 1289|       |     If |a| > m, we need to divide to get the remainder and take the
 1290|       |     absolute value.
 1291|       |
 1292|       |     If |a| < m, we don't need to do any division, just copy and adjust
 1293|       |     the sign (if a is negative).
 1294|       |
 1295|       |     If |a| == m, we can simply set the result to zero.
 1296|       |
 1297|       |     This order is intended to minimize the average path length of the
 1298|       |     comparison chain on common workloads -- the most frequent cases are
 1299|       |     that |a| != m, so we do those first.
 1300|       |     */
 1301|  4.51k|    if ((mag = s_mp_cmp(a, m)) > 0) {
  ------------------
  |  Branch (1301:9): [True: 4.09k, False: 420]
  ------------------
 1302|  4.09k|        if ((res = mp_div(a, m, NULL, c)) != MP_OKAY)
  ------------------
  |  |   39|  4.09k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (1302:13): [True: 0, False: 4.09k]
  ------------------
 1303|      0|            return res;
 1304|       |
 1305|  4.09k|        if (SIGN(c) == NEG) {
  ------------------
  |  |  327|  4.09k|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|  4.09k|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                      if (SIGN(c) == NEG) {
  ------------------
  |  |  320|  4.09k|#define NEG MP_NEG
  |  |  ------------------
  |  |  |  |   36|  4.09k|#define MP_NEG 1
  |  |  ------------------
  ------------------
  |  Branch (1305:13): [True: 2.25k, False: 1.84k]
  ------------------
 1306|  2.25k|            if ((res = mp_add(c, m, c)) != MP_OKAY)
  ------------------
  |  |   39|  2.25k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (1306:17): [True: 0, False: 2.25k]
  ------------------
 1307|      0|                return res;
 1308|  2.25k|        }
 1309|       |
 1310|  4.09k|    } else if (mag < 0) {
  ------------------
  |  Branch (1310:16): [True: 415, False: 5]
  ------------------
 1311|    415|        if ((res = mp_copy(a, c)) != MP_OKAY)
  ------------------
  |  |   39|    415|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (1311:13): [True: 0, False: 415]
  ------------------
 1312|      0|            return res;
 1313|       |
 1314|    415|        if (mp_cmp_z(a) < 0) {
  ------------------
  |  Branch (1314:13): [True: 205, False: 210]
  ------------------
 1315|    205|            if ((res = mp_add(c, m, c)) != MP_OKAY)
  ------------------
  |  |   39|    205|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (1315:17): [True: 0, False: 205]
  ------------------
 1316|      0|                return res;
 1317|    205|        }
 1318|       |
 1319|    415|    } else {
 1320|      5|        mp_zero(c);
 1321|      5|    }
 1322|       |
 1323|  4.51k|    return MP_OKAY;
  ------------------
  |  |   39|  4.51k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
 1324|       |
 1325|  4.51k|} /* end mp_mod() */
mp_submod:
 1537|  4.51k|{
 1538|  4.51k|    mp_err res;
 1539|       |
 1540|  4.51k|    ARGCHK(a != NULL && b != NULL && m != NULL && c != NULL, MP_BADARG);
  ------------------
  |  |  350|  4.51k|#define ARGCHK(X, Y) assert(X)
  ------------------
 1541|       |
 1542|  4.51k|    if ((res = mp_sub(a, b, c)) != MP_OKAY)
  ------------------
  |  |   39|  4.51k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (1542:9): [True: 0, False: 4.51k]
  ------------------
 1543|      0|        return res;
 1544|  4.51k|    if ((res = mp_mod(c, m, c)) != MP_OKAY)
  ------------------
  |  |   39|  4.51k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (1544:9): [True: 0, False: 4.51k]
  ------------------
 1545|      0|        return res;
 1546|       |
 1547|  4.51k|    return MP_OKAY;
  ------------------
  |  |   39|  4.51k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
 1548|  4.51k|}
mp_cmp_z:
 1790|  1.12M|{
 1791|  1.12M|    ARGMPCHK(a != NULL);
  ------------------
  |  |  349|  1.12M|#define ARGMPCHK(X) assert(X)
  ------------------
 1792|       |
 1793|  1.12M|    if (SIGN(a) == NEG)
  ------------------
  |  |  327|  1.12M|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|  1.12M|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                  if (SIGN(a) == NEG)
  ------------------
  |  |  320|  1.12M|#define NEG MP_NEG
  |  |  ------------------
  |  |  |  |   36|  1.12M|#define MP_NEG 1
  |  |  ------------------
  ------------------
  |  Branch (1793:9): [True: 205, False: 1.12M]
  ------------------
 1794|    205|        return MP_LT;
  ------------------
  |  |   95|    205|#define MP_LT -1
  ------------------
 1795|  1.12M|    else if (USED(a) == 1 && DIGIT(a, 0) == 0)
  ------------------
  |  |  328|  1.12M|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|  1.12M|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
                  else if (USED(a) == 1 && DIGIT(a, 0) == 0)
  ------------------
  |  |  331|   256k|#define DIGIT(MP, N) MP_DIGIT(MP, N)
  |  |  ------------------
  |  |  |  |  148|   256k|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  |  |  ------------------
  ------------------
  |  Branch (1795:14): [True: 256k, False: 865k]
  |  Branch (1795:30): [True: 18.5k, False: 237k]
  ------------------
 1796|  18.5k|        return MP_EQ;
  ------------------
  |  |   96|  18.5k|#define MP_EQ 0
  ------------------
 1797|  1.10M|    else
 1798|  1.10M|        return MP_GT;
  ------------------
  |  |   97|  1.10M|#define MP_GT 1
  ------------------
 1799|       |
 1800|  1.12M|} /* end mp_cmp_z() */
mp_read_raw:
 2735|  13.5k|{
 2736|  13.5k|    int ix;
 2737|  13.5k|    mp_err res;
 2738|  13.5k|    unsigned char *ustr = (unsigned char *)str;
 2739|       |
 2740|  13.5k|    ARGCHK(mp != NULL && str != NULL && len > 0, MP_BADARG);
  ------------------
  |  |  350|  13.5k|#define ARGCHK(X, Y) assert(X)
  ------------------
 2741|       |
 2742|  13.5k|    mp_zero(mp);
 2743|       |
 2744|       |    /* Read the rest of the digits */
 2745|   547k|    for (ix = 1; ix < len; ix++) {
  ------------------
  |  Branch (2745:18): [True: 533k, False: 13.5k]
  ------------------
 2746|   533k|        if ((res = mp_mul_d(mp, 256, mp)) != MP_OKAY)
  ------------------
  |  |   39|   533k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (2746:13): [True: 0, False: 533k]
  ------------------
 2747|      0|            return res;
 2748|   533k|        if ((res = mp_add_d(mp, ustr[ix], mp)) != MP_OKAY)
  ------------------
  |  |   39|   533k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (2748:13): [True: 0, False: 533k]
  ------------------
 2749|      0|            return res;
 2750|   533k|    }
 2751|       |
 2752|       |    /* Get sign from first byte */
 2753|  13.5k|    if (ustr[0])
  ------------------
  |  Branch (2753:9): [True: 9.98k, False: 3.52k]
  ------------------
 2754|  9.98k|        SIGN(mp) = NEG;
  ------------------
  |  |  327|  9.98k|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|  9.98k|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                      SIGN(mp) = NEG;
  ------------------
  |  |  320|  9.98k|#define NEG MP_NEG
  |  |  ------------------
  |  |  |  |   36|  9.98k|#define MP_NEG 1
  |  |  ------------------
  ------------------
 2755|  3.52k|    else
 2756|  3.52k|        SIGN(mp) = ZPOS;
  ------------------
  |  |  327|  3.52k|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|  3.52k|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                      SIGN(mp) = ZPOS;
  ------------------
  |  |  321|  3.52k|#define ZPOS MP_ZPOS
  |  |  ------------------
  |  |  |  |   37|  3.52k|#define MP_ZPOS 0
  |  |  ------------------
  ------------------
 2757|       |
 2758|  13.5k|    return MP_OKAY;
  ------------------
  |  |   39|  13.5k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
 2759|       |
 2760|  13.5k|} /* end mp_read_raw() */
mp_toradix:
 2924|  18.0k|{
 2925|  18.0k|    int ix, pos = 0;
 2926|       |
 2927|  18.0k|    ARGCHK(mp != NULL && str != NULL, MP_BADARG);
  ------------------
  |  |  350|  18.0k|#define ARGCHK(X, Y) assert(X)
  ------------------
 2928|  18.0k|    ARGCHK(radix > 1 && radix <= MAX_RADIX, MP_RANGE);
  ------------------
  |  |  350|  18.0k|#define ARGCHK(X, Y) assert(X)
  ------------------
 2929|       |
 2930|  18.0k|    if (mp_cmp_z(mp) == MP_EQ) {
  ------------------
  |  |   96|  18.0k|#define MP_EQ 0
  ------------------
  |  Branch (2930:9): [True: 913, False: 17.1k]
  ------------------
 2931|    913|        str[0] = '0';
 2932|    913|        str[1] = '\0';
 2933|  17.1k|    } else {
 2934|  17.1k|        mp_err res;
 2935|  17.1k|        mp_int tmp;
 2936|  17.1k|        mp_sign sgn;
 2937|  17.1k|        mp_digit rem, rdx = (mp_digit)radix;
 2938|  17.1k|        char ch;
 2939|       |
 2940|  17.1k|        if ((res = mp_init_copy(&tmp, mp)) != MP_OKAY)
  ------------------
  |  |   39|  17.1k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (2940:13): [True: 0, False: 17.1k]
  ------------------
 2941|      0|            return res;
 2942|       |
 2943|       |        /* Save sign for later, and take absolute value */
 2944|  17.1k|        sgn = SIGN(&tmp);
  ------------------
  |  |  327|  17.1k|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|  17.1k|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
 2945|  17.1k|        SIGN(&tmp) = ZPOS;
  ------------------
  |  |  327|  17.1k|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|  17.1k|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                      SIGN(&tmp) = ZPOS;
  ------------------
  |  |  321|  17.1k|#define ZPOS MP_ZPOS
  |  |  ------------------
  |  |  |  |   37|  17.1k|#define MP_ZPOS 0
  |  |  ------------------
  ------------------
 2946|       |
 2947|       |        /* Generate output digits in reverse order      */
 2948|  1.09M|        while (mp_cmp_z(&tmp) != 0) {
  ------------------
  |  Branch (2948:16): [True: 1.07M, False: 17.1k]
  ------------------
 2949|  1.07M|            if ((res = mp_div_d(&tmp, rdx, &tmp, &rem)) != MP_OKAY) {
  ------------------
  |  |   39|  1.07M|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (2949:17): [True: 0, False: 1.07M]
  ------------------
 2950|      0|                mp_clear(&tmp);
 2951|      0|                return res;
 2952|      0|            }
 2953|       |
 2954|       |            /* Generate digits, use capital letters */
 2955|  1.07M|            ch = s_mp_todigit(rem, radix, 0);
 2956|       |
 2957|  1.07M|            str[pos++] = ch;
 2958|  1.07M|        }
 2959|       |
 2960|       |        /* Add - sign if original value was negative */
 2961|  17.1k|        if (sgn == NEG)
  ------------------
  |  |  320|  17.1k|#define NEG MP_NEG
  |  |  ------------------
  |  |  |  |   36|  17.1k|#define MP_NEG 1
  |  |  ------------------
  ------------------
  |  Branch (2961:13): [True: 0, False: 17.1k]
  ------------------
 2962|      0|            str[pos++] = '-';
 2963|       |
 2964|       |        /* Add trailing NUL to end the string        */
 2965|  17.1k|        str[pos--] = '\0';
 2966|       |
 2967|       |        /* Reverse the digits and sign indicator     */
 2968|  17.1k|        ix = 0;
 2969|   552k|        while (ix < pos) {
  ------------------
  |  Branch (2969:16): [True: 535k, False: 17.1k]
  ------------------
 2970|   535k|            char tmpc = str[ix];
 2971|       |
 2972|   535k|            str[ix] = str[pos];
 2973|   535k|            str[pos] = tmpc;
 2974|   535k|            ++ix;
 2975|   535k|            --pos;
 2976|   535k|        }
 2977|       |
 2978|  17.1k|        mp_clear(&tmp);
 2979|  17.1k|    }
 2980|       |
 2981|  18.0k|    return MP_OKAY;
  ------------------
  |  |   39|  18.0k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
 2982|       |
 2983|  18.0k|} /* end mp_toradix() */
s_mp_grow:
 3038|    178|{
 3039|    178|    ARGCHK(mp != NULL, MP_BADARG);
  ------------------
  |  |  350|    178|#define ARGCHK(X, Y) assert(X)
  ------------------
 3040|       |
 3041|    178|    if (min > ALLOC(mp)) {
  ------------------
  |  |  329|    178|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|    178|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
  |  Branch (3041:9): [True: 178, False: 0]
  ------------------
 3042|    178|        mp_digit *tmp;
 3043|       |
 3044|       |        /* Set min to next nearest default precision block size */
 3045|    178|        min = MP_ROUNDUP(min, s_mp_defprec);
  ------------------
  |  |   89|    178|#define MP_ROUNDUP(a, b) (MP_HOWMANY(a, b) * (b))
  |  |  ------------------
  |  |  |  |   88|    178|#define MP_HOWMANY(a, b) (((a) + (b)-1) / (b))
  |  |  ------------------
  ------------------
 3046|       |
 3047|    178|        if ((tmp = s_mp_alloc(min, sizeof(mp_digit))) == NULL)
  ------------------
  |  Branch (3047:13): [True: 0, False: 178]
  ------------------
 3048|      0|            return MP_MEM;
  ------------------
  |  |   42|      0|#define MP_MEM -2    /* out of memory         */
  ------------------
 3049|       |
 3050|    178|        s_mp_copy(DIGITS(mp), tmp, USED(mp));
  ------------------
  |  |  330|    178|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|    178|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
                      s_mp_copy(DIGITS(mp), tmp, USED(mp));
  ------------------
  |  |  328|    178|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|    178|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
 3051|       |
 3052|    178|        s_mp_setz(DIGITS(mp), ALLOC(mp));
  ------------------
  |  |  330|    178|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|    178|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
                      s_mp_setz(DIGITS(mp), ALLOC(mp));
  ------------------
  |  |  329|    178|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|    178|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
 3053|    178|        s_mp_free(DIGITS(mp));
  ------------------
  |  |  330|    178|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|    178|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
 3054|    178|        DIGITS(mp) = tmp;
  ------------------
  |  |  330|    178|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|    178|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
 3055|    178|        ALLOC(mp) = min;
  ------------------
  |  |  329|    178|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|    178|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
 3056|    178|    }
 3057|       |
 3058|    178|    return MP_OKAY;
  ------------------
  |  |   39|    178|#define MP_OKAY 0    /* no error, all is well */
  ------------------
 3059|       |
 3060|    178|} /* end s_mp_grow() */
s_mp_pad:
 3069|   558k|{
 3070|   558k|    ARGCHK(mp != NULL, MP_BADARG);
  ------------------
  |  |  350|   558k|#define ARGCHK(X, Y) assert(X)
  ------------------
 3071|       |
 3072|   558k|    if (min > USED(mp)) {
  ------------------
  |  |  328|   558k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|   558k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  |  Branch (3072:9): [True: 71.3k, False: 487k]
  ------------------
 3073|  71.3k|        mp_err res;
 3074|       |
 3075|       |        /* Make sure there is room to increase precision  */
 3076|  71.3k|        if (min > ALLOC(mp)) {
  ------------------
  |  |  329|  71.3k|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|  71.3k|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
  |  Branch (3076:13): [True: 178, False: 71.2k]
  ------------------
 3077|    178|            if ((res = s_mp_grow(mp, min)) != MP_OKAY)
  ------------------
  |  |   39|    178|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (3077:17): [True: 0, False: 178]
  ------------------
 3078|      0|                return res;
 3079|  71.2k|        } else {
 3080|  71.2k|            s_mp_setz(DIGITS(mp) + USED(mp), min - USED(mp));
  ------------------
  |  |  330|  71.2k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|  71.2k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
                          s_mp_setz(DIGITS(mp) + USED(mp), min - USED(mp));
  ------------------
  |  |  328|  71.2k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|  71.2k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
                          s_mp_setz(DIGITS(mp) + USED(mp), min - USED(mp));
  ------------------
  |  |  328|  71.2k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|  71.2k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
 3081|  71.2k|        }
 3082|       |
 3083|       |        /* Increase precision; should already be 0-filled */
 3084|  71.3k|        USED(mp) = min;
  ------------------
  |  |  328|  71.3k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|  71.3k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
 3085|  71.3k|    }
 3086|       |
 3087|   558k|    return MP_OKAY;
  ------------------
  |  |   39|   558k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
 3088|       |
 3089|   558k|} /* end s_mp_pad() */
s_mp_setz:
 3098|   688k|{
 3099|   688k|    memset(dp, 0, count * sizeof(mp_digit));
 3100|   688k|} /* end s_mp_setz() */
s_mp_copy:
 3109|   572k|{
 3110|   572k|    memcpy(dp, sp, count * sizeof(mp_digit));
 3111|   572k|} /* end s_mp_copy() */
s_mp_alloc:
 3120|   589k|{
 3121|   589k|    return calloc(nb, ni);
 3122|       |
 3123|   589k|} /* end s_mp_alloc() */
s_mp_free:
 3132|   589k|{
 3133|   589k|    if (ptr) {
  ------------------
  |  Branch (3133:9): [True: 589k, False: 0]
  ------------------
 3134|   589k|        free(ptr);
 3135|   589k|    }
 3136|   589k|} /* end s_mp_free() */
s_mp_clamp:
 3145|  1.66M|{
 3146|  1.66M|    mp_size used = MP_USED(mp);
  ------------------
  |  |  145|  1.66M|#define MP_USED(MP) ((MP)->used)
  ------------------
 3147|  1.98M|    while (used > 1 && DIGIT(mp, used - 1) == 0)
  ------------------
  |  |  331|  1.58M|#define DIGIT(MP, N) MP_DIGIT(MP, N)
  |  |  ------------------
  |  |  |  |  148|  1.58M|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  |  |  ------------------
  ------------------
  |  Branch (3147:12): [True: 1.58M, False: 400k]
  |  Branch (3147:24): [True: 318k, False: 1.26M]
  ------------------
 3148|   318k|        --used;
 3149|  1.66M|    MP_USED(mp) = used;
  ------------------
  |  |  145|  1.66M|#define MP_USED(MP) ((MP)->used)
  ------------------
 3150|  1.66M|    if (used == 1 && DIGIT(mp, 0) == 0)
  ------------------
  |  |  331|   400k|#define DIGIT(MP, N) MP_DIGIT(MP, N)
  |  |  ------------------
  |  |  |  |  148|   400k|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  |  |  ------------------
  ------------------
  |  Branch (3150:9): [True: 400k, False: 1.26M]
  |  Branch (3150:22): [True: 91.4k, False: 308k]
  ------------------
 3151|  91.4k|        MP_SIGN(mp) = ZPOS;
  ------------------
  |  |  144|  91.4k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
                      MP_SIGN(mp) = ZPOS;
  ------------------
  |  |  321|  91.4k|#define ZPOS MP_ZPOS
  |  |  ------------------
  |  |  |  |   37|  91.4k|#define MP_ZPOS 0
  |  |  ------------------
  ------------------
 3152|  1.66M|} /* end s_mp_clamp() */
s_mp_exch:
 3161|   538k|{
 3162|   538k|    mp_int tmp;
 3163|   538k|    if (!a || !b) {
  ------------------
  |  Branch (3163:9): [True: 0, False: 538k]
  |  Branch (3163:15): [True: 0, False: 538k]
  ------------------
 3164|      0|        return;
 3165|      0|    }
 3166|       |
 3167|   538k|    tmp = *a;
 3168|   538k|    *a = *b;
 3169|   538k|    *b = tmp;
 3170|       |
 3171|   538k|} /* end s_mp_exch() */
s_mp_mul_2d:
 3227|   541k|{
 3228|   541k|    mp_err res;
 3229|   541k|    mp_digit dshift, rshift, mask, x, prev = 0;
 3230|   541k|    mp_digit *pa = NULL;
 3231|   541k|    int i;
 3232|       |
 3233|   541k|    ARGCHK(mp != NULL, MP_BADARG);
  ------------------
  |  |  350|   541k|#define ARGCHK(X, Y) assert(X)
  ------------------
 3234|       |
 3235|   541k|    dshift = d / MP_DIGIT_BIT;
  ------------------
  |  |  132|   541k|#define MP_DIGIT_BIT (CHAR_BIT * MP_DIGIT_SIZE)
  |  |  ------------------
  |  |  |  |  131|   541k|#define MP_DIGIT_SIZE sizeof(mp_digit)
  |  |  ------------------
  ------------------
 3236|   541k|    d %= MP_DIGIT_BIT;
  ------------------
  |  |  132|   541k|#define MP_DIGIT_BIT (CHAR_BIT * MP_DIGIT_SIZE)
  |  |  ------------------
  |  |  |  |  131|   541k|#define MP_DIGIT_SIZE sizeof(mp_digit)
  |  |  ------------------
  ------------------
 3237|       |    /* mp_digit >> rshift is undefined behavior for rshift >= MP_DIGIT_BIT */
 3238|       |    /* mod and corresponding mask logic avoid that when d = 0 */
 3239|   541k|    rshift = MP_DIGIT_BIT - d;
  ------------------
  |  |  132|   541k|#define MP_DIGIT_BIT (CHAR_BIT * MP_DIGIT_SIZE)
  |  |  ------------------
  |  |  |  |  131|   541k|#define MP_DIGIT_SIZE sizeof(mp_digit)
  |  |  ------------------
  ------------------
 3240|   541k|    rshift %= MP_DIGIT_BIT;
  ------------------
  |  |  132|   541k|#define MP_DIGIT_BIT (CHAR_BIT * MP_DIGIT_SIZE)
  |  |  ------------------
  |  |  |  |  131|   541k|#define MP_DIGIT_SIZE sizeof(mp_digit)
  |  |  ------------------
  ------------------
 3241|       |    /* mask = (2**d - 1) * 2**(w-d) mod 2**w */
 3242|   541k|    mask = (DIGIT_MAX << rshift) + 1;
  ------------------
  |  |  322|   541k|#define DIGIT_MAX MP_DIGIT_MAX
  |  |  ------------------
  |  |  |  |   74|   541k|#define MP_DIGIT_MAX ULONG_MAX
  |  |  ------------------
  ------------------
 3243|   541k|    mask &= DIGIT_MAX - 1;
  ------------------
  |  |  322|   541k|#define DIGIT_MAX MP_DIGIT_MAX
  |  |  ------------------
  |  |  |  |   74|   541k|#define MP_DIGIT_MAX ULONG_MAX
  |  |  ------------------
  ------------------
 3244|       |    /* bits to be shifted out of the top word */
 3245|   541k|    x = MP_DIGIT(mp, MP_USED(mp) - 1) & mask;
  ------------------
  |  |  148|   541k|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  ------------------
 3246|       |
 3247|   541k|    if (MP_OKAY != (res = s_mp_pad(mp, MP_USED(mp) + dshift + (x != 0))))
  ------------------
  |  |   39|   541k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
                  if (MP_OKAY != (res = s_mp_pad(mp, MP_USED(mp) + dshift + (x != 0))))
  ------------------
  |  |  145|   541k|#define MP_USED(MP) ((MP)->used)
  ------------------
  |  Branch (3247:9): [True: 0, False: 541k]
  ------------------
 3248|      0|        return res;
 3249|       |
 3250|   541k|    if (dshift && MP_OKAY != (res = s_mp_lshd(mp, dshift)))
  ------------------
  |  |   39|      0|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (3250:9): [True: 0, False: 541k]
  |  Branch (3250:19): [True: 0, False: 0]
  ------------------
 3251|      0|        return res;
 3252|       |
 3253|   541k|    pa = MP_DIGITS(mp) + dshift;
  ------------------
  |  |  147|   541k|#define MP_DIGITS(MP) ((MP)->dp)
  ------------------
 3254|       |
 3255|  8.67M|    for (i = MP_USED(mp) - dshift; i > 0; i--) {
  ------------------
  |  |  145|   541k|#define MP_USED(MP) ((MP)->used)
  ------------------
  |  Branch (3255:36): [True: 8.13M, False: 541k]
  ------------------
 3256|  8.13M|        x = *pa;
 3257|  8.13M|        *pa++ = (x << d) | prev;
 3258|  8.13M|        prev = (x & mask) >> rshift;
 3259|  8.13M|    }
 3260|       |
 3261|   541k|    s_mp_clamp(mp);
 3262|   541k|    return MP_OKAY;
  ------------------
  |  |   39|   541k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
 3263|   541k|} /* end s_mp_mul_2d() */
s_mp_rshd:
 3275|  1.07M|{
 3276|  1.07M|    mp_size ix;
 3277|  1.07M|    mp_digit *src, *dst;
 3278|       |
 3279|  1.07M|    if (p == 0)
  ------------------
  |  Branch (3279:9): [True: 1.07M, False: 234]
  ------------------
 3280|  1.07M|        return;
 3281|       |
 3282|       |    /* Shortcut when all digits are to be shifted off */
 3283|    234|    if (p >= USED(mp)) {
  ------------------
  |  |  328|    234|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|    234|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  |  Branch (3283:9): [True: 0, False: 234]
  ------------------
 3284|      0|        s_mp_setz(DIGITS(mp), ALLOC(mp));
  ------------------
  |  |  330|      0|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|      0|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
                      s_mp_setz(DIGITS(mp), ALLOC(mp));
  ------------------
  |  |  329|      0|#define ALLOC(MP) MP_ALLOC(MP)
  |  |  ------------------
  |  |  |  |  146|      0|#define MP_ALLOC(MP) ((MP)->alloc)
  |  |  ------------------
  ------------------
 3285|      0|        USED(mp) = 1;
  ------------------
  |  |  328|      0|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|      0|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
 3286|      0|        SIGN(mp) = ZPOS;
  ------------------
  |  |  327|      0|#define SIGN(MP) MP_SIGN(MP)
  |  |  ------------------
  |  |  |  |  144|      0|#define MP_SIGN(MP) ((MP)->sign)
  |  |  ------------------
  ------------------
                      SIGN(mp) = ZPOS;
  ------------------
  |  |  321|      0|#define ZPOS MP_ZPOS
  |  |  ------------------
  |  |  |  |   37|      0|#define MP_ZPOS 0
  |  |  ------------------
  ------------------
 3287|      0|        return;
 3288|      0|    }
 3289|       |
 3290|       |    /* Shift all the significant figures over as needed */
 3291|    234|    dst = MP_DIGITS(mp);
  ------------------
  |  |  147|    234|#define MP_DIGITS(MP) ((MP)->dp)
  ------------------
 3292|    234|    src = dst + p;
 3293|  1.62k|    for (ix = USED(mp) - p; ix > 0; ix--)
  ------------------
  |  |  328|    234|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|    234|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  |  Branch (3293:29): [True: 1.38k, False: 234]
  ------------------
 3294|  1.38k|        *dst++ = *src++;
 3295|       |
 3296|    234|    MP_USED(mp) -= p;
  ------------------
  |  |  145|    234|#define MP_USED(MP) ((MP)->used)
  ------------------
 3297|       |    /* Fill the top digits with zeroes */
 3298|  1.00k|    while (p-- > 0)
  ------------------
  |  Branch (3298:12): [True: 775, False: 234]
  ------------------
 3299|    775|        *dst++ = 0;
 3300|       |
 3301|    234|} /* end s_mp_rshd() */
s_mp_mod_2d:
 3364|    412|{
 3365|    412|    mp_size ndig = (d / DIGIT_BIT), nbit = (d % DIGIT_BIT);
  ------------------
  |  |  323|    412|#define DIGIT_BIT MP_DIGIT_BIT
  |  |  ------------------
  |  |  |  |  132|    412|#define MP_DIGIT_BIT (CHAR_BIT * MP_DIGIT_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  131|    412|#define MP_DIGIT_SIZE sizeof(mp_digit)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  mp_size ndig = (d / DIGIT_BIT), nbit = (d % DIGIT_BIT);
  ------------------
  |  |  323|    412|#define DIGIT_BIT MP_DIGIT_BIT
  |  |  ------------------
  |  |  |  |  132|    412|#define MP_DIGIT_BIT (CHAR_BIT * MP_DIGIT_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  131|    412|#define MP_DIGIT_SIZE sizeof(mp_digit)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3366|    412|    mp_size ix;
 3367|    412|    mp_digit dmask;
 3368|       |
 3369|    412|    if (ndig >= USED(mp))
  ------------------
  |  |  328|    412|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|    412|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  |  Branch (3369:9): [True: 0, False: 412]
  ------------------
 3370|      0|        return;
 3371|       |
 3372|       |    /* Flush all the bits above 2^d in its digit */
 3373|    412|    dmask = ((mp_digit)1 << nbit) - 1;
 3374|    412|    DIGIT(mp, ndig) &= dmask;
  ------------------
  |  |  331|    412|#define DIGIT(MP, N) MP_DIGIT(MP, N)
  |  |  ------------------
  |  |  |  |  148|    412|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  |  |  ------------------
  ------------------
 3375|       |
 3376|       |    /* Flush all digits above the one with 2^d in it */
 3377|  2.05k|    for (ix = ndig + 1; ix < USED(mp); ix++)
  ------------------
  |  |  328|  2.05k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|  2.05k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  |  Branch (3377:25): [True: 1.64k, False: 412]
  ------------------
 3378|  1.64k|        DIGIT(mp, ix) = 0;
  ------------------
  |  |  331|  1.64k|#define DIGIT(MP, N) MP_DIGIT(MP, N)
  |  |  ------------------
  |  |  |  |  148|  1.64k|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  |  |  ------------------
  ------------------
 3379|       |
 3380|    412|    s_mp_clamp(mp);
 3381|       |
 3382|    412|} /* end s_mp_mod_2d() */
s_mp_div_2d:
 3395|  1.07M|{
 3396|  1.07M|    int ix;
 3397|  1.07M|    mp_digit save, next, mask, lshift;
 3398|       |
 3399|  1.07M|    s_mp_rshd(mp, d / DIGIT_BIT);
  ------------------
  |  |  323|  1.07M|#define DIGIT_BIT MP_DIGIT_BIT
  |  |  ------------------
  |  |  |  |  132|  1.07M|#define MP_DIGIT_BIT (CHAR_BIT * MP_DIGIT_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  131|  1.07M|#define MP_DIGIT_SIZE sizeof(mp_digit)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3400|  1.07M|    d %= DIGIT_BIT;
  ------------------
  |  |  323|  1.07M|#define DIGIT_BIT MP_DIGIT_BIT
  |  |  ------------------
  |  |  |  |  132|  1.07M|#define MP_DIGIT_BIT (CHAR_BIT * MP_DIGIT_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  131|  1.07M|#define MP_DIGIT_SIZE sizeof(mp_digit)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3401|       |    /* mp_digit << lshift is undefined behavior for lshift >= MP_DIGIT_BIT */
 3402|       |    /* mod and corresponding mask logic avoid that when d = 0 */
 3403|  1.07M|    lshift = DIGIT_BIT - d;
  ------------------
  |  |  323|  1.07M|#define DIGIT_BIT MP_DIGIT_BIT
  |  |  ------------------
  |  |  |  |  132|  1.07M|#define MP_DIGIT_BIT (CHAR_BIT * MP_DIGIT_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  131|  1.07M|#define MP_DIGIT_SIZE sizeof(mp_digit)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3404|  1.07M|    lshift %= DIGIT_BIT;
  ------------------
  |  |  323|  1.07M|#define DIGIT_BIT MP_DIGIT_BIT
  |  |  ------------------
  |  |  |  |  132|  1.07M|#define MP_DIGIT_BIT (CHAR_BIT * MP_DIGIT_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  131|  1.07M|#define MP_DIGIT_SIZE sizeof(mp_digit)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3405|  1.07M|    mask = ((mp_digit)1 << d) - 1;
 3406|  1.07M|    save = 0;
 3407|  18.3M|    for (ix = USED(mp) - 1; ix >= 0; ix--) {
  ------------------
  |  |  328|  1.07M|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|  1.07M|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  |  Branch (3407:29): [True: 17.3M, False: 1.07M]
  ------------------
 3408|  17.3M|        next = DIGIT(mp, ix) & mask;
  ------------------
  |  |  331|  17.3M|#define DIGIT(MP, N) MP_DIGIT(MP, N)
  |  |  ------------------
  |  |  |  |  148|  17.3M|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  |  |  ------------------
  ------------------
 3409|  17.3M|        DIGIT(mp, ix) = (save << lshift) | (DIGIT(mp, ix) >> d);
  ------------------
  |  |  331|  17.3M|#define DIGIT(MP, N) MP_DIGIT(MP, N)
  |  |  ------------------
  |  |  |  |  148|  17.3M|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  |  |  ------------------
  ------------------
                      DIGIT(mp, ix) = (save << lshift) | (DIGIT(mp, ix) >> d);
  ------------------
  |  |  331|  17.3M|#define DIGIT(MP, N) MP_DIGIT(MP, N)
  |  |  ------------------
  |  |  |  |  148|  17.3M|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  |  |  ------------------
  ------------------
 3410|  17.3M|        save = next;
 3411|  17.3M|    }
 3412|  1.07M|    s_mp_clamp(mp);
 3413|       |
 3414|  1.07M|} /* end s_mp_div_2d() */
s_mp_norm:
 3433|  3.68k|{
 3434|  3.68k|    mp_digit d;
 3435|  3.68k|    mp_digit mask;
 3436|  3.68k|    mp_digit b_msd;
 3437|  3.68k|    mp_err res = MP_OKAY;
  ------------------
  |  |   39|  3.68k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
 3438|       |
 3439|  3.68k|    ARGCHK(a != NULL && b != NULL && pd != NULL, MP_BADARG);
  ------------------
  |  |  350|  3.68k|#define ARGCHK(X, Y) assert(X)
  ------------------
 3440|       |
 3441|  3.68k|    d = 0;
 3442|  3.68k|    mask = DIGIT_MAX & ~(DIGIT_MAX >> 1); /* mask is msb of digit */
  ------------------
  |  |  322|  3.68k|#define DIGIT_MAX MP_DIGIT_MAX
  |  |  ------------------
  |  |  |  |   74|  3.68k|#define MP_DIGIT_MAX ULONG_MAX
  |  |  ------------------
  ------------------
                  mask = DIGIT_MAX & ~(DIGIT_MAX >> 1); /* mask is msb of digit */
  ------------------
  |  |  322|  3.68k|#define DIGIT_MAX MP_DIGIT_MAX
  |  |  ------------------
  |  |  |  |   74|  3.68k|#define MP_DIGIT_MAX ULONG_MAX
  |  |  ------------------
  ------------------
 3443|  3.68k|    b_msd = DIGIT(b, USED(b) - 1);
  ------------------
  |  |  331|  3.68k|#define DIGIT(MP, N) MP_DIGIT(MP, N)
  |  |  ------------------
  |  |  |  |  148|  3.68k|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  |  |  ------------------
  ------------------
 3444|   148k|    while (!(b_msd & mask)) {
  ------------------
  |  Branch (3444:12): [True: 144k, False: 3.68k]
  ------------------
 3445|   144k|        b_msd <<= 1;
 3446|   144k|        ++d;
 3447|   144k|    }
 3448|       |
 3449|  3.68k|    if (d) {
  ------------------
  |  Branch (3449:9): [True: 3.23k, False: 444]
  ------------------
 3450|  3.23k|        MP_CHECKOK(s_mp_mul_2d(a, d));
  ------------------
  |  |  314|  3.23k|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|  3.23k|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 3.23k]
  |  |  ------------------
  |  |  315|  3.23k|    goto CLEANUP
  ------------------
 3451|  3.23k|        MP_CHECKOK(s_mp_mul_2d(b, d));
  ------------------
  |  |  314|  3.23k|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|  3.23k|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 3.23k]
  |  |  ------------------
  |  |  315|  3.23k|    goto CLEANUP
  ------------------
 3452|  3.23k|    }
 3453|       |
 3454|  3.68k|    *pd = d;
 3455|  3.68k|CLEANUP:
 3456|  3.68k|    return res;
 3457|       |
 3458|  3.68k|} /* end s_mp_norm() */
s_mp_add_d:
 3471|   534k|{
 3472|       |#if !defined(MP_NO_MP_WORD) && !defined(MP_NO_ADD_WORD)
 3473|       |    mp_word w, k = 0;
 3474|       |    mp_size ix = 1;
 3475|       |
 3476|       |    w = (mp_word)DIGIT(mp, 0) + d;
 3477|       |    DIGIT(mp, 0) = ACCUM(w);
 3478|       |    k = CARRYOUT(w);
 3479|       |
 3480|       |    while (ix < USED(mp) && k) {
 3481|       |        w = (mp_word)DIGIT(mp, ix) + k;
 3482|       |        DIGIT(mp, ix) = ACCUM(w);
 3483|       |        k = CARRYOUT(w);
 3484|       |        ++ix;
 3485|       |    }
 3486|       |
 3487|       |    if (k != 0) {
 3488|       |        mp_err res;
 3489|       |
 3490|       |        if ((res = s_mp_pad(mp, USED(mp) + 1)) != MP_OKAY)
 3491|       |            return res;
 3492|       |
 3493|       |        DIGIT(mp, ix) = (mp_digit)k;
 3494|       |    }
 3495|       |
 3496|       |    return MP_OKAY;
 3497|       |#else
 3498|   534k|    mp_digit *pmp = MP_DIGITS(mp);
  ------------------
  |  |  147|   534k|#define MP_DIGITS(MP) ((MP)->dp)
  ------------------
 3499|   534k|    mp_digit sum, mp_i, carry = 0;
 3500|   534k|    mp_err res = MP_OKAY;
  ------------------
  |  |   39|   534k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
 3501|   534k|    int used = (int)MP_USED(mp);
  ------------------
  |  |  145|   534k|#define MP_USED(MP) ((MP)->used)
  ------------------
 3502|       |
 3503|   534k|    mp_i = *pmp;
 3504|   534k|    *pmp++ = sum = d + mp_i;
 3505|   534k|    carry = (sum < d);
 3506|   534k|    while (carry && --used > 0) {
  ------------------
  |  Branch (3506:12): [True: 0, False: 534k]
  |  Branch (3506:21): [True: 0, False: 0]
  ------------------
 3507|      0|        mp_i = *pmp;
 3508|      0|        *pmp++ = sum = carry + mp_i;
 3509|      0|        carry = !sum;
 3510|      0|    }
 3511|   534k|    if (carry && !used) {
  ------------------
  |  Branch (3511:9): [True: 0, False: 534k]
  |  Branch (3511:18): [True: 0, False: 0]
  ------------------
 3512|       |        /* mp is growing */
 3513|      0|        used = MP_USED(mp);
  ------------------
  |  |  145|      0|#define MP_USED(MP) ((MP)->used)
  ------------------
 3514|      0|        MP_CHECKOK(s_mp_pad(mp, used + 1));
  ------------------
  |  |  314|      0|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|      0|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 0]
  |  |  ------------------
  |  |  315|      0|    goto CLEANUP
  ------------------
 3515|      0|        MP_DIGIT(mp, used) = carry;
  ------------------
  |  |  148|      0|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  ------------------
 3516|      0|    }
 3517|   534k|CLEANUP:
 3518|   534k|    return res;
 3519|   534k|#endif
 3520|   534k|} /* end s_mp_add_d() */
s_mp_mul_d:
 3580|   546k|{
 3581|   546k|    mp_err res;
 3582|   546k|    mp_size used;
 3583|   546k|    int pow;
 3584|       |
 3585|   546k|    if (!d) {
  ------------------
  |  Branch (3585:9): [True: 0, False: 546k]
  ------------------
 3586|      0|        mp_zero(a);
 3587|      0|        return MP_OKAY;
  ------------------
  |  |   39|      0|#define MP_OKAY 0    /* no error, all is well */
  ------------------
 3588|      0|    }
 3589|   546k|    if (d == 1)
  ------------------
  |  Branch (3589:9): [True: 1.08k, False: 545k]
  ------------------
 3590|  1.08k|        return MP_OKAY;
  ------------------
  |  |   39|  1.08k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
 3591|   545k|    if (0 <= (pow = s_mp_ispow2d(d))) {
  ------------------
  |  Branch (3591:9): [True: 534k, False: 10.6k]
  ------------------
 3592|   534k|        return s_mp_mul_2d(a, (mp_digit)pow);
 3593|   534k|    }
 3594|       |
 3595|  10.6k|    used = MP_USED(a);
  ------------------
  |  |  145|  10.6k|#define MP_USED(MP) ((MP)->used)
  ------------------
 3596|  10.6k|    MP_CHECKOK(s_mp_pad(a, used + 1));
  ------------------
  |  |  314|  10.6k|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|  10.6k|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 10.6k]
  |  |  ------------------
  |  |  315|  10.6k|    goto CLEANUP
  ------------------
 3597|       |
 3598|  10.6k|    s_mpv_mul_d(MP_DIGITS(a), used, d, MP_DIGITS(a));
  ------------------
  |  |  189|  10.6k|    ((mp_digit *)c)[a_len] = s_mpv_mul_set_vec64(c, a, a_len, b)
  ------------------
 3599|       |
 3600|  10.6k|    s_mp_clamp(a);
 3601|       |
 3602|  10.6k|CLEANUP:
 3603|  10.6k|    return res;
 3604|       |
 3605|  10.6k|} /* end s_mp_mul_d() */
s_mp_sub:
 4001|  16.4k|{
 4002|  16.4k|    mp_digit *pa, *pb, *limit;
 4003|       |#if !defined(MP_NO_MP_WORD) && !defined(MP_NO_SUB_WORD)
 4004|       |    mp_sword w = 0;
 4005|       |#else
 4006|  16.4k|    mp_digit d, diff, borrow = 0;
 4007|  16.4k|#endif
 4008|       |
 4009|       |    /*
 4010|       |    Subtract and propagate borrow.  Up to the precision of b, this
 4011|       |    accounts for the digits of b; after that, we just make sure the
 4012|       |    carries get to the right place.  This saves having to pad b out to
 4013|       |    the precision of a just to make the loops work right...
 4014|       |   */
 4015|  16.4k|    pa = MP_DIGITS(a);
  ------------------
  |  |  147|  16.4k|#define MP_DIGITS(MP) ((MP)->dp)
  ------------------
 4016|  16.4k|    pb = MP_DIGITS(b);
  ------------------
  |  |  147|  16.4k|#define MP_DIGITS(MP) ((MP)->dp)
  ------------------
 4017|  16.4k|    limit = pb + MP_USED(b);
  ------------------
  |  |  145|  16.4k|#define MP_USED(MP) ((MP)->used)
  ------------------
 4018|   180k|    while (pb < limit) {
  ------------------
  |  Branch (4018:12): [True: 164k, False: 16.4k]
  ------------------
 4019|       |#if !defined(MP_NO_MP_WORD) && !defined(MP_NO_SUB_WORD)
 4020|       |        w = w + *pa - *pb++;
 4021|       |        *pa++ = ACCUM(w);
 4022|       |        w >>= MP_DIGIT_BIT;
 4023|       |#else
 4024|   164k|        d = *pa;
 4025|   164k|        diff = d - *pb++;
 4026|   164k|        d = (diff > d); /* detect borrow */
 4027|   164k|        if (borrow && --diff == MP_DIGIT_MAX)
  ------------------
  |  |   74|  72.7k|#define MP_DIGIT_MAX ULONG_MAX
  ------------------
  |  Branch (4027:13): [True: 72.7k, False: 91.6k]
  |  Branch (4027:23): [True: 15.5k, False: 57.1k]
  ------------------
 4028|  15.5k|            ++d;
 4029|   164k|        *pa++ = diff;
 4030|   164k|        borrow = d;
 4031|   164k|#endif
 4032|   164k|    }
 4033|  16.4k|    limit = MP_DIGITS(a) + MP_USED(a);
  ------------------
  |  |  147|  16.4k|#define MP_DIGITS(MP) ((MP)->dp)
  ------------------
                  limit = MP_DIGITS(a) + MP_USED(a);
  ------------------
  |  |  145|  16.4k|#define MP_USED(MP) ((MP)->used)
  ------------------
 4034|       |#if !defined(MP_NO_MP_WORD) && !defined(MP_NO_SUB_WORD)
 4035|       |    while (w && pa < limit) {
 4036|       |        w = w + *pa;
 4037|       |        *pa++ = ACCUM(w);
 4038|       |        w >>= MP_DIGIT_BIT;
 4039|       |    }
 4040|       |#else
 4041|  19.4k|    while (borrow && pa < limit) {
  ------------------
  |  Branch (4041:12): [True: 2.99k, False: 16.4k]
  |  Branch (4041:22): [True: 2.99k, False: 0]
  ------------------
 4042|  2.99k|        d = *pa;
 4043|  2.99k|        *pa++ = diff = d - borrow;
 4044|  2.99k|        borrow = (diff > d);
 4045|  2.99k|    }
 4046|  16.4k|#endif
 4047|       |
 4048|       |    /* Clobber any leading zeroes we created    */
 4049|  16.4k|    s_mp_clamp(a);
 4050|       |
 4051|       |/*
 4052|       |     If there was a borrow out, then |b| > |a| in violation
 4053|       |     of our input invariant.  We've already done the work,
 4054|       |     but we'll at least complain about it...
 4055|       |   */
 4056|       |#if !defined(MP_NO_MP_WORD) && !defined(MP_NO_SUB_WORD)
 4057|       |    return w ? MP_RANGE : MP_OKAY;
 4058|       |#else
 4059|  16.4k|    return borrow ? MP_RANGE : MP_OKAY;
  ------------------
  |  |   43|      0|#define MP_RANGE -3  /* argument out of range */
  ------------------
                  return borrow ? MP_RANGE : MP_OKAY;
  ------------------
  |  |   39|  16.4k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (4059:12): [True: 0, False: 16.4k]
  ------------------
 4060|  16.4k|#endif
 4061|  16.4k|} /* end s_mp_sub() */
s_mp_sub_3arg:
 4068|  6.93k|{
 4069|  6.93k|    mp_digit *pa, *pb, *pc;
 4070|       |#if !defined(MP_NO_MP_WORD) && !defined(MP_NO_SUB_WORD)
 4071|       |    mp_sword w = 0;
 4072|       |#else
 4073|  6.93k|    mp_digit d, diff, borrow = 0;
 4074|  6.93k|#endif
 4075|  6.93k|    int ix, limit;
 4076|  6.93k|    mp_err res;
 4077|       |
 4078|  6.93k|    MP_SIGN(c) = MP_SIGN(a);
  ------------------
  |  |  144|  6.93k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
                  MP_SIGN(c) = MP_SIGN(a);
  ------------------
  |  |  144|  6.93k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
 4079|       |
 4080|       |    /* Make sure a has enough precision for the output value */
 4081|  6.93k|    if (MP_OKAY != (res = s_mp_pad(c, MP_USED(a))))
  ------------------
  |  |   39|  6.93k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
                  if (MP_OKAY != (res = s_mp_pad(c, MP_USED(a))))
  ------------------
  |  |  145|  6.93k|#define MP_USED(MP) ((MP)->used)
  ------------------
  |  Branch (4081:9): [True: 0, False: 6.93k]
  ------------------
 4082|      0|        return res;
 4083|       |
 4084|       |    /*
 4085|       |    Subtract and propagate borrow.  Up to the precision of b, this
 4086|       |    accounts for the digits of b; after that, we just make sure the
 4087|       |    carries get to the right place.  This saves having to pad b out to
 4088|       |    the precision of a just to make the loops work right...
 4089|       |   */
 4090|  6.93k|    pa = MP_DIGITS(a);
  ------------------
  |  |  147|  6.93k|#define MP_DIGITS(MP) ((MP)->dp)
  ------------------
 4091|  6.93k|    pb = MP_DIGITS(b);
  ------------------
  |  |  147|  6.93k|#define MP_DIGITS(MP) ((MP)->dp)
  ------------------
 4092|  6.93k|    pc = MP_DIGITS(c);
  ------------------
  |  |  147|  6.93k|#define MP_DIGITS(MP) ((MP)->dp)
  ------------------
 4093|  6.93k|    limit = MP_USED(b);
  ------------------
  |  |  145|  6.93k|#define MP_USED(MP) ((MP)->used)
  ------------------
 4094|  39.5k|    for (ix = 0; ix < limit; ++ix) {
  ------------------
  |  Branch (4094:18): [True: 32.5k, False: 6.93k]
  ------------------
 4095|       |#if !defined(MP_NO_MP_WORD) && !defined(MP_NO_SUB_WORD)
 4096|       |        w = w + *pa++ - *pb++;
 4097|       |        *pc++ = ACCUM(w);
 4098|       |        w >>= MP_DIGIT_BIT;
 4099|       |#else
 4100|  32.5k|        d = *pa++;
 4101|  32.5k|        diff = d - *pb++;
 4102|  32.5k|        d = (diff > d);
 4103|  32.5k|        if (borrow && --diff == MP_DIGIT_MAX)
  ------------------
  |  |   74|  11.6k|#define MP_DIGIT_MAX ULONG_MAX
  ------------------
  |  Branch (4103:13): [True: 11.6k, False: 20.9k]
  |  Branch (4103:23): [True: 4.25k, False: 7.37k]
  ------------------
 4104|  4.25k|            ++d;
 4105|  32.5k|        *pc++ = diff;
 4106|  32.5k|        borrow = d;
 4107|  32.5k|#endif
 4108|  32.5k|    }
 4109|  10.3k|    for (limit = MP_USED(a); ix < limit; ++ix) {
  ------------------
  |  |  145|  6.93k|#define MP_USED(MP) ((MP)->used)
  ------------------
  |  Branch (4109:30): [True: 3.37k, False: 6.93k]
  ------------------
 4110|       |#if !defined(MP_NO_MP_WORD) && !defined(MP_NO_SUB_WORD)
 4111|       |        w = w + *pa++;
 4112|       |        *pc++ = ACCUM(w);
 4113|       |        w >>= MP_DIGIT_BIT;
 4114|       |#else
 4115|  3.37k|        d = *pa++;
 4116|  3.37k|        *pc++ = diff = d - borrow;
 4117|  3.37k|        borrow = (diff > d);
 4118|  3.37k|#endif
 4119|  3.37k|    }
 4120|       |
 4121|       |    /* Clobber any leading zeroes we created    */
 4122|  6.93k|    MP_USED(c) = ix;
  ------------------
  |  |  145|  6.93k|#define MP_USED(MP) ((MP)->used)
  ------------------
 4123|  6.93k|    s_mp_clamp(c);
 4124|       |
 4125|       |/*
 4126|       |     If there was a borrow out, then |b| > |a| in violation
 4127|       |     of our input invariant.  We've already done the work,
 4128|       |     but we'll at least complain about it...
 4129|       |   */
 4130|       |#if !defined(MP_NO_MP_WORD) && !defined(MP_NO_SUB_WORD)
 4131|       |    return w ? MP_RANGE : MP_OKAY;
 4132|       |#else
 4133|  6.93k|    return borrow ? MP_RANGE : MP_OKAY;
  ------------------
  |  |   43|      0|#define MP_RANGE -3  /* argument out of range */
  ------------------
                  return borrow ? MP_RANGE : MP_OKAY;
  ------------------
  |  |   39|  6.93k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
  |  Branch (4133:12): [True: 0, False: 6.93k]
  ------------------
 4134|  6.93k|#endif
 4135|  6.93k|}
s_mpv_div_2dx1d:
 4446|  10.4k|{
 4447|  10.4k|    mp_digit d1, d0, q1, q0;
 4448|  10.4k|    mp_digit r1, r0, m;
 4449|       |
 4450|  10.4k|    d1 = divisor >> MP_HALF_DIGIT_BIT;
  ------------------
  |  |  136|  10.4k|#define MP_HALF_DIGIT_BIT (MP_DIGIT_BIT / 2)
  |  |  ------------------
  |  |  |  |  132|  10.4k|#define MP_DIGIT_BIT (CHAR_BIT * MP_DIGIT_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  131|  10.4k|#define MP_DIGIT_SIZE sizeof(mp_digit)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4451|  10.4k|    d0 = divisor & MP_HALF_DIGIT_MAX;
  ------------------
  |  |   76|  10.4k|#define MP_HALF_DIGIT_MAX UINT_MAX
  ------------------
 4452|  10.4k|    r1 = Nhi % d1;
 4453|  10.4k|    q1 = Nhi / d1;
 4454|  10.4k|    m = q1 * d0;
 4455|  10.4k|    r1 = (r1 << MP_HALF_DIGIT_BIT) | (Nlo >> MP_HALF_DIGIT_BIT);
  ------------------
  |  |  136|  10.4k|#define MP_HALF_DIGIT_BIT (MP_DIGIT_BIT / 2)
  |  |  ------------------
  |  |  |  |  132|  10.4k|#define MP_DIGIT_BIT (CHAR_BIT * MP_DIGIT_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  131|  10.4k|#define MP_DIGIT_SIZE sizeof(mp_digit)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  r1 = (r1 << MP_HALF_DIGIT_BIT) | (Nlo >> MP_HALF_DIGIT_BIT);
  ------------------
  |  |  136|  10.4k|#define MP_HALF_DIGIT_BIT (MP_DIGIT_BIT / 2)
  |  |  ------------------
  |  |  |  |  132|  10.4k|#define MP_DIGIT_BIT (CHAR_BIT * MP_DIGIT_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  131|  10.4k|#define MP_DIGIT_SIZE sizeof(mp_digit)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4456|  10.4k|    if (r1 < m) {
  ------------------
  |  Branch (4456:9): [True: 3.11k, False: 7.37k]
  ------------------
 4457|  3.11k|        q1--, r1 += divisor;
 4458|  3.11k|        if (r1 >= divisor && r1 < m) {
  ------------------
  |  Branch (4458:13): [True: 1.67k, False: 1.44k]
  |  Branch (4458:30): [True: 732, False: 946]
  ------------------
 4459|    732|            q1--, r1 += divisor;
 4460|    732|        }
 4461|  3.11k|    }
 4462|  10.4k|    r1 -= m;
 4463|  10.4k|    r0 = r1 % d1;
 4464|  10.4k|    q0 = r1 / d1;
 4465|  10.4k|    m = q0 * d0;
 4466|  10.4k|    r0 = (r0 << MP_HALF_DIGIT_BIT) | (Nlo & MP_HALF_DIGIT_MAX);
  ------------------
  |  |  136|  10.4k|#define MP_HALF_DIGIT_BIT (MP_DIGIT_BIT / 2)
  |  |  ------------------
  |  |  |  |  132|  10.4k|#define MP_DIGIT_BIT (CHAR_BIT * MP_DIGIT_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  131|  10.4k|#define MP_DIGIT_SIZE sizeof(mp_digit)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                  r0 = (r0 << MP_HALF_DIGIT_BIT) | (Nlo & MP_HALF_DIGIT_MAX);
  ------------------
  |  |   76|  10.4k|#define MP_HALF_DIGIT_MAX UINT_MAX
  ------------------
 4467|  10.4k|    if (r0 < m) {
  ------------------
  |  Branch (4467:9): [True: 3.36k, False: 7.12k]
  ------------------
 4468|  3.36k|        q0--, r0 += divisor;
 4469|  3.36k|        if (r0 >= divisor && r0 < m) {
  ------------------
  |  Branch (4469:13): [True: 1.73k, False: 1.62k]
  |  Branch (4469:30): [True: 639, False: 1.09k]
  ------------------
 4470|    639|            q0--, r0 += divisor;
 4471|    639|        }
 4472|  3.36k|    }
 4473|  10.4k|    if (qp)
  ------------------
  |  Branch (4473:9): [True: 10.4k, False: 0]
  ------------------
 4474|  10.4k|        *qp = (q1 << MP_HALF_DIGIT_BIT) | q0;
  ------------------
  |  |  136|  10.4k|#define MP_HALF_DIGIT_BIT (MP_DIGIT_BIT / 2)
  |  |  ------------------
  |  |  |  |  132|  10.4k|#define MP_DIGIT_BIT (CHAR_BIT * MP_DIGIT_SIZE)
  |  |  |  |  ------------------
  |  |  |  |  |  |  131|  10.4k|#define MP_DIGIT_SIZE sizeof(mp_digit)
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4475|  10.4k|    if (rp)
  ------------------
  |  Branch (4475:9): [True: 10.4k, False: 0]
  ------------------
 4476|  10.4k|        *rp = r0 - m;
 4477|  10.4k|    return MP_OKAY;
  ------------------
  |  |   39|  10.4k|#define MP_OKAY 0    /* no error, all is well */
  ------------------
 4478|  10.4k|}
s_mp_div:
 4515|  4.09k|{
 4516|  4.09k|    mp_int part, t;
 4517|  4.09k|    mp_digit q_msd;
 4518|  4.09k|    mp_err res;
 4519|  4.09k|    mp_digit d;
 4520|  4.09k|    mp_digit div_msd;
 4521|  4.09k|    int ix;
 4522|       |
 4523|  4.09k|    if (mp_cmp_z(div) == 0)
  ------------------
  |  Branch (4523:9): [True: 0, False: 4.09k]
  ------------------
 4524|      0|        return MP_RANGE;
  ------------------
  |  |   43|      0|#define MP_RANGE -3  /* argument out of range */
  ------------------
 4525|       |
 4526|  4.09k|    DIGITS(&t) = 0;
  ------------------
  |  |  330|  4.09k|#define DIGITS(MP) MP_DIGITS(MP)
  |  |  ------------------
  |  |  |  |  147|  4.09k|#define MP_DIGITS(MP) ((MP)->dp)
  |  |  ------------------
  ------------------
 4527|       |    /* Shortcut if divisor is power of two */
 4528|  4.09k|    if ((ix = s_mp_ispow2(div)) >= 0) {
  ------------------
  |  Branch (4528:9): [True: 412, False: 3.68k]
  ------------------
 4529|    412|        MP_CHECKOK(mp_copy(rem, quot));
  ------------------
  |  |  314|    412|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|    412|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 412]
  |  |  ------------------
  |  |  315|    412|    goto CLEANUP
  ------------------
 4530|    412|        s_mp_div_2d(quot, (mp_digit)ix);
 4531|    412|        s_mp_mod_2d(rem, (mp_digit)ix);
 4532|       |
 4533|    412|        return MP_OKAY;
  ------------------
  |  |   39|    412|#define MP_OKAY 0    /* no error, all is well */
  ------------------
 4534|    412|    }
 4535|       |
 4536|  3.68k|    MP_SIGN(rem) = ZPOS;
  ------------------
  |  |  144|  3.68k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
                  MP_SIGN(rem) = ZPOS;
  ------------------
  |  |  321|  3.68k|#define ZPOS MP_ZPOS
  |  |  ------------------
  |  |  |  |   37|  3.68k|#define MP_ZPOS 0
  |  |  ------------------
  ------------------
 4537|  3.68k|    MP_SIGN(div) = ZPOS;
  ------------------
  |  |  144|  3.68k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
                  MP_SIGN(div) = ZPOS;
  ------------------
  |  |  321|  3.68k|#define ZPOS MP_ZPOS
  |  |  ------------------
  |  |  |  |   37|  3.68k|#define MP_ZPOS 0
  |  |  ------------------
  ------------------
 4538|  3.68k|    MP_SIGN(&part) = ZPOS;
  ------------------
  |  |  144|  3.68k|#define MP_SIGN(MP) ((MP)->sign)
  ------------------
                  MP_SIGN(&part) = ZPOS;
  ------------------
  |  |  321|  3.68k|#define ZPOS MP_ZPOS
  |  |  ------------------
  |  |  |  |   37|  3.68k|#define MP_ZPOS 0
  |  |  ------------------
  ------------------
 4539|       |
 4540|       |    /* A working temporary for division     */
 4541|  3.68k|    MP_CHECKOK(mp_init_size(&t, MP_ALLOC(rem)));
  ------------------
  |  |  314|  3.68k|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|  3.68k|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 3.68k]
  |  |  ------------------
  |  |  315|  3.68k|    goto CLEANUP
  ------------------
 4542|       |
 4543|       |    /* Normalize to optimize guessing       */
 4544|  3.68k|    MP_CHECKOK(s_mp_norm(rem, div, &d));
  ------------------
  |  |  314|  3.68k|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|  3.68k|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 3.68k]
  |  |  ------------------
  |  |  315|  3.68k|    goto CLEANUP
  ------------------
 4545|       |
 4546|       |    /* Perform the division itself...woo!   */
 4547|  3.68k|    MP_USED(quot) = MP_ALLOC(quot);
  ------------------
  |  |  145|  3.68k|#define MP_USED(MP) ((MP)->used)
  ------------------
                  MP_USED(quot) = MP_ALLOC(quot);
  ------------------
  |  |  146|  3.68k|#define MP_ALLOC(MP) ((MP)->alloc)
  ------------------
 4548|       |
 4549|       |    /* Find a partial substring of rem which is at least div */
 4550|       |    /* If we didn't find one, we're finished dividing    */
 4551|  16.5k|    while (MP_USED(rem) > MP_USED(div) || s_mp_cmp(rem, div) >= 0) {
  ------------------
  |  |  145|  16.5k|#define MP_USED(MP) ((MP)->used)
  ------------------
                  while (MP_USED(rem) > MP_USED(div) || s_mp_cmp(rem, div) >= 0) {
  ------------------
  |  |  145|  33.0k|#define MP_USED(MP) ((MP)->used)
  ------------------
  |  Branch (4551:12): [True: 12.3k, False: 4.17k]
  |  Branch (4551:43): [True: 495, False: 3.68k]
  ------------------
 4552|  12.8k|        int i;
 4553|  12.8k|        int unusedRem;
 4554|  12.8k|        int partExtended = 0; /* set to true if we need to extend part */
 4555|       |
 4556|  12.8k|        unusedRem = MP_USED(rem) - MP_USED(div);
  ------------------
  |  |  145|  12.8k|#define MP_USED(MP) ((MP)->used)
  ------------------
                      unusedRem = MP_USED(rem) - MP_USED(div);
  ------------------
  |  |  145|  12.8k|#define MP_USED(MP) ((MP)->used)
  ------------------
 4557|  12.8k|        MP_DIGITS(&part) = MP_DIGITS(rem) + unusedRem;
  ------------------
  |  |  147|  12.8k|#define MP_DIGITS(MP) ((MP)->dp)
  ------------------
                      MP_DIGITS(&part) = MP_DIGITS(rem) + unusedRem;
  ------------------
  |  |  147|  12.8k|#define MP_DIGITS(MP) ((MP)->dp)
  ------------------
 4558|  12.8k|        MP_ALLOC(&part) = MP_ALLOC(rem) - unusedRem;
  ------------------
  |  |  146|  12.8k|#define MP_ALLOC(MP) ((MP)->alloc)
  ------------------
                      MP_ALLOC(&part) = MP_ALLOC(rem) - unusedRem;
  ------------------
  |  |  146|  12.8k|#define MP_ALLOC(MP) ((MP)->alloc)
  ------------------
 4559|  12.8k|        MP_USED(&part) = MP_USED(div);
  ------------------
  |  |  145|  12.8k|#define MP_USED(MP) ((MP)->used)
  ------------------
                      MP_USED(&part) = MP_USED(div);
  ------------------
  |  |  145|  12.8k|#define MP_USED(MP) ((MP)->used)
  ------------------
 4560|       |
 4561|       |        /* We have now truncated the part of the remainder to the same length as
 4562|       |         * the divisor. If part is smaller than div, extend part by one digit. */
 4563|  12.8k|        if (s_mp_cmp(&part, div) < 0) {
  ------------------
  |  Branch (4563:13): [True: 11.9k, False: 849]
  ------------------
 4564|  11.9k|            --unusedRem;
 4565|  11.9k|#if MP_ARGCHK == 2
 4566|  11.9k|            assert(unusedRem >= 0);
 4567|  11.9k|#endif
 4568|  11.9k|            --MP_DIGITS(&part);
  ------------------
  |  |  147|  11.9k|#define MP_DIGITS(MP) ((MP)->dp)
  ------------------
 4569|  11.9k|            ++MP_USED(&part);
  ------------------
  |  |  145|  11.9k|#define MP_USED(MP) ((MP)->used)
  ------------------
 4570|  11.9k|            ++MP_ALLOC(&part);
  ------------------
  |  |  146|  11.9k|#define MP_ALLOC(MP) ((MP)->alloc)
  ------------------
 4571|  11.9k|            partExtended = 1;
 4572|  11.9k|        }
 4573|       |
 4574|       |        /* Compute a guess for the next quotient digit       */
 4575|  12.8k|        q_msd = MP_DIGIT(&part, MP_USED(&part) - 1);
  ------------------
  |  |  148|  12.8k|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  ------------------
 4576|  12.8k|        div_msd = MP_DIGIT(div, MP_USED(div) - 1);
  ------------------
  |  |  148|  12.8k|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  ------------------
 4577|  12.8k|        if (!partExtended) {
  ------------------
  |  Branch (4577:13): [True: 849, False: 11.9k]
  ------------------
 4578|       |            /* In this case, q_msd /= div_msd is always 1. First, since div_msd is
 4579|       |             * normalized to have the high bit set, 2*div_msd > MP_DIGIT_MAX. Since
 4580|       |             * we didn't extend part, q_msd >= div_msd. Therefore we know that
 4581|       |             * div_msd <= q_msd <= MP_DIGIT_MAX < 2*div_msd. Dividing by div_msd we
 4582|       |             * get 1 <= q_msd/div_msd < 2. So q_msd /= div_msd must be 1. */
 4583|    849|            q_msd = 1;
 4584|  11.9k|        } else {
 4585|  11.9k|            if (q_msd == div_msd) {
  ------------------
  |  Branch (4585:17): [True: 1.50k, False: 10.4k]
  ------------------
 4586|  1.50k|                q_msd = MP_DIGIT_MAX;
  ------------------
  |  |   74|  1.50k|#define MP_DIGIT_MAX ULONG_MAX
  ------------------
 4587|  10.4k|            } else {
 4588|  10.4k|                mp_digit r;
 4589|  10.4k|                MP_CHECKOK(s_mpv_div_2dx1d(q_msd, MP_DIGIT(&part, MP_USED(&part) - 2),
  ------------------
  |  |  314|  10.4k|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|  10.4k|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 10.4k]
  |  |  ------------------
  |  |  315|  10.4k|    goto CLEANUP
  ------------------
 4590|  10.4k|                                           div_msd, &q_msd, &r));
 4591|  10.4k|            }
 4592|  11.9k|        }
 4593|  12.8k|#if MP_ARGCHK == 2
 4594|  12.8k|        assert(q_msd > 0); /* This case should never occur any more. */
 4595|  12.8k|#endif
 4596|  12.8k|        if (q_msd <= 0)
  ------------------
  |  Branch (4596:13): [True: 0, False: 12.8k]
  ------------------
 4597|      0|            break;
 4598|       |
 4599|       |        /* See what that multiplies out to                   */
 4600|  12.8k|        mp_copy(div, &t);
 4601|  12.8k|        MP_CHECKOK(s_mp_mul_d(&t, q_msd));
  ------------------
  |  |  314|  12.8k|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|  12.8k|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 12.8k]
  |  |  ------------------
  |  |  315|  12.8k|    goto CLEANUP
  ------------------
 4602|       |
 4603|       |        /*
 4604|       |           If it's too big, back it off.  We should not have to do this
 4605|       |           more than once, or, in rare cases, twice.  Knuth describes a
 4606|       |           method by which this could be reduced to a maximum of once, but
 4607|       |           I didn't implement that here.
 4608|       |           When using s_mpv_div_2dx1d, we may have to do this 3 times.
 4609|       |         */
 4610|  16.4k|        for (i = 4; s_mp_cmp(&t, &part) > 0 && i > 0; --i) {
  ------------------
  |  Branch (4610:21): [True: 3.56k, False: 12.8k]
  |  Branch (4610:48): [True: 3.56k, False: 0]
  ------------------
 4611|  3.56k|            --q_msd;
 4612|  3.56k|            MP_CHECKOK(s_mp_sub(&t, div)); /* t -= div */
  ------------------
  |  |  314|  3.56k|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|  3.56k|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 3.56k]
  |  |  ------------------
  |  |  315|  3.56k|    goto CLEANUP
  ------------------
 4613|  3.56k|        }
 4614|  12.8k|        if (i < 0) {
  ------------------
  |  Branch (4614:13): [True: 0, False: 12.8k]
  ------------------
 4615|      0|            res = MP_RANGE;
  ------------------
  |  |   43|      0|#define MP_RANGE -3  /* argument out of range */
  ------------------
 4616|      0|            goto CLEANUP;
 4617|      0|        }
 4618|       |
 4619|       |        /* At this point, q_msd should be the right next digit   */
 4620|  12.8k|        MP_CHECKOK(s_mp_sub(&part, &t)); /* part -= t */
  ------------------
  |  |  314|  12.8k|    if (MP_OKAY > (res = (x))) \
  |  |  ------------------
  |  |  |  |   39|  12.8k|#define MP_OKAY 0    /* no error, all is well */
  |  |  ------------------
  |  |  |  Branch (314:9): [True: 0, False: 12.8k]
  |  |  ------------------
  |  |  315|  12.8k|    goto CLEANUP
  ------------------
 4621|  12.8k|        s_mp_clamp(rem);
 4622|       |
 4623|       |        /*
 4624|       |          Include the digit in the quotient.  We allocated enough memory
 4625|       |          for any quotient we could ever possibly get, so we should not
 4626|       |          have to check for failures here
 4627|       |         */
 4628|  12.8k|        MP_DIGIT(quot, unusedRem) = q_msd;
  ------------------
  |  |  148|  12.8k|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  ------------------
 4629|  12.8k|    }
 4630|       |
 4631|       |    /* Denormalize remainder                */
 4632|  3.68k|    if (d) {
  ------------------
  |  Branch (4632:9): [True: 3.23k, False: 444]
  ------------------
 4633|  3.23k|        s_mp_div_2d(rem, d);
 4634|  3.23k|    }
 4635|       |
 4636|  3.68k|    s_mp_clamp(quot);
 4637|       |
 4638|  3.68k|CLEANUP:
 4639|  3.68k|    mp_clear(&t);
 4640|       |
 4641|  3.68k|    return res;
 4642|       |
 4643|  3.68k|} /* end s_mp_div() */
s_mp_cmp:
 4742|  49.0k|{
 4743|  49.0k|    ARGMPCHK(a != NULL && b != NULL);
  ------------------
  |  |  349|  49.0k|#define ARGMPCHK(X) assert(X)
  ------------------
 4744|       |
 4745|  49.0k|    mp_size used_a = MP_USED(a);
  ------------------
  |  |  145|  49.0k|#define MP_USED(MP) ((MP)->used)
  ------------------
 4746|  49.0k|    {
 4747|  49.0k|        mp_size used_b = MP_USED(b);
  ------------------
  |  |  145|  49.0k|#define MP_USED(MP) ((MP)->used)
  ------------------
 4748|       |
 4749|  49.0k|        if (used_a > used_b)
  ------------------
  |  Branch (4749:13): [True: 5.99k, False: 43.0k]
  ------------------
 4750|  5.99k|            goto IS_GT;
 4751|  43.0k|        if (used_a < used_b)
  ------------------
  |  Branch (4751:13): [True: 1.44k, False: 41.5k]
  ------------------
 4752|  1.44k|            goto IS_LT;
 4753|  43.0k|    }
 4754|  41.5k|    {
 4755|  41.5k|        mp_digit *pa, *pb;
 4756|  41.5k|        mp_digit da = 0, db = 0;
 4757|       |
 4758|  41.5k|#define CMP_AB(n)                     \
 4759|  41.5k|    if ((da = pa[n]) != (db = pb[n])) \
 4760|  41.5k|    goto done
 4761|       |
 4762|  41.5k|        pa = MP_DIGITS(a) + used_a;
  ------------------
  |  |  147|  41.5k|#define MP_DIGITS(MP) ((MP)->dp)
  ------------------
 4763|  41.5k|        pb = MP_DIGITS(b) + used_a;
  ------------------
  |  |  147|  41.5k|#define MP_DIGITS(MP) ((MP)->dp)
  ------------------
 4764|  42.9k|        while (used_a >= 4) {
  ------------------
  |  Branch (4764:16): [True: 19.3k, False: 23.5k]
  ------------------
 4765|  19.3k|            pa -= 4;
 4766|  19.3k|            pb -= 4;
 4767|  19.3k|            used_a -= 4;
 4768|  19.3k|            CMP_AB(3);
  ------------------
  |  | 4759|  19.3k|    if ((da = pa[n]) != (db = pb[n])) \
  |  |  ------------------
  |  |  |  Branch (4759:9): [True: 10.2k, False: 9.13k]
  |  |  ------------------
  |  | 4760|  19.3k|    goto done
  ------------------
 4769|  9.13k|            CMP_AB(2);
  ------------------
  |  | 4759|  9.13k|    if ((da = pa[n]) != (db = pb[n])) \
  |  |  ------------------
  |  |  |  Branch (4759:9): [True: 4.17k, False: 4.96k]
  |  |  ------------------
  |  | 4760|  9.13k|    goto done
  ------------------
 4770|  4.96k|            CMP_AB(1);
  ------------------
  |  | 4759|  4.96k|    if ((da = pa[n]) != (db = pb[n])) \
  |  |  ------------------
  |  |  |  Branch (4759:9): [True: 1.68k, False: 3.27k]
  |  |  ------------------
  |  | 4760|  4.96k|    goto done
  ------------------
 4771|  3.27k|            CMP_AB(0);
  ------------------
  |  | 4759|  3.27k|    if ((da = pa[n]) != (db = pb[n])) \
  |  |  ------------------
  |  |  |  Branch (4759:9): [True: 1.92k, False: 1.35k]
  |  |  ------------------
  |  | 4760|  3.27k|    goto done
  ------------------
 4772|  3.27k|        }
 4773|  29.0k|        while (used_a-- > 0 && ((da = *--pa) == (db = *--pb)))
  ------------------
  |  Branch (4773:16): [True: 28.6k, False: 348]
  |  Branch (4773:32): [True: 5.43k, False: 23.2k]
  ------------------
 4774|  5.43k|            /* do nothing */;
 4775|  41.5k|    done:
 4776|  41.5k|        if (da > db)
  ------------------
  |  Branch (4776:13): [True: 8.89k, False: 32.6k]
  ------------------
 4777|  8.89k|            goto IS_GT;
 4778|  32.6k|        if (da < db)
  ------------------
  |  Branch (4778:13): [True: 32.3k, False: 348]
  ------------------
 4779|  32.3k|            goto IS_LT;
 4780|  32.6k|    }
 4781|    348|    return MP_EQ;
  ------------------
  |  |   96|    348|#define MP_EQ 0
  ------------------
 4782|  33.7k|IS_LT:
 4783|  33.7k|    return MP_LT;
  ------------------
  |  |   95|  33.7k|#define MP_LT -1
  ------------------
 4784|  14.8k|IS_GT:
 4785|  14.8k|    return MP_GT;
  ------------------
  |  |   97|  14.8k|#define MP_GT 1
  ------------------
 4786|  32.6k|} /* end s_mp_cmp() */
s_mp_cmp_d:
 4795|   549k|{
 4796|   549k|    ARGMPCHK(a != NULL);
  ------------------
  |  |  349|   549k|#define ARGMPCHK(X) assert(X)
  ------------------
 4797|       |
 4798|   549k|    if (USED(a) > 1)
  ------------------
  |  |  328|   549k|#define USED(MP) MP_USED(MP)
  |  |  ------------------
  |  |  |  |  145|   549k|#define MP_USED(MP) ((MP)->used)
  |  |  ------------------
  ------------------
  |  Branch (4798:9): [True: 392k, False: 156k]
  ------------------
 4799|   392k|        return MP_GT;
  ------------------
  |  |   97|   392k|#define MP_GT 1
  ------------------
 4800|       |
 4801|   156k|    if (DIGIT(a, 0) < d)
  ------------------
  |  |  331|   156k|#define DIGIT(MP, N) MP_DIGIT(MP, N)
  |  |  ------------------
  |  |  |  |  148|   156k|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  |  |  ------------------
  ------------------
  |  Branch (4801:9): [True: 0, False: 156k]
  ------------------
 4802|      0|        return MP_LT;
  ------------------
  |  |   95|      0|#define MP_LT -1
  ------------------
 4803|   156k|    else if (DIGIT(a, 0) > d)
  ------------------
  |  |  331|   156k|#define DIGIT(MP, N) MP_DIGIT(MP, N)
  |  |  ------------------
  |  |  |  |  148|   156k|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  |  |  ------------------
  ------------------
  |  Branch (4803:14): [True: 95.6k, False: 61.2k]
  ------------------
 4804|  95.6k|        return MP_GT;
  ------------------
  |  |   97|  95.6k|#define MP_GT 1
  ------------------
 4805|  61.2k|    else
 4806|  61.2k|        return MP_EQ;
  ------------------
  |  |   96|  61.2k|#define MP_EQ 0
  ------------------
 4807|       |
 4808|   156k|} /* end s_mp_cmp_d() */
s_mp_ispow2:
 4820|  4.09k|{
 4821|  4.09k|    mp_digit d;
 4822|  4.09k|    int extra = 0, ix;
 4823|       |
 4824|  4.09k|    ARGMPCHK(v != NULL);
  ------------------
  |  |  349|  4.09k|#define ARGMPCHK(X) assert(X)
  ------------------
 4825|       |
 4826|  4.09k|    ix = MP_USED(v) - 1;
  ------------------
  |  |  145|  4.09k|#define MP_USED(MP) ((MP)->used)
  ------------------
 4827|  4.09k|    d = MP_DIGIT(v, ix); /* most significant digit of v */
  ------------------
  |  |  148|  4.09k|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  ------------------
 4828|       |
 4829|  4.09k|    extra = s_mp_ispow2d(d);
 4830|  4.09k|    if (extra < 0 || ix == 0)
  ------------------
  |  Branch (4830:9): [True: 3.33k, False: 762]
  |  Branch (4830:22): [True: 178, False: 584]
  ------------------
 4831|  3.50k|        return extra;
 4832|       |
 4833|  1.43k|    while (--ix >= 0) {
  ------------------
  |  Branch (4833:12): [True: 1.19k, False: 234]
  ------------------
 4834|  1.19k|        if (DIGIT(v, ix) != 0)
  ------------------
  |  |  331|  1.19k|#define DIGIT(MP, N) MP_DIGIT(MP, N)
  |  |  ------------------
  |  |  |  |  148|  1.19k|#define MP_DIGIT(MP, N) (MP)->dp[(N)]
  |  |  ------------------
  ------------------
  |  Branch (4834:13): [True: 350, False: 849]
  ------------------
 4835|    350|            return -1; /* not a power of two */
 4836|    849|        extra += MP_DIGIT_BIT;
  ------------------
  |  |  132|    849|#define MP_DIGIT_BIT (CHAR_BIT * MP_DIGIT_SIZE)
  |  |  ------------------
  |  |  |  |  131|    849|#define MP_DIGIT_SIZE sizeof(mp_digit)
  |  |  ------------------
  ------------------
 4837|    849|    }
 4838|       |
 4839|    234|    return extra;
 4840|       |
 4841|    584|} /* end s_mp_ispow2() */
s_mp_ispow2d:
 4849|  1.62M|{
 4850|  1.62M|    if ((d != 0) && ((d & (d - 1)) == 0)) { /* d is a power of 2 */
  ------------------
  |  Branch (4850:9): [True: 1.62M, False: 0]
  |  Branch (4850:21): [True: 1.60M, False: 13.9k]
  ------------------
 4851|  1.60M|        int pow = 0;
 4852|       |#if defined(MP_USE_UINT_DIGIT)
 4853|       |        if (d & 0xffff0000U)
 4854|       |            pow += 16;
 4855|       |        if (d & 0xff00ff00U)
 4856|       |            pow += 8;
 4857|       |        if (d & 0xf0f0f0f0U)
 4858|       |            pow += 4;
 4859|       |        if (d & 0xccccccccU)
 4860|       |            pow += 2;
 4861|       |        if (d & 0xaaaaaaaaU)
 4862|       |            pow += 1;
 4863|       |#elif defined(MP_USE_LONG_LONG_DIGIT)
 4864|       |        if (d & 0xffffffff00000000ULL)
 4865|       |            pow += 32;
 4866|       |        if (d & 0xffff0000ffff0000ULL)
 4867|       |            pow += 16;
 4868|       |        if (d & 0xff00ff00ff00ff00ULL)
 4869|       |            pow += 8;
 4870|       |        if (d & 0xf0f0f0f0f0f0f0f0ULL)
 4871|       |            pow += 4;
 4872|       |        if (d & 0xccccccccccccccccULL)
 4873|       |            pow += 2;
 4874|       |        if (d & 0xaaaaaaaaaaaaaaaaULL)
 4875|       |            pow += 1;
 4876|       |#elif defined(MP_USE_LONG_DIGIT)
 4877|  1.60M|        if (d & 0xffffffff00000000UL)
  ------------------
  |  Branch (4877:13): [True: 369, False: 1.60M]
  ------------------
 4878|    369|            pow += 32;
 4879|  1.60M|        if (d & 0xffff0000ffff0000UL)
  ------------------
  |  Branch (4879:13): [True: 450, False: 1.60M]
  ------------------
 4880|    450|            pow += 16;
 4881|  1.60M|        if (d & 0xff00ff00ff00ff00UL)
  ------------------
  |  Branch (4881:13): [True: 534k, False: 1.07M]
  ------------------
 4882|   534k|            pow += 8;
 4883|  1.60M|        if (d & 0xf0f0f0f0f0f0f0f0UL)
  ------------------
  |  Branch (4883:13): [True: 1.07M, False: 535k]
  ------------------
 4884|  1.07M|            pow += 4;
 4885|  1.60M|        if (d & 0xccccccccccccccccUL)
  ------------------
  |  Branch (4885:13): [True: 491, False: 1.60M]
  ------------------
 4886|    491|            pow += 2;
 4887|  1.60M|        if (d & 0xaaaaaaaaaaaaaaaaUL)
  ------------------
  |  Branch (4887:13): [True: 588, False: 1.60M]
  ------------------
 4888|    588|            pow += 1;
 4889|       |#else
 4890|       |#error "unknown type for mp_digit"
 4891|       |#endif
 4892|  1.60M|        return pow;
 4893|  1.60M|    }
 4894|  13.9k|    return -1;
 4895|       |
 4896|  1.62M|} /* end s_mp_ispow2d() */
s_mp_todigit:
 4959|  1.07M|{
 4960|  1.07M|    char ch;
 4961|       |
 4962|  1.07M|    if (val >= r)
  ------------------
  |  Branch (4962:9): [True: 0, False: 1.07M]
  ------------------
 4963|      0|        return 0;
 4964|       |
 4965|  1.07M|    ch = s_dmap_1[val];
 4966|       |
 4967|  1.07M|    if (r <= 36 && low)
  ------------------
  |  Branch (4967:9): [True: 1.07M, False: 0]
  |  Branch (4967:20): [True: 0, False: 1.07M]
  ------------------
 4968|      0|        ch = tolower(ch);
 4969|       |
 4970|  1.07M|    return ch;
 4971|       |
 4972|  1.07M|} /* end s_mp_todigit() */

