void fp_rshb(fp_int *c, int x)
{
    fp_digit *tmpc, mask, shift;
    fp_digit r, rr;
    fp_digit D = x;

    if (fp_iszero(c)) return;

    /* mask */
    mask = (((fp_digit)1) << D) - 1;

    /* shift for lsb */
    shift = DIGIT_BIT - D;

    /* alias */
    tmpc = c->dp + (c->used - 1);

    /* carry */
    r = 0;
    for (x = c->used - 1; x >= 0; x--) {
      /* get the lower  bits of this word in a temp */
      rr = *tmpc & mask;

      /* shift the current word and mix in the carry bits from previous word */
      *tmpc = (*tmpc >> D) | (r << shift);
      --tmpc;

      /* set the carry to the carry bits of the current word found above */
      r = rr;
    }

    /* clamp digits */
    fp_clamp(c);
}
void fp_rshb(fp_int *c, int x)
{
    fp_digit *tmpc, mask, shift;
    fp_digit r, rr;
    fp_digit D = x;

    if (fp_iszero(c)) return;

     
    mask = (((fp_digit)1) << D) - 1;

     
    shift = DIGIT_BIT - D;

     
    tmpc = c->dp + (c->used - 1);

     
    r = 0;
    for (x = c->used - 1; x >= 0; x--) {
       
      rr = *tmpc & mask;

       
      *tmpc = (*tmpc >> D) | (r << shift);
      --tmpc;

       
      r = rr;
    }

     
    fp_clamp(c);
}