long mc_rand_binomial(long n, double p) {
  static const double C1_3 = 0.33333333333333333;
  static const double C5_8 = 0.62500000000000000;
  static const double C1_6 = 0.16666666666666667;
  static const long DMAX_KM = 20;
  static __thread long n_last = -1, n_prev = -1;
  static __thread double par, np, p0, q, p_last = -1.0, p_prev = -1.0;
  static __thread long b, m, nm;
  static __thread double pq, rc, ss, xm, xl, xr, ll, lr, c, p1, p2, p3, p4, ch;
  long bh, i, K, Km, nK;
  double f, rm, tmp, U, V, X, T, E;
  if (n != n_last || p != p_last) {
    n_last = n;
    p_last = p;
    par = ((p) < (1.0 - p) ? (p) : (1.0 - p));
    q = 1.0 - par;
    np = n * par;
    if (np <= 0.0) {
      return -1;
    }
    rm = np + par;
    m = (long)rm;
    if (np < 10) {
      p0 = exp(n * log(q));
      bh = (long)(np + 10.0 * sqrt(np * q));
      b = ((n) < (bh) ? (n) : (bh));
    } else {
      pq = par / q;
      rc = (n + 1.0) * pq;
      ss = np * q;
      i = (long)(2.195 * sqrt(ss) - 4.6 * q);
      xm = m + 0.5;
      xl = (double)(m - i);
      xr = (double)(m + i + 1);
      f = (rm - xl) / (rm - xl * par);
      ll = f * (1.0 + 0.5 * f);
      f = (xr - rm) / (xr * q);
      lr = f * (1.0 + 0.5 * f);
      c = 0.134 + 20.5 / (15.3 + (double)m);
      p1 = i + 0.5;
      p2 = p1 * (1.0 + c + c);
      p3 = p2 + c / ll;
      p4 = p3 + c / lr;
    }
  }
  if (np <= 0.0) {
    return -1;
  }
  if (np < 10) {
    double pk;
    K = 0;
    pk = p0;
    U = mc_randf();
    while (U > pk) {
      ++K;
      if (K > b) {
        U = mc_randf();
        K = 0;
        pk = p0;
      } else {
        U -= pk;
        pk = (double)(((n - K + 1) * par * pk) / (K * q));
      }
    }
    return (p > 0.5) ? (n - K) : K;
  }
  for (;;) {
    V = mc_randf();
    U = mc_randf() * p4;
    if (U <= p1) {
      K = (long)(xm - U + p1 * V);
      return (p > 0.5) ? (n - K) : K;
    }
    if (U <= p2) {
      X = xl + (U - p1) / c;
      V = V * c + 1.0 - fabs(xm - X) / p1;
      if (V >= 1.0) {
        continue;
      }
      K = (long)X;
    } else if (U <= p3) {
      X = xl + log(V) / ll;
      if (X < 0.0) {
        continue;
      }
      K = (long)X;
      V *= (U - p2) * ll;
    } else {
      K = (long)(xr - log(V) / lr);
      if (K > n) {
        continue;
      }
      V *= (U - p3) * lr;
    }
    Km = labs(K - m);
    if ((Km <= DMAX_KM) || ((Km + Km + 2) >= ss)) {
      f = 1.0;
      if (m < K) {
        for (i = m; i < K;) {
          f *= (rc / (++i) - pq);
          if (f < V) {
            break;
          }
        }
      } else {
        for (i = K; i < m;) {
          V *= (rc / (++i) - pq);
          if (V > f) {
            break;
          }
        }
      }
      if (V <= f) {
        break;
      }
    } else {
      V = log(V);
      T = -Km * Km / (ss + ss);
      E = (Km / ss) * ((Km * (Km * C1_3 + C5_8) + C1_6) / ss + 0.5);
      if (V <= (T - E)) {
        break;
      }
      if (V <= (T + E)) {
        if ((n != n_prev) || (par != p_prev)) {
          n_prev = n;
          p_prev = par;
          nm = n - m + 1;
          ch = xm * log((m + 1.0) / (pq * nm)) + _stirling_correction(m + 1) +
               _stirling_correction(nm);
        }
        nK = n - K + 1;
        tmp = ch + (n + 1.0) * log((double)nm / (double)nK) +
              (K + 0.5) * log(nK * pq / (K + 1.0)) -
              _stirling_correction(K + 1) - _stirling_correction(nK);
        if (V <= tmp) {
          break;
        }
      }
    }
  }
  return (p > 0.5) ? (n - K) : K;
}


