docs: function randTruePrime_(ans, k) {
    var c, m, pm, dd, j, r, B, divisible, z, zz, recSize;
    var w;
    if (primes.length==0)
      primes=findPrimes(30000);  //check for divisibility by primes <=30000
  
    if (pows.length==0) {
      pows=new Array(512);
      for (j=0; j<512; j++) {
        pows[j]=Math.pow(2, j/511.-1.);
      }
    }
  
    //c and m should be tuned for a particular machine and value of k, to maximize speed
    c=0.1;  //c=0.1 in HAC
    m=20;   //generate this k-bit number by first recursively generating a number that has between k/2 and k-m bits
    var recLimit=20; //stop recursion when k <=recLimit.  Must have recLimit >= 2
  
    if (s_i2.length!=ans.length) {
      s_i2=dup(ans);
      s_R =dup(ans);
      s_n1=dup(ans);
      s_r2=dup(ans);
      s_d =dup(ans);
      s_x1=dup(ans); //TODO Seems like a bug in eslint, reports as unused
      s_x2=dup(ans);
      s_b =dup(ans);
      s_n =dup(ans);
      s_i =dup(ans);
      s_rm=dup(ans);
      s_q =dup(ans);
      s_a =dup(ans);
      s_aa=dup(ans);
    }
  
    if (k <= recLimit) {  //generate small random primes by trial division up to its square root
      pm=(1<<((k+2)>>1))-1; //pm is binary number with all ones, just over sqrt(2^k)
      copyInt_(ans, 0);
      for (dd=1; dd;) {
        dd=0;
        ans[0]= 1 | (1<<(k-1)) | Math.floor(Math.random()*(1<<k));  //random, k-bit, odd integer, with msb 1
        for (j=1; (j<primes.length) && ((primes[j]&pm)==primes[j]); j++) { //trial division by all primes 3...sqrt(2^k)
          if (0==(ans[0]%primes[j])) {
            dd=1;
            break;
          }
        }
      }
      carry_(ans);
      return;
    }
  
    B=c*k*k;    //try small primes up to B (or all the primes[] array if the largest is less than B).
    if (k>2*m)  //generate this k-bit number by first recursively generating a number that has between k/2 and k-m bits
      for (r=1; k-k*r<=m; )
        r=pows[Math.floor(Math.random()*512)];   //r=Math.pow(2,Math.random()-1);
    else
      r=.5;
  
    //simulation suggests the more complex algorithm using r=.333 is only slightly faster.
  
    recSize=Math.floor(r*k)+1;
  
    randTruePrime_(s_q, recSize);
    copyInt_(s_i2, 0);
    s_i2[Math.floor((k-2)/bpe)] |= (1<<((k-2)%bpe));   //s_i2=2^(k-2)
    divide_(s_i2, s_q, s_i, s_rm);                        //s_i=floor((2^(k-1))/(2q))
  
    z=bitSize(s_i);
  
    for (;;) {
      for (;;) {  //generate z-bit numbers until one falls in the range [0,s_i-1]
        randBigInt_(s_R, z, 0);
        if (greater(s_i, s_R))
          break;
      }                //now s_R is in the range [0,s_i-1]
      addInt_(s_R, 1);  //now s_R is in the range [1,s_i]
      add_(s_R, s_i);   //now s_R is in the range [s_i+1,2*s_i]
  
      copy_(s_n, s_q);
      mult_(s_n, s_R);
      multInt_(s_n, 2);
      addInt_(s_n, 1);    //s_n=2*s_R*s_q+1
  
      copy_(s_r2, s_R);
      multInt_(s_r2, 2);  //s_r2=2*s_R
  
      //check s_n for divisibility by small primes up to B
      for (divisible=0, j=0; (j<primes.length) && (primes[j]<B); j++)
        if (modInt(s_n, primes[j])==0 && !equalsInt(s_n, primes[j])) {
          divisible=1;
          break;
        }
  
      if (!divisible)    //if it passes small primes check, then try a single Miller-Rabin base 2
        if (!millerRabinInt(s_n, 2)) //this line represents 75% of the total runtime for randTruePrime_
          divisible=1;
  
      if (!divisible) {  //if it passes that test, continue checking s_n
        addInt_(s_n, -3);
        for (j=s_n.length-1; (s_n[j]==0) && (j>0); j--);  //strip leading zeros
        for (zz=0, w=s_n[j]; w; (w>>=1), zz++);
        zz+=bpe*j;                             //zz=number of bits in s_n, ignoring leading zeros
        for (;;) {  //generate z-bit numbers until one falls in the range [0,s_n-1]
          randBigInt_(s_a, zz, 0);
          if (greater(s_n, s_a))
            break;
        }                //now s_a is in the range [0,s_n-1]
        addInt_(s_n, 3);  //now s_a is in the range [0,s_n-4]
        addInt_(s_a, 2);  //now s_a is in the range [2,s_n-2]
        copy_(s_b, s_a);
        copy_(s_n1, s_n);
        addInt_(s_n1, -1);
        powMod_(s_b, s_n1, s_n);   //s_b=s_a^(s_n-1) modulo s_n
        addInt_(s_b, -1);
        if (isZero(s_b)) {
          copy_(s_b, s_a);
          powMod_(s_b, s_r2, s_n);
          addInt_(s_b, -1);
          copy_(s_aa, s_n);
          copy_(s_d, s_b);
          GCD_(s_d, s_n);  //if s_b and s_n are relatively prime, then s_n is a prime
          if (equalsInt(s_d, 1)) {
            copy_(ans, s_aa);
            return;     //if we've made it this far, then s_n is absolutely guaranteed to be prime
          }
        }
      }
    }
  }