+
+ if (yl > MPW_MAX) {
+ yh += yl >> MPW_BITS;
+ yl &= MPW_MAX;
+ }
+
+ while (yh > rh || (yh == rh && yl > rrr)) {
+ q--;
+ yh -= d;
+ if (yl < dd) {
+ yh++;
+ yl += MPW_MAX;
+ }
+ yl -= dd;
+ }
+ }
+
+ /* --- Remove a chunk from the dividend --- */
+
+ {
+ mpw *svv;
+ const mpw *dvv;
+ mpw c = 0;
+
+ /* --- Calculate the size of the chunk --- */
+
+ for (svv = sv, dvv = dv; dvv < dvl; svv++, dvv++) {
+ mpd x = (mpd)*dvv * (mpd)q + c;
+ *svv = MPW(x);
+ c = x >> MPW_BITS;
+ }
+ if (c)
+ *svv++ = c;
+
+ /* --- Now make sure that we can cope with the difference --- *
+ *
+ * Take advantage of the fact that subtraction works two's-
+ * complement.
+ */
+
+ mpx_usub(rv + scale, rvl, rv + scale, rvl, sv, svv);
+ if (rvl[-1] > MPW_MAX / 2) {
+ mpx_uadd(rv + scale, rvl, rv + scale, rvl, dv, dvl);
+ q--;
+ }
+ }
+
+ /* --- Done for another iteration --- */
+
+ if (qvl - qv > scale)
+ qv[scale] = q;
+ r = rr;
+ rr = rrr;
+ }
+ }
+
+ /* --- Now fiddle with unnormalizing and things --- */
+
+ mpx_lsr(rv, rvl, rv, rvl, norm);