x86 assembly (clang, -O0):
<mc_rand_binomial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x390,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    0x3e3a(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    %rax,%rcx
mov    -0x90(%rbp),%rax
mov    0x0(%rcx),%rcx
cmp    %rcx,%rax
jne    11f3 <mc_rand_binomial+0x83>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
lea    0x3e07(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x98(%rbp),%xmm0
ff
movsd  0x10(%rax),%xmm1
ucomisd %xmm1,%xmm0
jne    11f3 <mc_rand_binomial+0x83>
jp     11f3 <mc_rand_binomial+0x83>
jmp    19da <mc_rand_binomial+0x86a>
mov    -0x10(%rbp),%rax
mov    %rax,-0xa8(%rbp)
lea    0x3dcb(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    -0xa8(%rbp),%rcx
mov    %rcx,0x0(%rax)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
lea    0x3da4(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,0x10(%rax)
movsd  -0x18(%rbp),%xmm1
movsd  0x1db2(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    126f <mc_rand_binomial+0xff>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
jmp    1284 <mc_rand_binomial+0x114>
movsd  0x1d89(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xd0(%rbp)
ff
lea    0x3d35(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0xd0(%rbp),%xmm0
ff
mov    %rax,-0xc0(%rbp)
movsd  %xmm0,0x20(%rax)
movsd  0x20(%rax),%xmm1
movsd  0x1d39(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
lea    0x3cf6(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0xc8(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0xc0(%rbp),%rax
movsd  %xmm0,0x38(%rcx)
cvtsi2sdq -0x10(%rbp),%xmm0
movsd  0x20(%rax),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
lea    0x3cb6(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0xb8(%rbp),%xmm0
ff
movsd  %xmm0,0x28(%rax)
movsd  0x28(%rax),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jb     1351 <mc_rand_binomial+0x1e1>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    2771 <mc_rand_binomial+0x1601>
lea    0x3c78(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    %rax,-0xd8(%rbp)
movsd  0x28(%rax),%xmm0
movsd  %xmm0,-0xe8(%rbp)
ff
lea    0x3c55(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0xe8(%rbp),%xmm0
ff
movsd  0x20(%rax),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
cvttsd2si -0x50(%rbp),%rax
mov    %rax,-0xe0(%rbp)
lea    0x3c23(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    -0xe0(%rbp),%rdx
mov    %rax,%rcx
mov    -0xd8(%rbp),%rax
mov    %rdx,0x48(%rcx)
movsd  0x28(%rax),%xmm1
movsd  0x1c2e(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    14fb <mc_rand_binomial+0x38b>
cvtsi2sdq -0x10(%rbp),%xmm0
movsd  %xmm0,-0x108(%rbp)
ff
lea    0x3bd7(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    %rax,-0xf8(%rbp)
movsd  0x38(%rax),%xmm0
call   1080 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x108(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1070 <exp@plt>
movsd  %xmm0,-0x100(%rbp)
ff
lea    0x3b9b(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x100(%rbp),%xmm0
ff
movsd  %xmm0,0x30(%rax)
lea    0x3b7f(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    %rax,%rcx
mov    -0xf8(%rbp),%rax
movsd  0x28(%rcx),%xmm0
movaps %xmm0,%xmm1
movsd  %xmm1,-0xf0(%rbp)
ff
movsd  0x38(%rax),%xmm1
mulsd  %xmm1,%xmm0
call   1090 <sqrt@plt>
movsd  -0xf0(%rbp),%xmm1
ff
movsd  0x1b74(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    14c3 <mc_rand_binomial+0x353>
mov    -0x10(%rbp),%rax
mov    %rax,-0x110(%rbp)
jmp    14ce <mc_rand_binomial+0x35e>
mov    -0x20(%rbp),%rax
mov    %rax,-0x110(%rbp)
mov    -0x110(%rbp),%rax
mov    %rax,-0x118(%rbp)
lea    0x3aed(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    -0x118(%rbp),%rcx
mov    %rcx,0x40(%rax)
jmp    19d5 <mc_rand_binomial+0x865>
lea    0x3ace(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    %rax,-0x198(%rbp)
movsd  0x20(%rax),%xmm0
movsd  %xmm0,-0x1d8(%rbp)
ff
lea    0x3aab(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x1d8(%rbp),%xmm0
ff
mov    %rax,-0x180(%rbp)
movsd  0x38(%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x1d0(%rbp)
ff
lea    0x3a7c(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x1d0(%rbp),%xmm0
ff
movsd  %xmm0,0x58(%rax)
cvtsi2sdq -0x10(%rbp),%xmm0
movsd  0x1a89(%rip),%xmm1
movsd  %xmm1,-0x158(%rbp)
ff
addsd  %xmm1,%xmm0
movsd  0x58(%rax),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x1c8(%rbp)
ff
lea    0x3a32(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x1c8(%rbp),%xmm0
ff
movsd  %xmm0,0x60(%rax)
lea    0x3a16(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    %rax,%rcx
mov    -0x180(%rbp),%rax
movsd  0x28(%rcx),%xmm0
movsd  0x38(%rax),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x1c0(%rbp)
ff
lea    0x39e4(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x1c0(%rbp),%xmm0
ff
movsd  %xmm0,0x68(%rax)
movsd  0x68(%rax),%xmm0
call   1090 <sqrt@plt>
mov    -0x180(%rbp),%rax
movsd  0x38(%rax),%xmm1
movsd  0x19eb(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0x19e7(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x28(%rbp)
lea    0x3987(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    %rax,-0x170(%rbp)
cvtsi2sdq 0x48(%rax),%xmm0
movsd  0x19ba(%rip),%xmm1
movsd  %xmm1,-0x168(%rbp)
ff
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x1b8(%rbp)
ff
lea    0x394f(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x1b8(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0x170(%rbp),%rax
movsd  %xmm0,0x70(%rcx)
mov    0x48(%rax),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x1b0(%rbp)
ff
lea    0x390e(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x1b0(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0x170(%rbp),%rax
mov    %rcx,-0x1a0(%rbp)
movsd  %xmm0,0x78(%rcx)
mov    0x48(%rax),%rax
mov    -0x28(%rbp),%rcx
lea    0x1(%rax,%rcx,1),%rax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x1a8(%rbp)
ff
lea    0x38c4(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x168(%rbp),%xmm3
ff
movsd  -0x158(%rbp),%xmm2
ff
movsd  -0x1a8(%rbp),%xmm0
ff
mov    -0x1a0(%rbp),%rcx
mov    %rax,%rdx
mov    -0x198(%rbp),%rax
mov    %rdx,-0x188(%rbp)
movsd  %xmm0,0x80(%rdx)
movsd  -0x50(%rbp),%xmm1
movsd  0x78(%rcx),%xmm4
movaps %xmm1,%xmm0
subsd  %xmm4,%xmm0
movsd  0x20(%rax),%xmm5
mulsd  %xmm5,%xmm4
subsd  %xmm4,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movaps %xmm0,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x190(%rbp)
ff
lea    0x3837(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x168(%rbp),%xmm3
ff
movsd  -0x158(%rbp),%xmm2
ff
movsd  -0x190(%rbp),%xmm0
ff
mov    -0x188(%rbp),%rcx
mov    %rax,%rdx
mov    -0x180(%rbp),%rax
mov    %rdx,-0x140(%rbp)
movsd  %xmm0,0x88(%rdx)
movsd  0x80(%rcx),%xmm1
movsd  -0x50(%rbp),%xmm4
movaps %xmm1,%xmm0
subsd  %xmm4,%xmm0
movsd  0x38(%rax),%xmm4
mulsd  %xmm4,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movaps %xmm0,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x178(%rbp)
ff
lea    0x37ae(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x178(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0x170(%rbp),%rax
mov    %rcx,-0x128(%rbp)
movsd  %xmm0,0x90(%rcx)
cvtsi2sdq 0x48(%rax),%xmm1
movsd  0x17cf(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0x17cb(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  0x17c7(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x160(%rbp)
ff
lea    0x374c(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x168(%rbp),%xmm1
ff
movsd  -0x160(%rbp),%xmm0
ff
mov    %rax,-0x130(%rbp)
movsd  %xmm0,0x98(%rax)
cvtsi2sdq -0x28(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x150(%rbp)
ff
lea    0x370f(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x158(%rbp),%xmm3
ff
movsd  -0x150(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0x130(%rbp),%rax
movsd  %xmm0,0xa0(%rcx)
movsd  0xa0(%rcx),%xmm0
movsd  0x98(%rax),%xmm2
movaps %xmm2,%xmm1
addsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x148(%rbp)
ff
lea    0x36ba(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x148(%rbp),%xmm0
ff
mov    -0x130(%rbp),%rcx
mov    %rax,%rdx
mov    -0x140(%rbp),%rax
movsd  %xmm0,0xa8(%rdx)
movsd  0xa8(%rdx),%xmm0
movsd  0x98(%rcx),%xmm1
movsd  0x88(%rax),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x138(%rbp)
ff
lea    0x3665(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x138(%rbp),%xmm0
ff
mov    -0x130(%rbp),%rcx
mov    %rax,%rdx
mov    -0x128(%rbp),%rax
movsd  %xmm0,0xb0(%rdx)
movsd  0xb0(%rdx),%xmm0
movsd  0x98(%rcx),%xmm1
movsd  0x90(%rax),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x120(%rbp)
ff
lea    0x3610(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x120(%rbp),%xmm0
ff
movsd  %xmm0,0xb8(%rax)
jmp    19da <mc_rand_binomial+0x86a>
lea    0x35ef(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  0x28(%rax),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jb     1a08 <mc_rand_binomial+0x898>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    2771 <mc_rand_binomial+0x1601>
lea    0x35c1(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  0x28(%rax),%xmm1
movsd  0x15e4(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1bee <mc_rand_binomial+0xa7e>
movq   $0x0,-0x30(%rbp)
lea    0x3593(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  0x30(%rax),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    $0x0,%al
call   1060 <mc_randf@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
ucomisd -0x88(%rbp),%xmm0
ff
jbe    1ba8 <mc_rand_binomial+0xa38>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x1e0(%rbp)
lea    0x353d(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    %rax,%rcx
mov    -0x1e0(%rbp),%rax
mov    0x40(%rcx),%rcx
cmp    %rcx,%rax
jle    1aeb <mc_rand_binomial+0x97b>
xor    %eax,%eax
call   1060 <mc_randf@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x60(%rbp)
movq   $0x0,-0x30(%rbp)
lea    0x34ff(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  0x30(%rax),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    1ba3 <mc_rand_binomial+0xa33>
movsd  -0x88(%rbp),%xmm1
ff
movsd  -0x60(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    %rcx,-0x1f8(%rbp)
sub    %rcx,%rax
add    $0x1,%rax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x200(%rbp)
ff
lea    0x34a5(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x200(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0x1f8(%rbp),%rax
movsd  0x20(%rcx),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x88(%rbp),%xmm1
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x1e8(%rbp)
ff
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x1f0(%rbp)
ff
lea    0x345a(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x1f0(%rbp),%xmm1
ff
movsd  -0x1e8(%rbp),%xmm0
ff
movsd  0x38(%rax),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    1a62 <mc_rand_binomial+0x8f2>
movsd  -0x18(%rbp),%xmm0
movsd  0x146b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1bd3 <mc_rand_binomial+0xa63>
mov    -0x10(%rbp),%rax
sub    -0x30(%rbp),%rax
mov    %rax,-0x208(%rbp)
jmp    1bde <mc_rand_binomial+0xa6e>
mov    -0x30(%rbp),%rax
mov    %rax,-0x208(%rbp)
mov    -0x208(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    2771 <mc_rand_binomial+0x1601>
jmp    1bf3 <mc_rand_binomial+0xa83>
xor    %eax,%eax
mov    %al,-0x219(%rbp)
call   1060 <mc_randf@plt>
mov    %eax,%ecx
mov    -0x219(%rbp),%al
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,-0x68(%rbp)
call   1060 <mc_randf@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x218(%rbp)
ff
lea    0x33a7(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x218(%rbp),%xmm0
ff
movsd  0xb8(%rax),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x210(%rbp)
ff
lea    0x3375(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x210(%rbp),%xmm1
ff
movsd  0xa0(%rax),%xmm0
ucomisd %xmm1,%xmm0
jb     1d17 <mc_rand_binomial+0xba7>
lea    0x334f(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  0x70(%rax),%xmm0
movsd  -0x60(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x228(%rbp)
ff
lea    0x332a(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x228(%rbp),%xmm1
ff
movsd  0xa0(%rax),%xmm0
movsd  -0x68(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0x1342(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1cfc <mc_rand_binomial+0xb8c>
mov    -0x10(%rbp),%rax
sub    -0x30(%rbp),%rax
mov    %rax,-0x230(%rbp)
jmp    1d07 <mc_rand_binomial+0xb97>
mov    -0x30(%rbp),%rax
mov    %rax,-0x230(%rbp)
mov    -0x230(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    2771 <mc_rand_binomial+0x1601>
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x238(%rbp)
ff
lea    0x32a5(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x238(%rbp),%xmm1
ff
movsd  0xa8(%rax),%xmm0
ucomisd %xmm1,%xmm0
jb     1e72 <mc_rand_binomial+0xd02>
lea    0x327f(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  0x78(%rax),%xmm0
movsd  %xmm0,-0x250(%rbp)
ff
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x260(%rbp)
ff
lea    0x3256(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x260(%rbp),%xmm0
ff
mov    %rax,-0x240(%rbp)
movsd  0xa0(%rax),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x258(%rbp)
ff
lea    0x3227(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x258(%rbp),%xmm1
ff
movsd  -0x250(%rbp),%xmm0
ff
movsd  0x98(%rax),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  0x98(%rax),%xmm1
mulsd  %xmm1,%xmm0
movsd  0x1214(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x248(%rbp)
ff
lea    0x31d1(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x248(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0x240(%rbp),%rax
movsd  0x70(%rcx),%xmm1
movsd  -0x70(%rbp),%xmm2
subsd  %xmm2,%xmm1
movaps 0x1232(%rip),%xmm2
pand   %xmm2,%xmm1
movsd  0xa0(%rax),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  0x11ac(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1e63 <mc_rand_binomial+0xcf3>
jmp    1bf3 <mc_rand_binomial+0xa83>
cvttsd2si -0x70(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    205f <mc_rand_binomial+0xeef>
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x268(%rbp)
ff
lea    0x314a(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x268(%rbp),%xmm1
ff
movsd  0xb0(%rax),%xmm0
ucomisd %xmm1,%xmm0
jb     1f85 <mc_rand_binomial+0xe15>
lea    0x3124(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  0x78(%rax),%xmm0
movsd  %xmm0,-0x270(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
call   1080 <log@plt>
movsd  %xmm0,-0x278(%rbp)
ff
lea    0x30f6(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x278(%rbp),%xmm1
ff
movsd  -0x270(%rbp),%xmm0
ff
movsd  0x88(%rax),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x70(%rbp),%xmm0
jbe    1f17 <mc_rand_binomial+0xda7>
jmp    1bf3 <mc_rand_binomial+0xa83>
cvttsd2si -0x70(%rbp),%rax
mov    %rax,-0x30(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x288(%rbp)
ff
lea    0x309b(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x288(%rbp),%xmm0
ff
movsd  0xa8(%rax),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x280(%rbp)
ff
lea    0x3073(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x280(%rbp),%xmm0
ff
movsd  0x88(%rax),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    205a <mc_rand_binomial+0xeea>
lea    0x3044(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  0x80(%rax),%xmm0
movsd  %xmm0,-0x290(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
call   1080 <log@plt>
movsd  %xmm0,-0x298(%rbp)
ff
lea    0x3016(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x298(%rbp),%xmm1
ff
movsd  -0x290(%rbp),%xmm0
ff
movsd  0x90(%rax),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jle    1ffb <mc_rand_binomial+0xe8b>
jmp    1bf3 <mc_rand_binomial+0xa83>
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x2a8(%rbp)
lea    0x2fc1(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x2a8(%rbp),%xmm0
ff
movsd  0xb0(%rax),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x2a0(%rbp)
ff
lea    0x2f99(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x2a0(%rbp),%xmm0
ff
movsd  0x90(%rax),%xmm1
mulsd  %xmm1,%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    205f <mc_rand_binomial+0xeef>
mov    -0x30(%rbp),%rax
mov    %rax,-0x2b0(%rbp)
lea    0x2f5f(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    -0x2b0(%rbp),%rdi
mov    0x48(%rax),%rax
sub    %rax,%rdi
call   1030 <labs@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x14,-0x38(%rbp)
jle    20d7 <mc_rand_binomial+0xf67>
mov    -0x38(%rbp),%rax
lea    0x2(%rax,%rax,1),%rax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x2b8(%rbp)
ff
lea    0x2f18(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x2b8(%rbp),%xmm0
ff
movsd  0x68(%rax),%xmm1
ucomisd %xmm1,%xmm0
jb     2276 <mc_rand_binomial+0x1106>
movabs $0x3ff0000000000000,%rax
mov    %rax,-0x48(%rbp)
lea    0x2ee4(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    0x48(%rax),%rax
cmp    -0x30(%rbp),%rax
jge    21a5 <mc_rand_binomial+0x1035>
lea    0x2ec7(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    0x48(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jge    21a0 <mc_rand_binomial+0x1030>
lea    0x2ea2(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  0x60(%rax),%xmm0
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x2c0(%rbp)
ff
lea    0x2e71(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x2c0(%rbp),%xmm0
ff
movsd  0x58(%rax),%xmm1
subsd  %xmm1,%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    219b <mc_rand_binomial+0x102b>
jmp    21a0 <mc_rand_binomial+0x1030>
jmp    2119 <mc_rand_binomial+0xfa9>
jmp    2258 <mc_rand_binomial+0x10e8>
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x2c8(%rbp)
lea    0x2e11(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    %rax,%rcx
mov    -0x2c8(%rbp),%rax
mov    0x48(%rcx),%rcx
cmp    %rcx,%rax
jge    2253 <mc_rand_binomial+0x10e3>
lea    0x2deb(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  0x60(%rax),%xmm0
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x2d0(%rbp)
ff
lea    0x2dba(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x2d0(%rbp),%xmm0
ff
movsd  0x58(%rax),%xmm1
subsd  %xmm1,%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    224e <mc_rand_binomial+0x10de>
jmp    2253 <mc_rand_binomial+0x10e3>
jmp    21ad <mc_rand_binomial+0x103d>
jmp    2258 <mc_rand_binomial+0x10e8>
movsd  -0x68(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     2271 <mc_rand_binomial+0x1101>
jmp    2730 <mc_rand_binomial+0x15c0>
jmp    272b <mc_rand_binomial+0x15bb>
movsd  -0x68(%rbp),%xmm0
call   1080 <log@plt>
movsd  %xmm0,-0x68(%rbp)
mov    -0x38(%rbp),%rcx
mov    %rcx,%rax
neg    %rax
imul   %rcx,%rax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x2d8(%rbp)
ff
lea    0x2d29(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x2d8(%rbp),%xmm0
ff
movsd  0x68(%rax),%xmm1
addsd  %xmm1,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
cvtsi2sdq -0x38(%rbp),%xmm1
movsd  0x68(%rax),%xmm2
movaps %xmm1,%xmm0
divsd  %xmm2,%xmm0
movsd  0xd5a(%rip),%xmm4
movaps %xmm1,%xmm3
mulsd  %xmm4,%xmm3
movsd  0xd53(%rip),%xmm4
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
movsd  0xd4b(%rip),%xmm3
addsd  %xmm3,%xmm1
divsd  %xmm2,%xmm1
movsd  0xd0b(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x68(%rbp),%xmm1
movsd  -0x78(%rbp),%xmm0
subsd  -0x80(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     2340 <mc_rand_binomial+0x11d0>
jmp    2730 <mc_rand_binomial+0x15c0>
movsd  -0x68(%rbp),%xmm1
movsd  -0x78(%rbp),%xmm0
addsd  -0x80(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     2726 <mc_rand_binomial+0x15b6>
mov    -0x10(%rbp),%rax
mov    %rax,-0x2e0(%rbp)
lea    0x2c65(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    %rax,%rcx
mov    -0x2e0(%rbp),%rax
mov    0x8(%rcx),%rcx
cmp    %rcx,%rax
jne    23d7 <mc_rand_binomial+0x1267>
lea    0x2c3f(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  0x20(%rax),%xmm0
movsd  %xmm0,-0x2e8(%rbp)
ff
lea    0x2c23(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x2e8(%rbp),%xmm0
ff
movsd  0x18(%rax),%xmm1
ucomisd %xmm1,%xmm0
jne    23d7 <mc_rand_binomial+0x1267>
jp     23d7 <mc_rand_binomial+0x1267>
jmp    25ab <mc_rand_binomial+0x143b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x348(%rbp)
lea    0x2be7(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    -0x348(%rbp),%rcx
mov    %rcx,0x8(%rax)
lea    0x2bcd(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  0x20(%rax),%xmm0
movsd  %xmm0,-0x340(%rbp)
ff
lea    0x2bb1(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x340(%rbp),%xmm0
ff
movsd  %xmm0,0x18(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x338(%rbp)
lea    0x2b8a(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    %rax,%rcx
mov    -0x338(%rbp),%rax
mov    %rcx,-0x320(%rbp)
mov    0x48(%rcx),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x330(%rbp)
lea    0x2b58(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    -0x330(%rbp),%rcx
mov    %rax,-0x308(%rbp)
mov    %rcx,0x50(%rax)
lea    0x2b37(%rip),%rdi
call   1050 <__tls_get_addr@plt>
mov    %rax,%rcx
mov    -0x320(%rbp),%rax
movsd  0x70(%rcx),%xmm0
movsd  %xmm0,-0x318(%rbp)
ff
cvtsi2sdq 0x48(%rax),%xmm0
movsd  0xb37(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x328(%rbp)
ff
lea    0x2af4(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x328(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0x308(%rbp),%rax
movsd  0x58(%rcx),%xmm1
cvtsi2sdq 0x50(%rax),%xmm2
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1080 <log@plt>
mov    -0x320(%rbp),%rax
movsd  %xmm0,-0x310(%rbp)
ff
mov    0x48(%rax),%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %al,-0x2f9(%rbp)
call   1040 <_stirling_correction@plt>
movsd  -0x318(%rbp),%xmm0
ff
movsd  -0x310(%rbp),%xmm2
ff
mov    -0x308(%rbp),%rcx
mov    %eax,%edx
mov    -0x2f9(%rbp),%al
cvtsi2sd %edx,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x2f8(%rbp)
ff
mov    0x50(%rcx),%rdi
call   1040 <_stirling_correction@plt>
movsd  -0x2f8(%rbp),%xmm0
ff
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x2f0(%rbp)
ff
lea    0x2a3a(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x2f0(%rbp),%xmm0
ff
movsd  %xmm0,0xc0(%rax)
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
lea    0x2a0b(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  0xc0(%rax),%xmm0
movsd  %xmm0,-0x380(%rbp)
ff
cvtsi2sdq -0x10(%rbp),%xmm0
movsd  0xa18(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x378(%rbp)
ff
lea    0x29d5(%rip),%rdi
call   1050 <__tls_get_addr@plt>
cvtsi2sdq 0x50(%rax),%xmm0
cvtsi2sdq -0x40(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1080 <log@plt>
movsd  -0x380(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x378(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x368(%rbp)
ff
cvtsi2sdq -0x30(%rbp),%xmm0
movsd  0x9d7(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x360(%rbp)
ff
cvtsi2sdq -0x40(%rbp),%xmm0
movsd  %xmm0,-0x370(%rbp)
ff
lea    0x2966(%rip),%rdi
call   1050 <__tls_get_addr@plt>
movsd  -0x370(%rbp),%xmm0
ff
movsd  0x58(%rax),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdq -0x30(%rbp),%xmm1
movsd  0x96f(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1080 <log@plt>
movsd  -0x368(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x360(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x358(%rbp)
ff
mov    -0x30(%rbp),%rdi
add    $0x1,%rdi
mov    $0x0,%al
call   1040 <_stirling_correction@plt>
movsd  -0x358(%rbp),%xmm0
ff
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x350(%rbp)
ff
mov    -0x40(%rbp),%rdi
mov    $0x0,%al
call   1040 <_stirling_correction@plt>
movsd  -0x350(%rbp),%xmm0
ff
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x68(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     2721 <mc_rand_binomial+0x15b1>
jmp    2730 <mc_rand_binomial+0x15c0>
jmp    2726 <mc_rand_binomial+0x15b6>
jmp    272b <mc_rand_binomial+0x15bb>
jmp    1bf3 <mc_rand_binomial+0xa83>
movsd  -0x18(%rbp),%xmm0
movsd  0x8e3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    275b <mc_rand_binomial+0x15eb>
mov    -0x10(%rbp),%rax
sub    -0x30(%rbp),%rax
mov    %rax,-0x388(%rbp)
jmp    2766 <mc_rand_binomial+0x15f6>
mov    -0x30(%rbp),%rax
mov    %rax,-0x388(%rbp)
mov    -0x388(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x390,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mc_rand_binomial>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movsd  %xmm0,0x18(%rsp)
mov    %rdi,%r14
lea    0x2e52(%rip),%rdi
call   1040 <__tls_get_addr@plt>
movsd  0x18(%rsp),%xmm2
mov    %rax,%r12
mov    %rax,%rcx
cmp    %r14,0x0(%rax)
jne    11ac <mc_rand_binomial+0x4c>
movsd  0x10(%rax),%xmm0
ucomisd %xmm2,%xmm0
jne    11ac <mc_rand_binomial+0x4c>
jnp    1483 <mc_rand_binomial+0x323>
mov    %r12,%rax
mov    %r14,0x0(%r12)
movsd  %xmm2,0x10(%r12)
movsd  0xe37(%rip),%xmm6
movapd %xmm6,%xmm0
subsd  %xmm2,%xmm0
minsd  %xmm0,%xmm2
movsd  %xmm2,0x20(%r12)
movapd %xmm6,%xmm1
subsd  %xmm2,%xmm1
movsd  %xmm1,0x38(%r12)
xorps  %xmm4,%xmm4
cvtsi2sd %r14,%xmm4
movapd %xmm2,%xmm0
mulsd  %xmm4,%xmm0
movsd  %xmm0,0x28(%r12)
mov    $0xffffffffffffffff,%rax
xorpd  %xmm3,%xmm3
ucomisd %xmm0,%xmm3
jae    1b9e <mc_rand_binomial+0xa3e>
movapd %xmm2,%xmm7
addsd  %xmm0,%xmm7
cvttsd2si %xmm7,%rcx
mov    %r12,%rax
mov    %rcx,0x48(%r12)
movsd  0xdc8(%rip),%xmm3
ucomisd %xmm0,%xmm3
jbe    1295 <mc_rand_binomial+0x135>
movapd %xmm1,%xmm0
movsd  %xmm4,0x8(%rsp)
call   1070 <log@plt>
mulsd  0x8(%rsp),%xmm0
call   1060 <exp@plt>
mov    %r12,%rax
movsd  %xmm0,0x30(%r12)
movsd  0x28(%r12),%xmm2
movsd  0x38(%r12),%xmm0
mulsd  %xmm2,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     12da <mc_rand_binomial+0x17a>
sqrtsd %xmm0,%xmm0
jmp    12eb <mc_rand_binomial+0x18b>
divsd  %xmm1,%xmm2
addsd  0xd5f(%rip),%xmm4
mov    %r12,%rax
movsd  %xmm2,0x58(%r12)
mulsd  %xmm2,%xmm4
movsd  %xmm4,0x60(%r12)
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x68(%r12)
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1313 <mc_rand_binomial+0x1b3>
sqrtsd %xmm0,%xmm0
jmp    132c <mc_rand_binomial+0x1cc>
movsd  %xmm2,0x8(%rsp)
call   1080 <sqrt@plt>
movsd  0x8(%rsp),%xmm2
mulsd  0xd15(%rip),%xmm0
addsd  %xmm2,%xmm0
cvttsd2si %xmm0,%rcx
cmp    %r14,%rcx
cmovg  %r14,%rcx
mov    %r12,%rax
mov    %rcx,0x40(%r12)
jmp    1483 <mc_rand_binomial+0x323>
movsd  %xmm7,0x8(%rsp)
call   1080 <sqrt@plt>
movsd  0x8(%rsp),%xmm7
movsd  0xcd4(%rip),%xmm6
mov    %r12,%rax
movsd  0x38(%r12),%xmm2
movsd  0xccf(%rip),%xmm1
mulsd  0xccf(%rip),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
mov    0x48(%r12),%rdx
xorps  %xmm1,%xmm1
cvtsi2sd %rdx,%xmm1
movsd  0xcb2(%rip),%xmm0
movapd %xmm1,%xmm3
addsd  %xmm0,%xmm3
movsd  %xmm3,0x70(%r12)
lea    (%rdx,%rcx,1),%rsi
add    $0x1,%rsi
sub    %rcx,%rdx
xorps  %xmm3,%xmm3
cvtsi2sd %rdx,%xmm3
movsd  %xmm3,0x78(%r12)
xorps  %xmm4,%xmm4
cvtsi2sd %rsi,%xmm4
movsd  %xmm4,0x80(%r12)
movapd %xmm7,%xmm5
subsd  %xmm3,%xmm5
mulsd  0x20(%r12),%xmm3
mulsd  %xmm4,%xmm2
subsd  %xmm7,%xmm4
subsd  %xmm3,%xmm7
divsd  %xmm7,%xmm5
movapd %xmm5,%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm6,%xmm3
mulsd  %xmm5,%xmm3
movsd  %xmm3,0x88(%r12)
divsd  %xmm2,%xmm4
movapd %xmm4,%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm6,%xmm2
mulsd  %xmm4,%xmm2
addsd  0xc21(%rip),%xmm1
movsd  0xc21(%rip),%xmm4
divsd  %xmm1,%xmm4
addsd  0xc1d(%rip),%xmm4
movsd  %xmm2,0x90(%r12)
movsd  %xmm4,0x98(%r12)
xorps  %xmm1,%xmm1
cvtsi2sd %rcx,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0xa0(%r12)
addsd  %xmm4,%xmm6
addsd  %xmm4,%xmm6
mulsd  %xmm1,%xmm6
movsd  %xmm6,0xa8(%r12)
movapd %xmm4,%xmm0
divsd  %xmm3,%xmm0
addsd  %xmm6,%xmm0
movsd  %xmm0,0xb0(%r12)
divsd  %xmm2,%xmm4
addsd  %xmm0,%xmm4
movsd  %xmm4,0xb8(%r12)
mov    %r12,%rax
movsd  0x28(%r12),%xmm0
mov    $0xffffffffffffffff,%rax
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    1b9e <mc_rand_binomial+0xa3e>
movsd  0xb5b(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    157d <mc_rand_binomial+0x41d>
movsd  0x30(%r12),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <mc_randf@plt>
movsd  0x8(%rsp),%xmm3
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
ucomisd %xmm3,%xmm0
jbe    1b86 <mc_rand_binomial+0xa26>
mov    %r12,%rax
mov    0x40(%r12),%rcx
xor    %ebx,%ebx
jmp    1551 <mc_rand_binomial+0x3f1>
cs nopw 0x0(%rax,%rax,1)
subsd  %xmm3,%xmm0
mov    %r14,%rax
sub    %rbx,%rax
add    $0x1,%rbx
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
mov    %r12,%rax
mulsd  0x20(%r12),%xmm1
xorps  %xmm2,%xmm2
cvtsi2sd %rbx,%xmm2
mulsd  %xmm3,%xmm1
mulsd  0x38(%r12),%xmm2
divsd  %xmm2,%xmm1
movapd %xmm1,%xmm3
ucomisd %xmm3,%xmm0
movsd  0x18(%rsp),%xmm1
jbe    1b8c <mc_rand_binomial+0xa2c>
cmp    %rcx,%rbx
jl     1500 <mc_rand_binomial+0x3a0>
xor    %eax,%eax
call   1050 <mc_randf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    %r12,%rax
movsd  0x30(%r12),%xmm3
mov    0x40(%r12),%rcx
xor    %ebx,%ebx
jmp    1541 <mc_rand_binomial+0x3e1>
xor    %eax,%eax
call   1050 <mc_randf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1050 <mc_randf@plt>
xorps  %xmm3,%xmm3
cvtsi2sd %eax,%xmm3
mov    %r12,%rax
mulsd  0xb8(%r12),%xmm3
movsd  0xa0(%r12),%xmm0
ucomisd %xmm3,%xmm0
jae    1b4b <mc_rand_binomial+0x9eb>
xorps  %xmm1,%xmm1
cvtsi2sd %r14,%xmm1
addsd  0xa30(%rip),%xmm1
movsd  %xmm1,0x28(%rsp)
movsd  0xa22(%rip),%xmm2
jmp    1639 <mc_rand_binomial+0x4d9>
movapd %xmm4,%xmm2
ucomisd %xmm5,%xmm2
jae    1b34 <mc_rand_binomial+0x9d4>
xor    %eax,%eax
call   1050 <mc_randf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1050 <mc_randf@plt>
xorps  %xmm3,%xmm3
cvtsi2sd %eax,%xmm3
mov    %r12,%rax
mulsd  0xb8(%r12),%xmm3
movsd  0xa0(%r12),%xmm0
ucomisd %xmm3,%xmm0
movsd  0x9cd(%rip),%xmm2
jae    1b4b <mc_rand_binomial+0x9eb>
mov    %r12,%rax
movsd  0xa8(%r12),%xmm1
ucomisd %xmm3,%xmm1
jae    16e0 <mc_rand_binomial+0x580>
mov    %r12,%rax
movsd  0xb0(%r12),%xmm0
movsd  %xmm3,0x20(%rsp)
ucomisd %xmm3,%xmm0
movsd  0x8(%rsp),%xmm0
jae    1740 <mc_rand_binomial+0x5e0>
movsd  0x80(%r12),%xmm1
movsd  %xmm1,0x10(%rsp)
call   1070 <log@plt>
movsd  0x8(%rsp),%xmm5
mov    %r12,%rax
movsd  0x90(%r12),%xmm1
divsd  %xmm1,%xmm0
movsd  0x10(%rsp),%xmm2
subsd  %xmm0,%xmm2
cvttsd2si %xmm2,%r13
cmp    %r14,%r13
movsd  0x20(%rsp),%xmm0
jg     15ee <mc_rand_binomial+0x48e>
mov    %r12,%rax
subsd  0xb0(%r12),%xmm0
mulsd  %xmm0,%xmm1
jmp    179c <mc_rand_binomial+0x63c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
subsd  %xmm0,%xmm3
mov    %r12,%rax
mov    %rax,%rcx
movsd  0x98(%r12),%xmm1
divsd  %xmm1,%xmm3
addsd  0x78(%rax),%xmm3
movsd  0x8(%rsp),%xmm5
mulsd  %xmm1,%xmm5
addsd  %xmm2,%xmm5
movsd  0x70(%r12),%xmm1
subsd  %xmm3,%xmm1
andpd  0x93c(%rip),%xmm1
divsd  %xmm0,%xmm1
subsd  %xmm1,%xmm5
ucomisd %xmm2,%xmm5
jae    15ee <mc_rand_binomial+0x48e>
cvttsd2si %xmm3,%r13
jmp    17a0 <mc_rand_binomial+0x640>
nopl   (%rax)
movsd  0x78(%r12),%xmm1
movsd  %xmm1,0x10(%rsp)
call   1070 <log@plt>
movsd  0x8(%rsp),%xmm5
mov    %r12,%rax
movsd  0x88(%r12),%xmm1
divsd  %xmm1,%xmm0
addsd  0x10(%rsp),%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
movsd  0x20(%rsp),%xmm2
ja     15ee <mc_rand_binomial+0x48e>
cvttsd2si %xmm0,%r13
mov    %r12,%rax
subsd  0xa8(%r12),%xmm2
mulsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm5
mov    %r12,%rax
mov    0x48(%r12),%rcx
mov    %r13,%rbx
sub    %rcx,%rbx
mov    %rbx,%rbp
neg    %rbp
cmovs  %rbx,%rbp
cmp    $0x15,%rbp
jb     18e0 <mc_rand_binomial+0x780>
lea    0x2(,%rbp,1),%rax
add    %rbp,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    %r12,%rax
ucomisd 0x68(%r12),%xmm0
jae    18e0 <mc_rand_binomial+0x780>
movapd %xmm5,%xmm0
call   1070 <log@plt>
imul   %rbx,%rbx
neg    %rbx
xorps  %xmm4,%xmm4
cvtsi2sd %rbx,%xmm4
mov    %r12,%rax
movsd  0x68(%r12),%xmm1
movapd %xmm1,%xmm2
addsd  %xmm1,%xmm2
divsd  %xmm2,%xmm4
xorps  %xmm2,%xmm2
cvtsi2sd %rbp,%xmm2
movapd %xmm2,%xmm3
mulsd  0x810(%rip),%xmm3
addsd  0x810(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  0x80c(%rip),%xmm3
unpcklpd %xmm3,%xmm2
unpcklpd %xmm1,%xmm1
divpd  %xmm1,%xmm2
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
addsd  0x7c0(%rip),%xmm1
mulsd  %xmm2,%xmm1
movapd %xmm4,%xmm2
subsd  %xmm1,%xmm2
ucomisd %xmm0,%xmm2
jae    1b34 <mc_rand_binomial+0x9d4>
addsd  %xmm1,%xmm4
ucomisd %xmm0,%xmm4
jb     15ee <mc_rand_binomial+0x48e>
mov    %r12,%rax
mov    %rax,%rcx
movsd  0x20(%r12),%xmm1
cmp    %r14,0x8(%rax)
movsd  %xmm0,0x20(%rsp)
jne    1985 <mc_rand_binomial+0x825>
ucomisd 0x18(%rax),%xmm1
jne    1985 <mc_rand_binomial+0x825>
jp     1985 <mc_rand_binomial+0x825>
mov    %r12,%rax
movsd  0xc0(%r12),%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    1a5a <mc_rand_binomial+0x8fa>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rax
movsd  0x60(%r12),%xmm0
movsd  0x58(%r12),%xmm1
cmp    %rcx,%r13
jle    1940 <mc_rand_binomial+0x7e0>
movsd  0x6fc(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    %r13,%rcx
jge    15e4 <mc_rand_binomial+0x484>
add    $0x1,%rcx
xorps  %xmm3,%xmm3
cvtsi2sd %rcx,%xmm3
movapd %xmm0,%xmm4
divsd  %xmm3,%xmm4
subsd  %xmm1,%xmm4
mulsd  %xmm4,%xmm2
ucomisd %xmm2,%xmm5
jbe    1910 <mc_rand_binomial+0x7b0>
jmp    15e4 <mc_rand_binomial+0x484>
neg    %rcx
lea    0x1(%r13),%rax
movsd  0x6b1(%rip),%xmm4
nop
lea    (%rcx,%rax,1),%rdx
cmp    $0x1,%rdx
je     15e0 <mc_rand_binomial+0x480>
xorps  %xmm2,%xmm2
cvtsi2sd %rax,%xmm2
movapd %xmm0,%xmm3
divsd  %xmm2,%xmm3
subsd  %xmm1,%xmm3
mulsd  %xmm3,%xmm5
add    $0x1,%rax
ucomisd %xmm4,%xmm5
jbe    1950 <mc_rand_binomial+0x7f0>
jmp    15e0 <mc_rand_binomial+0x480>
mov    %r12,%rax
mov    %r14,0x8(%r12)
movsd  %xmm1,0x18(%r12)
mov    %rax,%rbx
mov    0x48(%rax),%rcx
mov    %r14,%rdx
sub    %rcx,%rdx
add    $0x1,%rdx
mov    %rax,%r15
mov    %rdx,0x50(%rax)
movsd  0x70(%r12),%xmm0
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %rcx,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %rdx,%xmm1
movsd  0x620(%rip),%xmm2
addsd  %xmm2,%xmm0
mulsd  0x58(%r12),%xmm1
divsd  %xmm1,%xmm0
call   1070 <log@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x48(%rbx),%rdi
add    $0x1,%rdi
xor    %eax,%eax
call   1030 <_stirling_correction@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    0x50(%r15),%rdi
xor    %eax,%eax
call   1030 <_stirling_correction@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x8(%rsp),%xmm0
mov    %r12,%rax
movsd  %xmm0,0x8(%rsp)
movsd  %xmm0,0xc0(%r12)
mov    %r14,%r15
sub    %r13,%r15
xorps  %xmm0,%xmm0
cvtsi2sdq 0x50(%r12),%xmm0
add    $0x1,%r15
xorps  %xmm1,%xmm1
cvtsi2sd %r15,%xmm1
movsd  %xmm1,0x10(%rsp)
divsd  %xmm1,%xmm0
call   1070 <log@plt>
mulsd  0x28(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r13,%xmm0
movapd %xmm0,%xmm1
addsd  0x572(%rip),%xmm1
movsd  %xmm1,0x30(%rsp)
movsd  0x10(%rsp),%xmm1
mulsd  0x58(%r12),%xmm1
addsd  0x534(%rip),%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1070 <log@plt>
mulsd  0x30(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x1(%r13),%rdi
xor    %eax,%eax
call   1030 <_stirling_correction@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <_stirling_correction@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
ucomisd 0x20(%rsp),%xmm1
jb     15ee <mc_rand_binomial+0x48e>
sub    %r13,%r14
movsd  0x18(%rsp),%xmm0
ucomisd 0x4db(%rip),%xmm0
cmovbe %r13,%r14
jmp    1b9b <mc_rand_binomial+0xa3b>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
mov    %r12,%rax
movsd  0x70(%r12),%xmm0
subsd  %xmm3,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
sub    %rax,%r14
movsd  0x18(%rsp),%xmm0
ucomisd 0x4a0(%rip),%xmm0
cmovbe %rax,%r14
jmp    1b9b <mc_rand_binomial+0xa3b>
movsd  0x18(%rsp),%xmm1
sub    %rbx,%r14
ucomisd 0x489(%rip),%xmm1
cmovbe %rbx,%r14
mov    %r14,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@mc_rand_binomial.C1_3 = internal constant double 0x3FD5555555555555
@mc_rand_binomial.C5_8 = internal constant double 6.250000e-01
@mc_rand_binomial.C1_6 = internal constant double 0x3FC5555555555555
@mc_rand_binomial.DMAX_KM = internal constant i64 20
@mc_rand_binomial.n_last = internal thread_local global i64 -1
@mc_rand_binomial.n_prev = internal thread_local global i64 -1
@mc_rand_binomial.par = internal thread_local global double 0.000000e+00
@mc_rand_binomial.np = internal thread_local global double 0.000000e+00
@mc_rand_binomial.p0 = internal thread_local global double 0.000000e+00
@mc_rand_binomial.q = internal thread_local global double 0.000000e+00
@mc_rand_binomial.p_last = internal thread_local global double -1.000000e+00
@mc_rand_binomial.p_prev = internal thread_local global double -1.000000e+00
@mc_rand_binomial.b = internal thread_local global i64 0
@mc_rand_binomial.m = internal thread_local global i64 0
@mc_rand_binomial.nm = internal thread_local global i64 0
@mc_rand_binomial.pq = internal thread_local global double 0.000000e+00
@mc_rand_binomial.rc = internal thread_local global double 0.000000e+00
@mc_rand_binomial.ss = internal thread_local global double 0.000000e+00
@mc_rand_binomial.xm = internal thread_local global double 0.000000e+00
@mc_rand_binomial.xl = internal thread_local global double 0.000000e+00
@mc_rand_binomial.xr = internal thread_local global double 0.000000e+00
@mc_rand_binomial.ll = internal thread_local global double 0.000000e+00
@mc_rand_binomial.lr = internal thread_local global double 0.000000e+00
@mc_rand_binomial.c = internal thread_local global double 0.000000e+00
@mc_rand_binomial.p1 = internal thread_local global double 0.000000e+00
@mc_rand_binomial.p2 = internal thread_local global double 0.000000e+00
@mc_rand_binomial.p3 = internal thread_local global double 0.000000e+00
@mc_rand_binomial.p4 = internal thread_local global double 0.000000e+00
@mc_rand_binomial.ch = internal thread_local global double 0.000000e+00
define i64 @mc_rand_binomial(i64 %0, double %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca double
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
store i64 %0, i64* %4
store double %1, double* %5
%20 = load i64, i64* %4
%21 = load i64, i64* @mc_rand_binomial.n_last
%22 = icmp ne i64 %20, %21
br i1 %22, label %27, label %23
23: ; preds = %2
%24 = load double, double* %5
%25 = load double, double* @mc_rand_binomial.p_last
%26 = fcmp une double %24, %25
br i1 %26, label %27, label %161
27: ; preds = %23, %2
%28 = load i64, i64* %4
store i64 %28, i64* @mc_rand_binomial.n_last
%29 = load double, double* %5
store double %29, double* @mc_rand_binomial.p_last
%30 = load double, double* %5
%31 = load double, double* %5
%32 = fsub double 1.000000e+00, %31
%33 = fcmp olt double %30, %32
br i1 %33, label %34, label %36
34: ; preds = %27
%35 = load double, double* %5
br label %39
36: ; preds = %27
%37 = load double, double* %5
%38 = fsub double 1.000000e+00, %37
br label %39
39: ; preds = %36, %34
%40 = phi double [ %35, %34 ], [ %38, %36 ]
store double %40, double* @mc_rand_binomial.par
%41 = load double, double* @mc_rand_binomial.par
%42 = fsub double 1.000000e+00, %41
store double %42, double* @mc_rand_binomial.q
%43 = load i64, i64* %4
%44 = sitofp i64 %43 to double
%45 = load double, double* @mc_rand_binomial.par
%46 = fmul double %44, %45
store double %46, double* @mc_rand_binomial.np
%47 = load double, double* @mc_rand_binomial.np
%48 = fcmp ole double %47, 0.000000e+00
br i1 %48, label %49, label %50
49: ; preds = %39
store i64 -1, i64* %3
br label %515
50: ; preds = %39
%51 = load double, double* @mc_rand_binomial.np
%52 = load double, double* @mc_rand_binomial.par
%53 = fadd double %51, %52
store double %53, double* %12
%54 = load double, double* %12
%55 = fptosi double %54 to i64
store i64 %55, i64* @mc_rand_binomial.m
%56 = load double, double* @mc_rand_binomial.np
%57 = fcmp olt double %56, 1.000000e+01
br i1 %57, label %58, label %81
58: ; preds = %50
%59 = load i64, i64* %4
%60 = sitofp i64 %59 to double
%61 = load double, double* @mc_rand_binomial.q
%62 = call double @log(double %61)
%63 = fmul double %60, %62
%64 = call double @exp(double %63)
store double %64, double* @mc_rand_binomial.p0
%65 = load double, double* @mc_rand_binomial.np
%66 = load double, double* @mc_rand_binomial.np
%67 = load double, double* @mc_rand_binomial.q
%68 = fmul double %66, %67
%69 = call double @sqrt(double %68)
%70 = call double @llvm.fmuladd.f64(double 1.000000e+01, double %69, double %65)
%71 = fptosi double %70 to i64
store i64 %71, i64* %6
%72 = load i64, i64* %4
%73 = load i64, i64* %6
%74 = icmp slt i64 %72, %73
br i1 %74, label %75, label %77
75: ; preds = %58
%76 = load i64, i64* %4
br label %79
77: ; preds = %58
%78 = load i64, i64* %6
br label %79
79: ; preds = %77, %75
%80 = phi i64 [ %76, %75 ], [ %78, %77 ]
store i64 %80, i64* @mc_rand_binomial.b
br label %160
81: ; preds = %50
%82 = load double, double* @mc_rand_binomial.par
%83 = load double, double* @mc_rand_binomial.q
%84 = fdiv double %82, %83
store double %84, double* @mc_rand_binomial.pq
%85 = load i64, i64* %4
%86 = sitofp i64 %85 to double
%87 = fadd double %86, 1.000000e+00
%88 = load double, double* @mc_rand_binomial.pq
%89 = fmul double %87, %88
store double %89, double* @mc_rand_binomial.rc
%90 = load double, double* @mc_rand_binomial.np
%91 = load double, double* @mc_rand_binomial.q
%92 = fmul double %90, %91
store double %92, double* @mc_rand_binomial.ss
%93 = load double, double* @mc_rand_binomial.ss
%94 = call double @sqrt(double %93)
%95 = load double, double* @mc_rand_binomial.q
%96 = fmul double 4.600000e+00, %95
%97 = fneg double %96
%98 = call double @llvm.fmuladd.f64(double 2.195000e+00, double %94, double %97)
%99 = fptosi double %98 to i64
store i64 %99, i64* %7
%100 = load i64, i64* @mc_rand_binomial.m
%101 = sitofp i64 %100 to double
%102 = fadd double %101, 5.000000e-01
store double %102, double* @mc_rand_binomial.xm
%103 = load i64, i64* @mc_rand_binomial.m
%104 = load i64, i64* %7
%105 = sub nsw i64 %103, %104
%106 = sitofp i64 %105 to double
store double %106, double* @mc_rand_binomial.xl
%107 = load i64, i64* @mc_rand_binomial.m
%108 = load i64, i64* %7
%109 = add nsw i64 %107, %108
%110 = add nsw i64 %109, 1
%111 = sitofp i64 %110 to double
store double %111, double* @mc_rand_binomial.xr
%112 = load double, double* %12
%113 = load double, double* @mc_rand_binomial.xl
%114 = fsub double %112, %113
%115 = load double, double* %12
%116 = load double, double* @mc_rand_binomial.xl
%117 = load double, double* @mc_rand_binomial.par
%118 = fneg double %116
%119 = call double @llvm.fmuladd.f64(double %118, double %117, double %115)
%120 = fdiv double %114, %119
store double %120, double* %11
%121 = load double, double* %11
%122 = load double, double* %11
%123 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %122, double 1.000000e+00)
%124 = fmul double %121, %123
store double %124, double* @mc_rand_binomial.ll
%125 = load double, double* @mc_rand_binomial.xr
%126 = load double, double* %12
%127 = fsub double %125, %126
%128 = load double, double* @mc_rand_binomial.xr
%129 = load double, double* @mc_rand_binomial.q
%130 = fmul double %128, %129
%131 = fdiv double %127, %130
store double %131, double* %11
%132 = load double, double* %11
%133 = load double, double* %11
%134 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %133, double 1.000000e+00)
%135 = fmul double %132, %134
store double %135, double* @mc_rand_binomial.lr
%136 = load i64, i64* @mc_rand_binomial.m
%137 = sitofp i64 %136 to double
%138 = fadd double 1.530000e+01, %137
%139 = fdiv double 2.050000e+01, %138
%140 = fadd double 1.340000e-01, %139
store double %140, double* @mc_rand_binomial.c
%141 = load i64, i64* %7
%142 = sitofp i64 %141 to double
%143 = fadd double %142, 5.000000e-01
store double %143, double* @mc_rand_binomial.p1
%144 = load double, double* @mc_rand_binomial.p1
%145 = load double, double* @mc_rand_binomial.c
%146 = fadd double 1.000000e+00, %145
%147 = load double, double* @mc_rand_binomial.c
%148 = fadd double %146, %147
%149 = fmul double %144, %148
store double %149, double* @mc_rand_binomial.p2
%150 = load double, double* @mc_rand_binomial.p2
%151 = load double, double* @mc_rand_binomial.c
%152 = load double, double* @mc_rand_binomial.ll
%153 = fdiv double %151, %152
%154 = fadd double %150, %153
store double %154, double* @mc_rand_binomial.p3
%155 = load double, double* @mc_rand_binomial.p3
%156 = load double, double* @mc_rand_binomial.c
%157 = load double, double* @mc_rand_binomial.lr
%158 = fdiv double %156, %157
%159 = fadd double %155, %158
store double %159, double* @mc_rand_binomial.p4
br label %160
160: ; preds = %81, %79
br label %161
161: ; preds = %160, %23
%162 = load double, double* @mc_rand_binomial.np
%163 = fcmp ole double %162, 0.000000e+00
br i1 %163, label %164, label %165
164: ; preds = %161
store i64 -1, i64* %3
br label %515
165: ; preds = %161
%166 = load double, double* @mc_rand_binomial.np
%167 = fcmp olt double %166, 1.000000e+01
br i1 %167, label %168, label %216
168: ; preds = %165
store i64 0, i64* %8
%169 = load double, double* @mc_rand_binomial.p0
store double %169, double* %19
%170 = call i32 (...) @mc_randf()
%171 = sitofp i32 %170 to double
store double %171, double* %14
br label %172
172: ; preds = %204, %168
%173 = load double, double* %14
%174 = load double, double* %19
%175 = fcmp ogt double %173, %174
br i1 %175, label %176, label %205
176: ; preds = %172
%177 = load i64, i64* %8
%178 = add nsw i64 %177, 1
store i64 %178, i64* %8
%179 = load i64, i64* %8
%180 = load i64, i64* @mc_rand_binomial.b
%181 = icmp sgt i64 %179, %180
br i1 %181, label %182, label %186
182: ; preds = %176
%183 = call i32 (...) @mc_randf()
%184 = sitofp i32 %183 to double
store double %184, double* %14
store i64 0, i64* %8
%185 = load double, double* @mc_rand_binomial.p0
store double %185, double* %19
br label %204
186: ; preds = %176
%187 = load double, double* %19
%188 = load double, double* %14
%189 = fsub double %188, %187
store double %189, double* %14
%190 = load i64, i64* %4
%191 = load i64, i64* %8
%192 = sub nsw i64 %190, %191
%193 = add nsw i64 %192, 1
%194 = sitofp i64 %193 to double
%195 = load double, double* @mc_rand_binomial.par
%196 = fmul double %194, %195
%197 = load double, double* %19
%198 = fmul double %196, %197
%199 = load i64, i64* %8
%200 = sitofp i64 %199 to double
%201 = load double, double* @mc_rand_binomial.q
%202 = fmul double %200, %201
%203 = fdiv double %198, %202
store double %203, double* %19
br label %204
204: ; preds = %186, %182
br label %172
205: ; preds = %172
%206 = load double, double* %5
%207 = fcmp ogt double %206, 5.000000e-01
br i1 %207, label %208, label %212
208: ; preds = %205
%209 = load i64, i64* %4
%210 = load i64, i64* %8
%211 = sub nsw i64 %209, %210
br label %214
212: ; preds = %205
%213 = load i64, i64* %8
br label %214
214: ; preds = %212, %208
%215 = phi i64 [ %211, %208 ], [ %213, %212 ]
store i64 %215, i64* %3
br label %515
216: ; preds = %165
br label %217
217: ; preds = %503, %308, %286, %269, %216
%218 = call i32 (...) @mc_randf()
%219 = sitofp i32 %218 to double
store double %219, double* %15
%220 = call i32 (...) @mc_randf()
%221 = sitofp i32 %220 to double
%222 = load double, double* @mc_rand_binomial.p4
%223 = fmul double %221, %222
store double %223, double* %14
%224 = load double, double* %14
%225 = load double, double* @mc_rand_binomial.p1
%226 = fcmp ole double %224, %225
br i1 %226, label %227, label %245
227: ; preds = %217
%228 = load double, double* @mc_rand_binomial.xm
%229 = load double, double* %14
%230 = fsub double %228, %229
%231 = load double, double* @mc_rand_binomial.p1
%232 = load double, double* %15
%233 = call double @llvm.fmuladd.f64(double %231, double %232, double %230)
%234 = fptosi double %233 to i64
store i64 %234, i64* %8
%235 = load double, double* %5
%236 = fcmp ogt double %235, 5.000000e-01
br i1 %236, label %237, label %241
237: ; preds = %227
%238 = load i64, i64* %4
%239 = load i64, i64* %8
%240 = sub nsw i64 %238, %239
br label %243
241: ; preds = %227
%242 = load i64, i64* %8
br label %243
243: ; preds = %241, %237
%244 = phi i64 [ %240, %237 ], [ %242, %241 ]
store i64 %244, i64* %3
br label %515
245: ; preds = %217
%246 = load double, double* %14
%247 = load double, double* @mc_rand_binomial.p2
%248 = fcmp ole double %246, %247
br i1 %248, label %249, label %273
249: ; preds = %245
%250 = load double, double* @mc_rand_binomial.xl
%251 = load double, double* %14
%252 = load double, double* @mc_rand_binomial.p1
%253 = fsub double %251, %252
%254 = load double, double* @mc_rand_binomial.c
%255 = fdiv double %253, %254
%256 = fadd double %250, %255
store double %256, double* %16
%257 = load double, double* %15
%258 = load double, double* @mc_rand_binomial.c
%259 = call double @llvm.fmuladd.f64(double %257, double %258, double 1.000000e+00)
%260 = load double, double* @mc_rand_binomial.xm
%261 = load double, double* %16
%262 = fsub double %260, %261
%263 = call double @llvm.fabs.f64(double %262)
%264 = load double, double* @mc_rand_binomial.p1
%265 = fdiv double %263, %264
%266 = fsub double %259, %265
store double %266, double* %15
%267 = load double, double* %15
%268 = fcmp oge double %267, 1.000000e+00
br i1 %268, label %269, label %270
269: ; preds = %249
br label %217
270: ; preds = %249
%271 = load double, double* %16
%272 = fptosi double %271 to i64
store i64 %272, i64* %8
br label %318
273: ; preds = %245
%274 = load double, double* %14
%275 = load double, double* @mc_rand_binomial.p3
%276 = fcmp ole double %274, %275
br i1 %276, label %277, label %297
277: ; preds = %273
%278 = load double, double* @mc_rand_binomial.xl
%279 = load double, double* %15
%280 = call double @log(double %279)
%281 = load double, double* @mc_rand_binomial.ll
%282 = fdiv double %280, %281
%283 = fadd double %278, %282
store double %283, double* %16
%284 = load double, double* %16
%285 = fcmp olt double %284, 0.000000e+00
br i1 %285, label %286, label %287
286: ; preds = %277
br label %217
287: ; preds = %277
%288 = load double, double* %16
%289 = fptosi double %288 to i64
store i64 %289, i64* %8
%290 = load double, double* %14
%291 = load double, double* @mc_rand_binomial.p2
%292 = fsub double %290, %291
%293 = load double, double* @mc_rand_binomial.ll
%294 = fmul double %292, %293
%295 = load double, double* %15
%296 = fmul double %295, %294
store double %296, double* %15
br label %317
297: ; preds = %273
%298 = load double, double* @mc_rand_binomial.xr
%299 = load double, double* %15
%300 = call double @log(double %299)
%301 = load double, double* @mc_rand_binomial.lr
%302 = fdiv double %300, %301
%303 = fsub double %298, %302
%304 = fptosi double %303 to i64
store i64 %304, i64* %8
%305 = load i64, i64* %8
%306 = load i64, i64* %4
%307 = icmp sgt i64 %305, %306
br i1 %307, label %308, label %309
308: ; preds = %297
br label %217
309: ; preds = %297
%310 = load double, double* %14
%311 = load double, double* @mc_rand_binomial.p3
%312 = fsub double %310, %311
%313 = load double, double* @mc_rand_binomial.lr
%314 = fmul double %312, %313
%315 = load double, double* %15
%316 = fmul double %315, %314
store double %316, double* %15
br label %317
317: ; preds = %309, %287
br label %318
318: ; preds = %317, %270
%319 = load i64, i64* %8
%320 = load i64, i64* @mc_rand_binomial.m
%321 = sub nsw i64 %319, %320
%322 = call i64 @labs(i64 %321)
store i64 %322, i64* %9
%323 = load i64, i64* %9
%324 = icmp sle i64 %323, 20
br i1 %324, label %333, label %325
325: ; preds = %318
%326 = load i64, i64* %9
%327 = load i64, i64* %9
%328 = add nsw i64 %326, %327
%329 = add nsw i64 %328, 2
%330 = sitofp i64 %329 to double
%331 = load double, double* @mc_rand_binomial.ss
%332 = fcmp oge double %330, %331
br i1 %332, label %333, label %387
333: ; preds = %325, %318
store double 1.000000e+00, double* %11
%334 = load i64, i64* @mc_rand_binomial.m
%335 = load i64, i64* %8
%336 = icmp slt i64 %334, %335
br i1 %336, label %337, label %359
337: ; preds = %333
%338 = load i64, i64* @mc_rand_binomial.m
store i64 %338, i64* %7
br label %339
339: ; preds = %357, %337
%340 = load i64, i64* %7
%341 = load i64, i64* %8
%342 = icmp slt i64 %340, %341
br i1 %342, label %343, label %358
343: ; preds = %339
%344 = load double, double* @mc_rand_binomial.rc
%345 = load i64, i64* %7
%346 = add nsw i64 %345, 1
store i64 %346, i64* %7
%347 = sitofp i64 %346 to double
%348 = fdiv double %344, %347
%349 = load double, double* @mc_rand_binomial.pq
%350 = fsub double %348, %349
%351 = load double, double* %11
%352 = fmul double %351, %350
store double %352, double* %11
%353 = load double, double* %11
%354 = load double, double* %15
%355 = fcmp olt double %353, %354
br i1 %355, label %356, label %357
356: ; preds = %343
br label %358
357: ; preds = %343
br label %339
358: ; preds = %356, %339
br label %381
359: ; preds = %333
%360 = load i64, i64* %8
store i64 %360, i64* %7
br label %361
361: ; preds = %379, %359
%362 = load i64, i64* %7
%363 = load i64, i64* @mc_rand_binomial.m
%364 = icmp slt i64 %362, %363
br i1 %364, label %365, label %380
365: ; preds = %361
%366 = load double, double* @mc_rand_binomial.rc
%367 = load i64, i64* %7
%368 = add nsw i64 %367, 1
store i64 %368, i64* %7
%369 = sitofp i64 %368 to double
%370 = fdiv double %366, %369
%371 = load double, double* @mc_rand_binomial.pq
%372 = fsub double %370, %371
%373 = load double, double* %15
%374 = fmul double %373, %372
store double %374, double* %15
%375 = load double, double* %15
%376 = load double, double* %11
%377 = fcmp ogt double %375, %376
br i1 %377, label %378, label %379
378: ; preds = %365
br label %380
379: ; preds = %365
br label %361
380: ; preds = %378, %361
br label %381
381: ; preds = %380, %358
%382 = load double, double* %15
%383 = load double, double* %11
%384 = fcmp ole double %382, %383
br i1 %384, label %385, label %386
385: ; preds = %381
br label %504
386: ; preds = %381
br label %503
387: ; preds = %325
%388 = load double, double* %15
%389 = call double @log(double %388)
store double %389, double* %15
%390 = load i64, i64* %9
%391 = sub nsw i64 0, %390
%392 = load i64, i64* %9
%393 = mul nsw i64 %391, %392
%394 = sitofp i64 %393 to double
%395 = load double, double* @mc_rand_binomial.ss
%396 = load double, double* @mc_rand_binomial.ss
%397 = fadd double %395, %396
%398 = fdiv double %394, %397
store double %398, double* %17
%399 = load i64, i64* %9
%400 = sitofp i64 %399 to double
%401 = load double, double* @mc_rand_binomial.ss
%402 = fdiv double %400, %401
%403 = load i64, i64* %9
%404 = sitofp i64 %403 to double
%405 = load i64, i64* %9
%406 = sitofp i64 %405 to double
%407 = call double @llvm.fmuladd.f64(double %406, double 0x3FD5555555555555, double 6.250000e-01)
%408 = call double @llvm.fmuladd.f64(double %404, double %407, double 0x3FC5555555555555)
%409 = load double, double* @mc_rand_binomial.ss
%410 = fdiv double %408, %409
%411 = fadd double %410, 5.000000e-01
%412 = fmul double %402, %411
store double %412, double* %18
%413 = load double, double* %15
%414 = load double, double* %17
%415 = load double, double* %18
%416 = fsub double %414, %415
%417 = fcmp ole double %413, %416
br i1 %417, label %418, label %419
418: ; preds = %387
br label %504
419: ; preds = %387
%420 = load double, double* %15
%421 = load double, double* %17
%422 = load double, double* %18
%423 = fadd double %421, %422
%424 = fcmp ole double %420, %423
br i1 %424, label %425, label %502
425: ; preds = %419
%426 = load i64, i64* %4
%427 = load i64, i64* @mc_rand_binomial.n_prev
%428 = icmp ne i64 %426, %427
br i1 %428, label %433, label %429
429: ; preds = %425
%430 = load double, double* @mc_rand_binomial.par
%431 = load double, double* @mc_rand_binomial.p_prev
%432 = fcmp une double %430, %431
br i1 %432, label %433, label %459
433: ; preds = %429, %425
%434 = load i64, i64* %4
store i64 %434, i64* @mc_rand_binomial.n_prev
%435 = load double, double* @mc_rand_binomial.par
store double %435, double* @mc_rand_binomial.p_prev
%436 = load i64, i64* %4
%437 = load i64, i64* @mc_rand_binomial.m
%438 = sub nsw i64 %436, %437
%439 = add nsw i64 %438, 1
store i64 %439, i64* @mc_rand_binomial.nm
%440 = load double, double* @mc_rand_binomial.xm
%441 = load i64, i64* @mc_rand_binomial.m
%442 = sitofp i64 %441 to double
%443 = fadd double %442, 1.000000e+00
%444 = load double, double* @mc_rand_binomial.pq
%445 = load i64, i64* @mc_rand_binomial.nm
%446 = sitofp i64 %445 to double
%447 = fmul double %444, %446
%448 = fdiv double %443, %447
%449 = call double @log(double %448)
%450 = load i64, i64* @mc_rand_binomial.m
%451 = add nsw i64 %450, 1
%452 = call i32 (i64, ...) bitcast (i32 (...)* @_stirling_correction to i32 (i64, ...)*)(i64 %451)
%453 = sitofp i32 %452 to double
%454 = call double @llvm.fmuladd.f64(double %440, double %449, double %453)
%455 = load i64, i64* @mc_rand_binomial.nm
%456 = call i32 (i64, ...) bitcast (i32 (...)* @_stirling_correction to i32 (i64, ...)*)(i64 %455)
%457 = sitofp i32 %456 to double
%458 = fadd double %454, %457
store double %458, double* @mc_rand_binomial.ch
br label %459
459: ; preds = %433, %429
%460 = load i64, i64* %4
%461 = load i64, i64* %8
%462 = sub nsw i64 %460, %461
%463 = add nsw i64 %462, 1
store i64 %463, i64* %10
%464 = load double, double* @mc_rand_binomial.ch
%465 = load i64, i64* %4
%466 = sitofp i64 %465 to double
%467 = fadd double %466, 1.000000e+00
%468 = load i64, i64* @mc_rand_binomial.nm
%469 = sitofp i64 %468 to double
%470 = load i64, i64* %10
%471 = sitofp i64 %470 to double
%472 = fdiv double %469, %471
%473 = call double @log(double %472)
%474 = call double @llvm.fmuladd.f64(double %467, double %473, double %464)
%475 = load i64, i64* %8
%476 = sitofp i64 %475 to double
%477 = fadd double %476, 5.000000e-01
%478 = load i64, i64* %10
%479 = sitofp i64 %478 to double
%480 = load double, double* @mc_rand_binomial.pq
%481 = fmul double %479, %480
%482 = load i64, i64* %8
%483 = sitofp i64 %482 to double
%484 = fadd double %483, 1.000000e+00
%485 = fdiv double %481, %484
%486 = call double @log(double %485)
%487 = call double @llvm.fmuladd.f64(double %477, double %486, double %474)
%488 = load i64, i64* %8
%489 = add nsw i64 %488, 1
%490 = call i32 (i64, ...) bitcast (i32 (...)* @_stirling_correction to i32 (i64, ...)*)(i64 %489)
%491 = sitofp i32 %490 to double
%492 = fsub double %487, %491
%493 = load i64, i64* %10
%494 = call i32 (i64, ...) bitcast (i32 (...)* @_stirling_correction to i32 (i64, ...)*)(i64 %493)
%495 = sitofp i32 %494 to double
%496 = fsub double %492, %495
store double %496, double* %13
%497 = load double, double* %15
%498 = load double, double* %13
%499 = fcmp ole double %497, %498
br i1 %499, label %500, label %501
500: ; preds = %459
br label %504
501: ; preds = %459
br label %502
502: ; preds = %501, %419
br label %503
503: ; preds = %502, %386
br label %217
504: ; preds = %500, %418, %385
%505 = load double, double* %5
%506 = fcmp ogt double %505, 5.000000e-01
br i1 %506, label %507, label %511
507: ; preds = %504
%508 = load i64, i64* %4
%509 = load i64, i64* %8
%510 = sub nsw i64 %508, %509
br label %513
511: ; preds = %504
%512 = load i64, i64* %8
br label %513
513: ; preds = %511, %507
%514 = phi i64 [ %510, %507 ], [ %512, %511 ]
store i64 %514, i64* %3
br label %515
515: ; preds = %513, %243, %214, %164, %49
%516 = load i64, i64* %3
ret i64 %516
}

LLVM IR (-O2):
@mc_rand_binomial.n_last = internal thread_local unnamed_addr global i64 -1
@mc_rand_binomial.n_prev = internal thread_local unnamed_addr global i64 -1
@mc_rand_binomial.par = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.np = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.p0 = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.q = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.p_last = internal thread_local unnamed_addr global double -1.000000e+00
@mc_rand_binomial.p_prev = internal thread_local unnamed_addr global double -1.000000e+00
@mc_rand_binomial.b = internal thread_local unnamed_addr global i64 0
@mc_rand_binomial.m = internal thread_local unnamed_addr global i64 0
@mc_rand_binomial.nm = internal thread_local unnamed_addr global i64 0
@mc_rand_binomial.pq = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.rc = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.ss = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.xm = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.xl = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.xr = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.ll = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.lr = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.c = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.p1 = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.p2 = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.p3 = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.p4 = internal thread_local unnamed_addr global double 0.000000e+00
@mc_rand_binomial.ch = internal thread_local unnamed_addr global double 0.000000e+00
define i64 @mc_rand_binomial(i64 %0, double %1) {
%3 = load i64, i64* @mc_rand_binomial.n_last
%4 = icmp ne i64 %3, %0
%5 = load double, double* @mc_rand_binomial.p_last
%6 = fcmp une double %5, %1
%7 = select i1 %4, i1 true, i1 %6
br i1 %7, label %8, label %74
8: ; preds = %2
store i64 %0, i64* @mc_rand_binomial.n_last
store double %1, double* @mc_rand_binomial.p_last
%9 = fsub double 1.000000e+00, %1
%10 = fcmp ogt double %9, %1
%11 = select i1 %10, double %1, double %9
store double %11, double* @mc_rand_binomial.par
%12 = fsub double 1.000000e+00, %11
store double %12, double* @mc_rand_binomial.q
%13 = sitofp i64 %0 to double
%14 = fmul double %11, %13
store double %14, double* @mc_rand_binomial.np
%15 = fcmp ugt double %14, 0.000000e+00
br i1 %15, label %16, label %330
16: ; preds = %8
%17 = fadd double %11, %14
%18 = fptosi double %17 to i64
store i64 %18, i64* @mc_rand_binomial.m
%19 = fcmp olt double %14, 1.000000e+01
br i1 %19, label %20, label %32
20: ; preds = %16
%21 = tail call double @log(double %12)
%22 = fmul double %21, %13
%23 = tail call double @exp(double %22)
store double %23, double* @mc_rand_binomial.p0
%24 = load double, double* @mc_rand_binomial.np
%25 = load double, double* @mc_rand_binomial.q
%26 = fmul double %24, %25
%27 = tail call double @sqrt(double %26)
%28 = tail call double @llvm.fmuladd.f64(double %27, double 1.000000e+01, double %24)
%29 = fptosi double %28 to i64
%30 = icmp sgt i64 %29, %0
%31 = select i1 %30, i64 %0, i64 %29
store i64 %31, i64* @mc_rand_binomial.b
br label %74
32: ; preds = %16
%33 = fdiv double %11, %12
store double %33, double* @mc_rand_binomial.pq
%34 = fadd double %13, 1.000000e+00
%35 = fmul double %34, %33
store double %35, double* @mc_rand_binomial.rc
%36 = fmul double %14, %12
store double %36, double* @mc_rand_binomial.ss
%37 = tail call double @sqrt(double %36)
%38 = load double, double* @mc_rand_binomial.q
%39 = fmul double %38, -4.600000e+00
%40 = tail call double @llvm.fmuladd.f64(double %37, double 2.195000e+00, double %39)
%41 = fptosi double %40 to i64
%42 = load i64, i64* @mc_rand_binomial.m
%43 = sitofp i64 %42 to double
%44 = fadd double %43, 5.000000e-01
store double %44, double* @mc_rand_binomial.xm
%45 = sub nsw i64 %42, %41
%46 = sitofp i64 %45 to double
store double %46, double* @mc_rand_binomial.xl
%47 = add i64 %42, 1
%48 = add i64 %47, %41
%49 = sitofp i64 %48 to double
store double %49, double* @mc_rand_binomial.xr
%50 = fsub double %17, %46
%51 = load double, double* @mc_rand_binomial.par
%52 = fneg double %46
%53 = tail call double @llvm.fmuladd.f64(double %52, double %51, double %17)
%54 = fdiv double %50, %53
%55 = tail call double @llvm.fmuladd.f64(double %54, double 5.000000e-01, double 1.000000e+00)
%56 = fmul double %54, %55
store double %56, double* @mc_rand_binomial.ll
%57 = fsub double %49, %17
%58 = fmul double %38, %49
%59 = fdiv double %57, %58
%60 = tail call double @llvm.fmuladd.f64(double %59, double 5.000000e-01, double 1.000000e+00)
%61 = fmul double %59, %60
store double %61, double* @mc_rand_binomial.lr
%62 = fadd double %43, 1.530000e+01
%63 = fdiv double 2.050000e+01, %62
%64 = fadd double %63, 1.340000e-01
store double %64, double* @mc_rand_binomial.c
%65 = sitofp i64 %41 to double
%66 = fadd double %65, 5.000000e-01
store double %66, double* @mc_rand_binomial.p1
%67 = fadd double %64, 1.000000e+00
%68 = fadd double %64, %67
%69 = fmul double %66, %68
store double %69, double* @mc_rand_binomial.p2
%70 = fdiv double %64, %56
%71 = fadd double %69, %70
store double %71, double* @mc_rand_binomial.p3
%72 = fdiv double %64, %61
%73 = fadd double %72, %71
store double %73, double* @mc_rand_binomial.p4
br label %74
74: ; preds = %2, %20, %32
%75 = load double, double* @mc_rand_binomial.np
%76 = fcmp ugt double %75, 0.000000e+00
br i1 %76, label %77, label %330
77: ; preds = %74
%78 = fcmp olt double %75, 1.000000e+01
br i1 %78, label %91, label %79
79: ; preds = %77
%80 = tail call i32 (...) @mc_randf()
%81 = sitofp i32 %80 to double
%82 = tail call i32 (...) @mc_randf()
%83 = sitofp i32 %82 to double
%84 = load double, double* @mc_rand_binomial.p4
%85 = fmul double %84, %83
%86 = load double, double* @mc_rand_binomial.p1
%87 = fcmp ugt double %85, %86
br i1 %87, label %88, label %132
88: ; preds = %79
%89 = sitofp i64 %0 to double
%90 = fadd double %89, 1.000000e+00
br label %143
91: ; preds = %77
%92 = load double, double* @mc_rand_binomial.p0
%93 = tail call i32 (...) @mc_randf()
%94 = sitofp i32 %93 to double
%95 = fcmp olt double %92, %94
br i1 %95, label %96, label %127
96: ; preds = %91
%97 = load i64, i64* @mc_rand_binomial.b
br label %98
98: ; preds = %96, %121
%99 = phi i64 [ %97, %96 ], [ %122, %121 ]
%100 = phi double [ %92, %96 ], [ %125, %121 ]
%101 = phi double [ %94, %96 ], [ %124, %121 ]
%102 = phi i64 [ 0, %96 ], [ %123, %121 ]
%103 = add nsw i64 %102, 1
%104 = icmp slt i64 %102, %99
br i1 %104, label %110, label %105
105: ; preds = %98
%106 = tail call i32 (...) @mc_randf()
%107 = sitofp i32 %106 to double
%108 = load double, double* @mc_rand_binomial.p0
%109 = load i64, i64* @mc_rand_binomial.b
br label %121
110: ; preds = %98
%111 = fsub double %101, %100
%112 = sub i64 %0, %102
%113 = sitofp i64 %112 to double
%114 = load double, double* @mc_rand_binomial.par
%115 = fmul double %114, %113
%116 = fmul double %100, %115
%117 = sitofp i64 %103 to double
%118 = load double, double* @mc_rand_binomial.q
%119 = fmul double %118, %117
%120 = fdiv double %116, %119
br label %121
121: ; preds = %110, %105
%122 = phi i64 [ %109, %105 ], [ %99, %110 ]
%123 = phi i64 [ 0, %105 ], [ %103, %110 ]
%124 = phi double [ %107, %105 ], [ %111, %110 ]
%125 = phi double [ %108, %105 ], [ %120, %110 ]
%126 = fcmp ogt double %124, %125
br i1 %126, label %98, label %127
127: ; preds = %121, %91
%128 = phi i64 [ 0, %91 ], [ %123, %121 ]
%129 = fcmp ogt double %1, 5.000000e-01
%130 = sub nsw i64 %0, %128
%131 = select i1 %129, i64 %130, i64 %128
br label %330
132: ; preds = %317, %79
%133 = phi double [ %81, %79 ], [ %319, %317 ]
%134 = phi double [ %85, %79 ], [ %323, %317 ]
%135 = phi double [ %86, %79 ], [ %324, %317 ]
%136 = load double, double* @mc_rand_binomial.xm
%137 = fsub double %136, %134
%138 = tail call double @llvm.fmuladd.f64(double %135, double %133, double %137)
%139 = fptosi double %138 to i64
%140 = fcmp ogt double %1, 5.000000e-01
%141 = sub nsw i64 %0, %139
%142 = select i1 %140, i64 %141, i64 %139
br label %330
143: ; preds = %88, %317
%144 = phi double [ %86, %88 ], [ %324, %317 ]
%145 = phi double [ %85, %88 ], [ %323, %317 ]
%146 = phi double [ %81, %88 ], [ %319, %317 ]
%147 = load double, double* @mc_rand_binomial.p2
%148 = fcmp ugt double %145, %147
br i1 %148, label %164, label %149
149: ; preds = %143
%150 = load double, double* @mc_rand_binomial.xl
%151 = fsub double %145, %144
%152 = load double, double* @mc_rand_binomial.c
%153 = fdiv double %151, %152
%154 = fadd double %150, %153
%155 = tail call double @llvm.fmuladd.f64(double %146, double %152, double 1.000000e+00)
%156 = load double, double* @mc_rand_binomial.xm
%157 = fsub double %156, %154
%158 = tail call double @llvm.fabs.f64(double %157)
%159 = fdiv double %158, %144
%160 = fsub double %155, %159
%161 = fcmp ult double %160, 1.000000e+00
br i1 %161, label %162, label %317
162: ; preds = %149
%163 = fptosi double %154 to i64
br label %193
164: ; preds = %143
%165 = load double, double* @mc_rand_binomial.p3
%166 = fcmp ugt double %145, %165
br i1 %166, label %180, label %167
167: ; preds = %164
%168 = load double, double* @mc_rand_binomial.xl
%169 = tail call double @log(double %146)
%170 = load double, double* @mc_rand_binomial.ll
%171 = fdiv double %169, %170
%172 = fadd double %168, %171
%173 = fcmp olt double %172, 0.000000e+00
br i1 %173, label %317, label %174
174: ; preds = %167
%175 = fptosi double %172 to i64
%176 = load double, double* @mc_rand_binomial.p2
%177 = fsub double %145, %176
%178 = fmul double %170, %177
%179 = fmul double %146, %178
br label %193
180: ; preds = %164
%181 = load double, double* @mc_rand_binomial.xr
%182 = tail call double @log(double %146)
%183 = load double, double* @mc_rand_binomial.lr
%184 = fdiv double %182, %183
%185 = fsub double %181, %184
%186 = fptosi double %185 to i64
%187 = icmp sgt i64 %186, %0
br i1 %187, label %317, label %188
188: ; preds = %180
%189 = load double, double* @mc_rand_binomial.p3
%190 = fsub double %145, %189
%191 = fmul double %183, %190
%192 = fmul double %146, %191
br label %193
193: ; preds = %174, %188, %162
%194 = phi i64 [ %163, %162 ], [ %175, %174 ], [ %186, %188 ]
%195 = phi double [ %160, %162 ], [ %179, %174 ], [ %192, %188 ]
%196 = load i64, i64* @mc_rand_binomial.m
%197 = sub nsw i64 %194, %196
%198 = tail call i64 @llvm.abs.i64(i64 %197, i1 true)
%199 = icmp ult i64 %198, 21
br i1 %199, label %206, label %200
200: ; preds = %193
%201 = shl nuw nsw i64 %198, 1
%202 = add nuw nsw i64 %201, 2
%203 = sitofp i64 %202 to double
%204 = load double, double* @mc_rand_binomial.ss
%205 = fcmp ugt double %204, %203
br i1 %205, label %236, label %206
206: ; preds = %200, %193
%207 = icmp sgt i64 %194, %196
%208 = load double, double* @mc_rand_binomial.rc
%209 = load double, double* @mc_rand_binomial.pq
br i1 %207, label %210, label %221
210: ; preds = %206, %214
%211 = phi double [ %219, %214 ], [ 1.000000e+00, %206 ]
%212 = phi i64 [ %215, %214 ], [ %196, %206 ]
%213 = icmp slt i64 %212, %194
br i1 %213, label %214, label %232
214: ; preds = %210
%215 = add nsw i64 %212, 1
%216 = sitofp i64 %215 to double
%217 = fdiv double %208, %216
%218 = fsub double %217, %209
%219 = fmul double %211, %218
%220 = fcmp olt double %219, %195
br i1 %220, label %232, label %210
221: ; preds = %206, %225
%222 = phi double [ %230, %225 ], [ %195, %206 ]
%223 = phi i64 [ %226, %225 ], [ %194, %206 ]
%224 = icmp eq i64 %223, %196
br i1 %224, label %232, label %225
225: ; preds = %221
%226 = add i64 %223, 1
%227 = sitofp i64 %226 to double
%228 = fdiv double %208, %227
%229 = fsub double %228, %209
%230 = fmul double %222, %229
%231 = fcmp ogt double %230, 1.000000e+00
br i1 %231, label %232, label %221
232: ; preds = %221, %225, %210, %214
%233 = phi double [ %211, %210 ], [ %219, %214 ], [ 1.000000e+00, %225 ], [ 1.000000e+00, %221 ]
%234 = phi double [ %195, %214 ], [ %195, %210 ], [ %222, %221 ], [ %230, %225 ]
%235 = fcmp ugt double %234, %233
br i1 %235, label %317, label %326
236: ; preds = %200
%237 = tail call double @log(double %195)
%238 = mul i64 %197, %197
%239 = sub i64 0, %238
%240 = sitofp i64 %239 to double
%241 = load double, double* @mc_rand_binomial.ss
%242 = fadd double %241, %241
%243 = fdiv double %240, %242
%244 = sitofp i64 %198 to double
%245 = tail call double @llvm.fmuladd.f64(double %244, double 0x3FD5555555555555, double 6.250000e-01)
%246 = tail call double @llvm.fmuladd.f64(double %244, double %245, double 0x3FC5555555555555)
%247 = insertelement <2 x double> poison, double %244, i64 0
%248 = insertelement <2 x double> %247, double %246, i64 1
%249 = insertelement <2 x double> poison, double %241, i64 0
%250 = shufflevector <2 x double> %249, <2 x double> poison, <2 x i32> zeroinitializer
%251 = fdiv <2 x double> %248, %250
%252 = extractelement <2 x double> %251, i64 1
%253 = fadd double %252, 5.000000e-01
%254 = extractelement <2 x double> %251, i64 0
%255 = fmul double %254, %253
%256 = fsub double %243, %255
%257 = fcmp ugt double %237, %256
br i1 %257, label %258, label %326
258: ; preds = %236
%259 = fadd double %243, %255
%260 = fcmp ugt double %237, %259
br i1 %260, label %317, label %261
261: ; preds = %258
%262 = load i64, i64* @mc_rand_binomial.n_prev
%263 = icmp ne i64 %262, %0
%264 = load double, double* @mc_rand_binomial.par
%265 = load double, double* @mc_rand_binomial.p_prev
%266 = fcmp une double %264, %265
%267 = select i1 %263, i1 true, i1 %266
br i1 %267, label %270, label %268
268: ; preds = %261
%269 = load double, double* @mc_rand_binomial.ch
br label %291
270: ; preds = %261
store i64 %0, i64* @mc_rand_binomial.n_prev
store double %264, double* @mc_rand_binomial.p_prev
%271 = load i64, i64* @mc_rand_binomial.m
%272 = sub nsw i64 %0, %271
%273 = add nsw i64 %272, 1
store i64 %273, i64* @mc_rand_binomial.nm
%274 = load double, double* @mc_rand_binomial.xm
%275 = sitofp i64 %271 to double
%276 = fadd double %275, 1.000000e+00
%277 = load double, double* @mc_rand_binomial.pq
%278 = sitofp i64 %273 to double
%279 = fmul double %277, %278
%280 = fdiv double %276, %279
%281 = tail call double @log(double %280)
%282 = load i64, i64* @mc_rand_binomial.m
%283 = add nsw i64 %282, 1
%284 = tail call i32 (i64, ...) bitcast (i32 (...)* @_stirling_correction to i32 (i64, ...)*)(i64 %283)
%285 = sitofp i32 %284 to double
%286 = tail call double @llvm.fmuladd.f64(double %274, double %281, double %285)
%287 = load i64, i64* @mc_rand_binomial.nm
%288 = tail call i32 (i64, ...) bitcast (i32 (...)* @_stirling_correction to i32 (i64, ...)*)(i64 %287)
%289 = sitofp i32 %288 to double
%290 = fadd double %286, %289
store double %290, double* @mc_rand_binomial.ch
br label %291
291: ; preds = %268, %270
%292 = phi double [ %269, %268 ], [ %290, %270 ]
%293 = sub nsw i64 %0, %194
%294 = add nsw i64 %293, 1
%295 = load i64, i64* @mc_rand_binomial.nm
%296 = sitofp i64 %295 to double
%297 = sitofp i64 %294 to double
%298 = fdiv double %296, %297
%299 = tail call double @log(double %298)
%300 = tail call double @llvm.fmuladd.f64(double %90, double %299, double %292)
%301 = sitofp i64 %194 to double
%302 = fadd double %301, 5.000000e-01
%303 = load double, double* @mc_rand_binomial.pq
%304 = fmul double %303, %297
%305 = fadd double %301, 1.000000e+00
%306 = fdiv double %304, %305
%307 = tail call double @log(double %306)
%308 = tail call double @llvm.fmuladd.f64(double %302, double %307, double %300)
%309 = add nsw i64 %194, 1
%310 = tail call i32 (i64, ...) bitcast (i32 (...)* @_stirling_correction to i32 (i64, ...)*)(i64 %309)
%311 = sitofp i32 %310 to double
%312 = fsub double %308, %311
%313 = tail call i32 (i64, ...) bitcast (i32 (...)* @_stirling_correction to i32 (i64, ...)*)(i64 %294)
%314 = sitofp i32 %313 to double
%315 = fsub double %312, %314
%316 = fcmp ugt double %237, %315
br i1 %316, label %317, label %326
317: ; preds = %232, %291, %258, %149, %167, %180
%318 = tail call i32 (...) @mc_randf()
%319 = sitofp i32 %318 to double
%320 = tail call i32 (...) @mc_randf()
%321 = sitofp i32 %320 to double
%322 = load double, double* @mc_rand_binomial.p4
%323 = fmul double %322, %321
%324 = load double, double* @mc_rand_binomial.p1
%325 = fcmp ugt double %323, %324
br i1 %325, label %143, label %132
326: ; preds = %291, %236, %232
%327 = fcmp ogt double %1, 5.000000e-01
%328 = sub nsw i64 %0, %194
%329 = select i1 %327, i64 %328, i64 %194
br label %330
330: ; preds = %74, %8, %326, %132, %127
%331 = phi i64 [ %131, %127 ], [ %142, %132 ], [ %329, %326 ], [ -1, %8 ], [ -1, %74 ]
ret i64 %331
}