#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double exp(double);
double floor(double);
double lgamma(double);
double log(double);
double const rand_lp();
double sqrt(double);
double tan(double);
double rbinom(const double pp, const int n) {
  const double PI = 3.141592653589793238;
  int j;
  static int nold = (-1);
  double am, em, g, angle, p, bnl, sq, t, y;
  static double pold = (-1.0), pc, plog, pclog, en, oldg;
  p = (pp <= 0.5 ? pp : 1.0 - pp);
  am = n * p;
  if (n < 25) {
    bnl = 0.0;
    for (j = 0; j < n; j++) {
      if (rand_lp() < p)
        ++bnl;
    }
  } else if (am < 1.0) {
    g = exp(-am);
    t = 1.0;
    for (j = 0; j <= n; j++) {
      t *= rand_lp();
      if (t < g)
        break;
    }
    bnl = (j <= n ? j : n);
  } else {
    if (n != nold) {
      en = n;
      oldg = lgamma(en + 1.0);
      nold = n;
    }
    if (p != pold) {
      pc = 1.0 - p;
      plog = log(p);
      pclog = log(pc);
      pold = p;
    }
    sq = sqrt(2.0 * am * pc);
    do {
      do {
        angle = PI * rand_lp();
        y = tan(angle);
        em = sq * y + am;
      } while (em < 0.0 || em >= (en + 1.0));
      em = floor(em);
      t = 1.2 * sq * (1.0 + y * y) *
          exp(oldg - lgamma(em + 1.0) - lgamma(en - em + 1.0) + em * plog +
              (en - em) * pclog);
    } while (rand_lp() > t);
    bnl = em;
  }
  if (p != pp)
    bnl = n - bnl;
  return bnl;
}


