code: private static final void divmod(byte[] q, byte[] r, int n, byte[] d, int t) {
  		int rn = 0;
  		int dt = ((d[t-1] & 0xFF) << 8);
  		if (t>1) {
  			dt |= (d[t-2] & 0xFF);
  		}
  		while (n-- >= t) {
  			int z = (rn << 16) | ((r[n] & 0xFF) << 8);
  			if (n>0) {
  				z |= (r[n-1] & 0xFF);
  			}
  			z/=dt;
  			rn += mula_small(r,r, n-t+1, d, t, -z);
  			q[n-t+1] = (byte)((z + rn) & 0xFF); /* rn is 0 or -1 (underflow) */
  			mula_small(r,r, n-t+1, d, t, -rn);
  			rn = (r[n] & 0xFF);
  			r[n] = 0;
  		}
  		r[t-1] = (byte)rn;
  	}
docs: /* divide r (size n) by d (size t), returning quotient q and remainder r
  quotient is size n-t+1, remainder is size t
  requires t > 0 && d[t-1] != 0
  requires that r[-1] and d[-1] are valid memory locations
  q may overlap with r+t