Remove dead platform-specific code in |BN_div|.

It is always the case that |BN_ULLONG| is defined or we're building for
64-bit MSVC. Lots of code is trying to handle impossible cases where
neither of those is true.

Change-Id: Ie337adda1dfb453843c6e0999807dfa1afb1ed89
Reviewed-on: https://boringssl-review.googlesource.com/7043
Reviewed-by: David Benjamin <davidben@google.com>
diff --git a/crypto/bn/div.c b/crypto/bn/div.c
index f9e144a..8fbbb16 100644
--- a/crypto/bn/div.c
+++ b/crypto/bn/div.c
@@ -291,31 +291,15 @@
 #else /* !BN_ULLONG */
       BN_ULONG t2l, t2h;
 
-#if defined(div_asm)
-      q = div_asm(n0, n1, d0);
-#else
+#if !defined(_MSC_VER) || !defined(OPENSSL_X86_64)
+#error "Unreachable code. BN_ULLONG is defined everywhere except 64-bit MSVC."
+#endif
+
       q = bn_div_words(n0, n1, d0);
-#endif
 
-#ifndef REMAINDER_IS_ALREADY_CALCULATED
       rem = (n1 - q * d0) & BN_MASK2;
-#endif
 
-#if defined(BN_UMULT_LOHI)
       BN_UMULT_LOHI(t2l, t2h, d1, q);
-#elif defined(BN_UMULT_HIGH)
-      t2l = d1 * q;
-      t2h = BN_UMULT_HIGH(d1, q);
-#else
-      {
-        BN_ULONG ql, qh;
-        t2l = LBITS(d1);
-        t2h = HBITS(d1);
-        ql = LBITS(q);
-        qh = HBITS(q);
-        mul64(t2l, t2h, ql, qh); /* t2=(BN_ULLONG)d1*q; */
-      }
-#endif
 
       for (;;) {
         if ((t2h < rem) || ((t2h == rem) && (t2l <= wnump[-2]))) {
diff --git a/crypto/bn/internal.h b/crypto/bn/internal.h
index 0246aa9..e2ccb94 100644
--- a/crypto/bn/internal.h
+++ b/crypto/bn/internal.h
@@ -225,69 +225,9 @@
 int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
                 const BN_ULONG *np, const BN_ULONG *n0, int num);
 
-#if !defined(BN_ULLONG)
-
-#define LBITS(a) ((a) & BN_MASK2l)
-#define HBITS(a) (((a) >> BN_BITS4) & BN_MASK2l)
-#define L2HBITS(a) (((a) << BN_BITS4) & BN_MASK2)
-
-#define LLBITS(a) ((a) & BN_MASKl)
-#define LHBITS(a) (((a) >> BN_BITS2) & BN_MASKl)
-#define LL2HBITS(a) ((BN_ULLONG)((a) & BN_MASKl) << BN_BITS2)
-
-#define mul64(l, h, bl, bh)       \
-  {                               \
-    BN_ULONG m, m1, lt, ht;       \
-                                  \
-    lt = l;                       \
-    ht = h;                       \
-    m = (bh) * (lt);              \
-    lt = (bl) * (lt);             \
-    m1 = (bl) * (ht);             \
-    ht = (bh) * (ht);             \
-    m = (m + m1) & BN_MASK2;      \
-    if (m < m1)                   \
-      ht += L2HBITS((BN_ULONG)1); \
-    ht += HBITS(m);               \
-    m1 = L2HBITS(m);              \
-    lt = (lt + m1) & BN_MASK2;    \
-    if (lt < m1)                  \
-      ht++;                       \
-    (l) = lt;                     \
-    (h) = ht;                     \
-  }
-
-#endif  /* !defined(BN_ULLONG) */
-
-#if defined(OPENSSL_X86_64)
-# if defined(_MSC_VER)
+#if defined(OPENSSL_X86_64) && defined(_MSC_VER)
 #  define BN_UMULT_HIGH(a, b) __umulh((a), (b))
 #  define BN_UMULT_LOHI(low, high, a, b) ((low) = _umul128((a), (b), &(high)))
-# elif !defined(OPENSSL_NO_ASM) && defined(__GNUC__)
-#  define BN_UMULT_HIGH(a,b)	({	\
-	register BN_ULONG ret,discard;	\
-	__asm__ ("mulq	%3"		\
-	     : "=a"(discard),"=d"(ret)	\
-	     : "a"(a), "g"(b)		\
-	     : "cc");			\
-	ret;			})
-#  define BN_UMULT_LOHI(low,high,a,b)	\
-	__asm__ ("mulq	%3"		\
-		: "=a"(low),"=d"(high)	\
-		: "a"(a),"g"(b)		\
-		: "cc");
-# endif
-#endif
-
-#if defined(OPENSSL_AARCH64)
-# if !defined(OPENSSL_NO_ASM) && defined(__GNUC__)
-#  define BN_UMULT_HIGH(a,b)	({	\
-	register BN_ULONG ret;		\
-	__asm__ ("umulh	%0,%1,%2"	\
-	     : "=r"(ret)		\
-	     : "r"(a), "r"(b));		\
-	ret;			})
-# endif
 #endif