x86 assembly (clang, -O0):
<rbinom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movsd  0xe7d(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe68(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     11b2 <rbinom+0x42>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    11c4 <rbinom+0x54>
movsd  0xe56(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x19,-0xc(%rbp)
jge    1245 <rbinom+0xd5>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1240 <rbinom+0xd0>
mov    $0x0,%al
call   1070 <rand_lp@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    122d <rbinom+0xbd>
movsd  0xded(%rip),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1232 <rbinom+0xc2>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f6 <rbinom+0x86>
jmp    1567 <rbinom+0x3f7>
movsd  0xdc3(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1309 <rbinom+0x199>
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xd8a(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     12db <rbinom+0x16b>
mov    $0x0,%al
call   1070 <rand_lp@plt>
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12c8 <rbinom+0x158>
jmp    12db <rbinom+0x16b>
jmp    12cd <rbinom+0x15d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1292 <rbinom+0x122>
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     12f2 <rbinom+0x182>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x74(%rbp)
jmp    12f8 <rbinom+0x188>
mov    -0xc(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1562 <rbinom+0x3f2>
mov    -0xc(%rbp),%eax
cmp    0x2d46(%rip),%eax
je     134b <rbinom+0x1db>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  %xmm0,0x2d63(%rip)
movsd  0xce3(%rip),%xmm0
addsd  0x2d53(%rip),%xmm0
call   1040 <lgamma@plt>
movsd  %xmm0,0x2d4e(%rip)
mov    -0xc(%rbp),%eax
mov    %eax,0x2d0d(%rip)
movsd  -0x48(%rbp),%xmm0
ucomisd 0x2d08(%rip),%xmm0
jne    1369 <rbinom+0x1f9>
jp     1369 <rbinom+0x1f9>
jmp    13b2 <rbinom+0x242>
movsd  0xc9f(%rip),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,0x2cf2(%rip)
movsd  -0x48(%rbp),%xmm0
call   1060 <log@plt>
movsd  %xmm0,0x2ce8(%rip)
movsd  0x2cd8(%rip),%xmm0
call   1060 <log@plt>
movsd  %xmm0,0x2cdb(%rip)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,0x2cae(%rip)
movsd  0xc5e(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  0x2ca9(%rip),%xmm0
call   1080 <sqrt@plt>
movsd  %xmm0,-0x58(%rbp)
jmp    13d6 <rbinom+0x266>
mov    $0x0,%al
call   1070 <rand_lp@plt>
movaps %xmm0,%xmm1
movsd  0xc20(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1050 <tan@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    $0x1,%al
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
mov    %al,-0x75(%rbp)
ja     144e <rbinom+0x2de>
movsd  -0x30(%rbp),%xmm0
movsd  0xbd4(%rip),%xmm1
addsd  0x2c44(%rip),%xmm1
ucomisd %xmm1,%xmm0
setae  %al
mov    %al,-0x75(%rbp)
mov    -0x75(%rbp),%al
test   $0x1,%al
jne    13d6 <rbinom+0x266>
movsd  -0x30(%rbp),%xmm0
call   1090 <floor@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xbb0(%rip),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xb85(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0x2bf0(%rip),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  0xb60(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
call   1040 <lgamma@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0x2baf(%rip),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  0xb2a(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <lgamma@plt>
movaps %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  0x2b6d(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0x2b6d(%rip),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  0x2b58(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    $0x0,%al
call   1070 <rand_lp@plt>
ucomisd -0x60(%rbp),%xmm0
ja     13d1 <rbinom+0x261>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1567 <rbinom+0x3f7>
movsd  -0x48(%rbp),%xmm0
ucomisd -0x8(%rbp),%xmm0
jne    1582 <rbinom+0x412>
jp     1582 <rbinom+0x412>
jmp    1591 <rbinom+0x421>
cvtsi2sdl -0xc(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rbinom>:
push   %rbp
push   %rbx
sub    $0x78,%rsp
mov    %edi,%ebx
movsd  0xe80(%rip),%xmm3
movapd %xmm3,%xmm2
subsd  %xmm0,%xmm2
movapd %xmm0,%xmm4
cmplesd 0xe73(%rip),%xmm4
movapd %xmm4,%xmm1
andpd  %xmm0,%xmm1
andnpd %xmm2,%xmm4
orpd   %xmm1,%xmm4
movapd %xmm4,%xmm2
xorps  %xmm1,%xmm1
cvtsi2sd %edi,%xmm1
cmp    $0x18,%edi
movapd %xmm0,0x60(%rsp)
movapd %xmm1,0x20(%rsp)
jg     1227 <rbinom+0xb7>
test   %ebx,%ebx
jle    1360 <rbinom+0x1f0>
xorpd  %xmm0,%xmm0
movsd  %xmm2,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movapd %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1070 <rand_lp@plt>
movsd  (%rsp),%xmm2
movapd %xmm0,%xmm3
movapd 0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
addsd  0xdf8(%rip),%xmm0
cmpltsd %xmm2,%xmm3
andpd  %xmm3,%xmm0
andnpd %xmm1,%xmm3
orpd   %xmm0,%xmm3
movapd %xmm3,%xmm0
add    $0xffffffff,%ebx
jne    11e0 <rbinom+0x70>
jmp    14cc <rbinom+0x35c>
mulsd  %xmm1,%xmm4
ucomisd %xmm4,%xmm3
movsd  %xmm2,(%rsp)
jbe    129e <rbinom+0x12e>
xorpd  0xdf2(%rip),%xmm4
movapd %xmm4,%xmm0
call   1030 <exp@plt>
movsd  0xdb1(%rip),%xmm1
movsd  %xmm0,0x8(%rsp)
add    $0x1,%ebx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movsd  %xmm1,0x10(%rsp)
xor    %eax,%eax
call   1070 <rand_lp@plt>
movapd %xmm0,%xmm1
mulsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
ucomisd %xmm1,%xmm0
ja     1369 <rbinom+0x1f9>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1260 <rbinom+0xf0>
movapd 0x20(%rsp),%xmm3
movsd  (%rsp),%xmm2
jmp    14cc <rbinom+0x35c>
cmp    %ebx,0x2db4(%rip)
movapd %xmm4,0x30(%rsp)
je     12ec <rbinom+0x17c>
movapd 0x20(%rsp),%xmm1
movsd  %xmm1,0x2dce(%rip)
movsd  0xd3e(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1040 <lgamma@plt>
movapd 0x30(%rsp),%xmm4
movsd  0xd27(%rip),%xmm3
movsd  (%rsp),%xmm2
movsd  %xmm0,0x2daa(%rip)
mov    %ebx,0x2d6c(%rip)
ucomisd 0x2d6c(%rip),%xmm2
jne    12f8 <rbinom+0x188>
jnp    1341 <rbinom+0x1d1>
movapd %xmm3,%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,0x2d68(%rip)
movapd %xmm2,%xmm0
call   1060 <log@plt>
movsd  %xmm0,0x2d5f(%rip)
movsd  0x2d4f(%rip),%xmm0
call   1060 <log@plt>
movapd 0x30(%rsp),%xmm4
movsd  (%rsp),%xmm2
movsd  %xmm0,0x2d47(%rip)
movsd  %xmm2,0x2d1f(%rip)
addsd  %xmm4,%xmm4
mulsd  0x2d23(%rip),%xmm4
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm4
jb     137a <rbinom+0x20a>
xorps  %xmm0,%xmm0
sqrtsd %xmm4,%xmm0
jmp    1383 <rbinom+0x213>
xorpd  %xmm3,%xmm3
jmp    14cc <rbinom+0x35c>
xorps  %xmm3,%xmm3
cvtsi2sd %ebp,%xmm3
movsd  (%rsp),%xmm2
jmp    14cc <rbinom+0x35c>
movapd %xmm4,%xmm0
call   1080 <sqrt@plt>
movsd  0xc85(%rip),%xmm1
movsd  %xmm0,0x58(%rsp)
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x50(%rsp)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand_lp@plt>
mulsd  0xc69(%rip),%xmm0
call   1050 <tan@plt>
movapd %xmm0,%xmm2
movsd  0x58(%rsp),%xmm0
mulsd  %xmm2,%xmm0
addsd  0x30(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
movsd  0x2cb0(%rip),%xmm1
addsd  0xc20(%rip),%xmm1
ja     13a0 <rbinom+0x230>
ucomisd %xmm1,%xmm0
jae    13a0 <rbinom+0x230>
movsd  %xmm2,0x10(%rsp)
call   1090 <floor@plt>
movapd %xmm0,%xmm2
movapd %xmm0,0x40(%rsp)
movsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm1
movsd  0xbf1(%rip),%xmm3
addsd  %xmm3,%xmm1
mulsd  0x50(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0x2c69(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
addsd  %xmm3,%xmm2
movapd %xmm2,%xmm0
call   1040 <lgamma@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x2c36(%rip),%xmm0
subsd  0x40(%rsp),%xmm0
addsd  0xba0(%rip),%xmm0
call   1040 <lgamma@plt>
movsd  0x8(%rsp),%xmm3
subsd  %xmm0,%xmm3
movsd  0x2c01(%rip),%xmm1
movapd 0x40(%rsp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm3,%xmm1
movsd  0x2bfb(%rip),%xmm0
subsd  %xmm2,%xmm0
mulsd  0x2be7(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1030 <exp@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1070 <rand_lp@plt>
ucomisd 0x10(%rsp),%xmm0
ja     13a0 <rbinom+0x230>
movsd  (%rsp),%xmm2
movapd 0x40(%rsp),%xmm3
movapd 0x20(%rsp),%xmm1
subsd  %xmm3,%xmm1
movapd 0x60(%rsp),%xmm0
cmpneqsd %xmm2,%xmm0
andpd  %xmm0,%xmm1
andnpd %xmm3,%xmm0
orpd   %xmm1,%xmm0
add    $0x78,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@rbinom.nold = internal global i32 -1
@rbinom.pold = internal global double -1.000000e+00
@rbinom.pc = internal global double 0.000000e+00
@rbinom.plog = internal global double 0.000000e+00
@rbinom.pclog = internal global double 0.000000e+00
@rbinom.en = internal global double 0.000000e+00
@rbinom.oldg = internal global double 0.000000e+00
define double @rbinom(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double %0, double* %3
store i32 %1, i32* %4
store double 0x400921FB54442D18, double* %5
%16 = load double, double* %3
%17 = fcmp ole double %16, 5.000000e-01
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = load double, double* %3
br label %23
20: ; preds = %2
%21 = load double, double* %3
%22 = fsub double 1.000000e+00, %21
br label %23
23: ; preds = %20, %18
%24 = phi double [ %19, %18 ], [ %22, %20 ]
store double %24, double* %11
%25 = load i32, i32* %4
%26 = sitofp i32 %25 to double
%27 = load double, double* %11
%28 = fmul double %26, %27
store double %28, double* %7
%29 = load i32, i32* %4
%30 = icmp slt i32 %29, 25
br i1 %30, label %31, label %48
31: ; preds = %23
store double 0.000000e+00, double* %12
store i32 0, i32* %6
br label %32
32: ; preds = %44, %31
%33 = load i32, i32* %6
%34 = load i32, i32* %4
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %47
36: ; preds = %32
%37 = call double (...) @rand_lp()
%38 = load double, double* %11
%39 = fcmp olt double %37, %38
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load double, double* %12
%42 = fadd double %41, 1.000000e+00
store double %42, double* %12
br label %43
43: ; preds = %40, %36
br label %44
44: ; preds = %43
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
br label %32
47: ; preds = %32
br label %168
48: ; preds = %23
%49 = load double, double* %7
%50 = fcmp olt double %49, 1.000000e+00
br i1 %50, label %51, label %82
51: ; preds = %48
%52 = load double, double* %7
%53 = fneg double %52
%54 = call double @exp(double %53)
store double %54, double* %9
store double 1.000000e+00, double* %14
store i32 0, i32* %6
br label %55
55: ; preds = %68, %51
%56 = load i32, i32* %6
%57 = load i32, i32* %4
%58 = icmp sle i32 %56, %57
br i1 %58, label %59, label %71
59: ; preds = %55
%60 = call double (...) @rand_lp()
%61 = load double, double* %14
%62 = fmul double %61, %60
store double %62, double* %14
%63 = load double, double* %14
%64 = load double, double* %9
%65 = fcmp olt double %63, %64
br i1 %65, label %66, label %67
66: ; preds = %59
br label %71
67: ; preds = %59
br label %68
68: ; preds = %67
%69 = load i32, i32* %6
%70 = add nsw i32 %69, 1
store i32 %70, i32* %6
br label %55
71: ; preds = %66, %55
%72 = load i32, i32* %6
%73 = load i32, i32* %4
%74 = icmp sle i32 %72, %73
br i1 %74, label %75, label %77
75: ; preds = %71
%76 = load i32, i32* %6
br label %79
77: ; preds = %71
%78 = load i32, i32* %4
br label %79
79: ; preds = %77, %75
%80 = phi i32 [ %76, %75 ], [ %78, %77 ]
%81 = sitofp i32 %80 to double
store double %81, double* %12
br label %167
82: ; preds = %48
%83 = load i32, i32* %4
%84 = load i32, i32* @rbinom.nold
%85 = icmp ne i32 %83, %84
br i1 %85, label %86, label %93
86: ; preds = %82
%87 = load i32, i32* %4
%88 = sitofp i32 %87 to double
store double %88, double* @rbinom.en
%89 = load double, double* @rbinom.en
%90 = fadd double %89, 1.000000e+00
%91 = call double @lgamma(double %90)
store double %91, double* @rbinom.oldg
%92 = load i32, i32* %4
store i32 %92, i32* @rbinom.nold
br label %93
93: ; preds = %86, %82
%94 = load double, double* %11
%95 = load double, double* @rbinom.pold
%96 = fcmp une double %94, %95
br i1 %96, label %97, label %105
97: ; preds = %93
%98 = load double, double* %11
%99 = fsub double 1.000000e+00, %98
store double %99, double* @rbinom.pc
%100 = load double, double* %11
%101 = call double @log(double %100)
store double %101, double* @rbinom.plog
%102 = load double, double* @rbinom.pc
%103 = call double @log(double %102)
store double %103, double* @rbinom.pclog
%104 = load double, double* %11
store double %104, double* @rbinom.pold
br label %105
105: ; preds = %97, %93
%106 = load double, double* %7
%107 = fmul double 2.000000e+00, %106
%108 = load double, double* @rbinom.pc
%109 = fmul double %107, %108
%110 = call double @sqrt(double %109)
store double %110, double* %13
br label %111
111: ; preds = %161, %105
br label %112
112: ; preds = %129, %111
%113 = call double (...) @rand_lp()
%114 = fmul double 0x400921FB54442D18, %113
store double %114, double* %10
%115 = load double, double* %10
%116 = call double @tan(double %115)
store double %116, double* %15
%117 = load double, double* %13
%118 = load double, double* %15
%119 = load double, double* %7
%120 = call double @llvm.fmuladd.f64(double %117, double %118, double %119)
store double %120, double* %8
br label %121
121: ; preds = %112
%122 = load double, double* %8
%123 = fcmp olt double %122, 0.000000e+00
br i1 %123, label %129, label %124
124: ; preds = %121
%125 = load double, double* %8
%126 = load double, double* @rbinom.en
%127 = fadd double %126, 1.000000e+00
%128 = fcmp oge double %125, %127
br label %129
129: ; preds = %124, %121
%130 = phi i1 [ true, %121 ], [ %128, %124 ]
br i1 %130, label %112, label %131
131: ; preds = %129
%132 = load double, double* %8
%133 = call double @llvm.floor.f64(double %132)
store double %133, double* %8
%134 = load double, double* %13
%135 = fmul double 1.200000e+00, %134
%136 = load double, double* %15
%137 = load double, double* %15
%138 = call double @llvm.fmuladd.f64(double %136, double %137, double 1.000000e+00)
%139 = fmul double %135, %138
%140 = load double, double* @rbinom.oldg
%141 = load double, double* %8
%142 = fadd double %141, 1.000000e+00
%143 = call double @lgamma(double %142)
%144 = fsub double %140, %143
%145 = load double, double* @rbinom.en
%146 = load double, double* %8
%147 = fsub double %145, %146
%148 = fadd double %147, 1.000000e+00
%149 = call double @lgamma(double %148)
%150 = fsub double %144, %149
%151 = load double, double* %8
%152 = load double, double* @rbinom.plog
%153 = call double @llvm.fmuladd.f64(double %151, double %152, double %150)
%154 = load double, double* @rbinom.en
%155 = load double, double* %8
%156 = fsub double %154, %155
%157 = load double, double* @rbinom.pclog
%158 = call double @llvm.fmuladd.f64(double %156, double %157, double %153)
%159 = call double @exp(double %158)
%160 = fmul double %139, %159
store double %160, double* %14
br label %161
161: ; preds = %131
%162 = call double (...) @rand_lp()
%163 = load double, double* %14
%164 = fcmp ogt double %162, %163
br i1 %164, label %111, label %165
165: ; preds = %161
%166 = load double, double* %8
store double %166, double* %12
br label %167
167: ; preds = %165, %79
br label %168
168: ; preds = %167, %47
%169 = load double, double* %11
%170 = load double, double* %3
%171 = fcmp une double %169, %170
br i1 %171, label %172, label %177
172: ; preds = %168
%173 = load i32, i32* %4
%174 = sitofp i32 %173 to double
%175 = load double, double* %12
%176 = fsub double %174, %175
store double %176, double* %12
br label %177
177: ; preds = %172, %168
%178 = load double, double* %12
ret double %178
}

LLVM IR (-O2):
@rbinom.nold = internal unnamed_addr global i32 -1
@rbinom.pold = internal unnamed_addr global double -1.000000e+00
@rbinom.pc = internal unnamed_addr global double 0.000000e+00
@rbinom.plog = internal unnamed_addr global double 0.000000e+00
@rbinom.pclog = internal unnamed_addr global double 0.000000e+00
@rbinom.en = internal unnamed_addr global double 0.000000e+00
@rbinom.oldg = internal unnamed_addr global double 0.000000e+00
define double @rbinom(double %0, i32 %1) {
%3 = fcmp ole double %0, 5.000000e-01
%4 = fsub double 1.000000e+00, %0
%5 = select i1 %3, double %0, double %4
%6 = sitofp i32 %1 to double
%7 = fmul double %5, %6
%8 = icmp slt i32 %1, 25
br i1 %8, label %9, label %20
9: ; preds = %2
%10 = icmp sgt i32 %1, 0
br i1 %10, label %11, label %90
11: ; preds = %9, %11
%12 = phi i32 [ %18, %11 ], [ 0, %9 ]
%13 = phi double [ %17, %11 ], [ 0.000000e+00, %9 ]
%14 = tail call double (...) @rand_lp()
%15 = fcmp olt double %14, %5
%16 = fadd double %13, 1.000000e+00
%17 = select i1 %15, double %16, double %13
%18 = add nuw nsw i32 %12, 1
%19 = icmp eq i32 %18, %1
br i1 %19, label %90, label %11
20: ; preds = %2
%21 = fcmp olt double %7, 1.000000e+00
br i1 %21, label %22, label %36
22: ; preds = %20
%23 = fneg double %7
%24 = tail call double @exp(double %23)
br label %25
25: ; preds = %22, %33
%26 = phi i32 [ %34, %33 ], [ 0, %22 ]
%27 = phi double [ %29, %33 ], [ 1.000000e+00, %22 ]
%28 = tail call double (...) @rand_lp()
%29 = fmul double %27, %28
%30 = fcmp olt double %29, %24
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = sitofp i32 %26 to double
br label %90
33: ; preds = %25
%34 = add nuw i32 %26, 1
%35 = icmp eq i32 %26, %1
br i1 %35, label %90, label %25
36: ; preds = %20
%37 = load i32, i32* @rbinom.nold
%38 = icmp eq i32 %37, %1
br i1 %38, label %42, label %39
39: ; preds = %36
store double %6, double* @rbinom.en
%40 = fadd double %6, 1.000000e+00
%41 = tail call double @lgamma(double %40)
store double %41, double* @rbinom.oldg
store i32 %1, i32* @rbinom.nold
br label %42
42: ; preds = %39, %36
%43 = load double, double* @rbinom.pold
%44 = fcmp une double %5, %43
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = fsub double 1.000000e+00, %5
store double %46, double* @rbinom.pc
%47 = tail call double @log(double %5)
store double %47, double* @rbinom.plog
%48 = load double, double* @rbinom.pc
%49 = tail call double @log(double %48)
store double %49, double* @rbinom.pclog
store double %5, double* @rbinom.pold
br label %50
50: ; preds = %45, %42
%51 = fmul double %7, 2.000000e+00
%52 = load double, double* @rbinom.pc
%53 = fmul double %51, %52
%54 = tail call double @sqrt(double %53)
%55 = fmul double %54, 1.200000e+00
br label %56
56: ; preds = %66, %50
%57 = tail call double (...) @rand_lp()
%58 = fmul double %57, 0x400921FB54442D18
%59 = tail call double @tan(double %58)
%60 = tail call double @llvm.fmuladd.f64(double %54, double %59, double %7)
%61 = fcmp olt double %60, 0.000000e+00
%62 = load double, double* @rbinom.en
%63 = fadd double %62, 1.000000e+00
%64 = fcmp oge double %60, %63
%65 = select i1 %61, i1 true, i1 %64
br i1 %65, label %66, label %67
66: ; preds = %56, %67
br label %56
67: ; preds = %56
%68 = tail call double @llvm.floor.f64(double %60)
%69 = tail call double @llvm.fmuladd.f64(double %59, double %59, double 1.000000e+00)
%70 = fmul double %55, %69
%71 = load double, double* @rbinom.oldg
%72 = fadd double %68, 1.000000e+00
%73 = tail call double @lgamma(double %72)
%74 = fsub double %71, %73
%75 = load double, double* @rbinom.en
%76 = fsub double %75, %68
%77 = fadd double %76, 1.000000e+00
%78 = tail call double @lgamma(double %77)
%79 = fsub double %74, %78
%80 = load double, double* @rbinom.plog
%81 = tail call double @llvm.fmuladd.f64(double %68, double %80, double %79)
%82 = load double, double* @rbinom.en
%83 = fsub double %82, %68
%84 = load double, double* @rbinom.pclog
%85 = tail call double @llvm.fmuladd.f64(double %83, double %84, double %81)
%86 = tail call double @exp(double %85)
%87 = fmul double %70, %86
%88 = tail call double (...) @rand_lp()
%89 = fcmp ogt double %88, %87
br i1 %89, label %66, label %90
90: ; preds = %67, %33, %11, %31, %9
%91 = phi double [ 0.000000e+00, %9 ], [ %32, %31 ], [ %17, %11 ], [ %6, %33 ], [ %68, %67 ]
%92 = fcmp une double %5, %0
%93 = fsub double %6, %91
%94 = select i1 %92, double %93, double %91
ret double %94
}