debug(result); leave(("<modpow\n"));
i = 0; j = 15; while (i < exp[0] && (exp[exp[0] - i] & (1 << j)) == 0) { j--; if (j < 0) { i++; j = 15; } }   while (i < exp[0]) { while (j >= 0) { bigmul(a + mlen, a + mlen, b, mlen); bigmod(b, m, mlen); if ((exp[exp[0] - i] & (1 << j)) != 0) { bigmul(b + mlen, n, a, mlen); bigmod(a, m, mlen); } else { unsigned short *t; t = a;  a = b;  b = t; } j--; } i++; j = 15; }   if (mshift) { for (i = mlen - 1; i < 2*mlen - 1; i++) a[i] = (a[i] << mshift) | (a[i+1] >> (16-mshift)); a[2*mlen-1] = a[2*mlen-1] << mshift; bigmod(a, m, mlen); for (i = 2*mlen - 1; i >= mlen; i--) a[i] = (a[i] >> mshift) | (a[i-1] << (16-mshift)); }   for (i = 0; i < mlen; i++) result[result[0] - i] = a[i+mlen];   for (i = 0; i < 2*mlen; i++) a[i] = 0; free(a); for (i = 0; i < 2*mlen; i++) b[i] = 0; free(b); for (i = 0; i < mlen; i++) m[i] = 0; free(m); for (i = 0; i < mlen; i++) n[i] = 0; free(n);
static void modpow(Bignum r1, Bignum r2, Bignum modulus, Bignum result) {    Bignum temp = newbn(modulus[0]+1);    Bignum tmp2 = newbn(modulus[0]+1);    int i;    int bit, bits, digit, smallbit;    enter((">modpow\n"));    debug(r1);    debug(r2);    debug(modulus);    for (i=1; i<=result[0]; i++)	result[i] = (i==1);	       /* result := 1 */    for (i=1; i<=temp[0]; i++)	temp[i] = (i > r1[0] ? 0 : r1[i]);   /* temp := r1 */    bits = 1+msb(r2);    for (bit = 0; bit < bits; bit++) {	digit = 1 + bit / 16;	smallbit = bit % 16;	debug(temp);	if (digit <= r2[0] && (r2[digit] & (1<<smallbit))) {	    dmsg(("bit %d\n", bit));	    modmult(temp, result, modulus, tmp2);	    add(tmp2, Zero, result);	    debug(result);	}	modmult(temp, temp, modulus, tmp2);	add(tmp2, Zero, temp);    }    freebn(temp);    freebn(tmp2);    debug(result);    leave(("<modpow\n"));}