#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(float);
float floor(float);
float log(float);
float sqrt(double);
float tan(float);
float bnldev(float pp, int n, long *idum) {
  float gammln(float xx);
  float ran1(long *idum);
  int j;
  static int nold = (-1);
  float am, em, g, angle, p, bnl, sq, t, y;
  static float 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 = 1; j <= n; j++)
      if (ran1(idum) < p)
        ++bnl;
  } else if (am < 1.0) {
    g = exp(-am);
    t = 1.0;
    for (j = 0; j <= n; j++) {
      t *= ran1(idum);
      if (t < g)
        break;
    }
    bnl = (j <= n ? j : n);
  } else {
    if (n != nold) {
      en = n;
      oldg = gammln(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 = 3.141592654 * ran1(idum);
        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 - gammln(em + 1.0) - gammln(en - em + 1.0) + em * plog +
              (en - em) * pclog);
    } while (ran1(idum) > t);
    bnl = em;
  }
  if (p != pp)
    bnl = n - bnl;
  return bnl;
}


x86 assembly (clang, -O0):
<bnldev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe6b(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     11b2 <bnldev+0x42>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11cc <bnldev+0x5c>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe45(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
cvtsi2ssl -0x8(%rbp),%xmm0
mulss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
cmpl   $0x19,-0x8(%rbp)
jge    1252 <bnldev+0xe2>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     124d <bnldev+0xdd>
mov    -0x10(%rbp),%rdi
call   1050 <ran1@plt>
movaps %xmm0,%xmm1
movss  -0x28(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    123a <bnldev+0xca>
movss  0xdf8(%rip),%xmm0
addss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
jmp    123f <bnldev+0xcf>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1202 <bnldev+0x92>
jmp    15ce <bnldev+0x45e>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xda5(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1319 <bnldev+0x1a9>
movss  -0x18(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
call   1030 <exp@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  0xd93(%rip),%xmm0
movss  %xmm0,-0x34(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     12eb <bnldev+0x17b>
mov    -0x10(%rbp),%rdi
call   1050 <ran1@plt>
mulss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm1
movss  -0x20(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    12d8 <bnldev+0x168>
jmp    12eb <bnldev+0x17b>
jmp    12dd <bnldev+0x16d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12a1 <bnldev+0x131>
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1302 <bnldev+0x192>
mov    -0x14(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    1308 <bnldev+0x198>
mov    -0x8(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x2c(%rbp)
jmp    15c9 <bnldev+0x459>
mov    -0x8(%rbp),%eax
cmp    0x2d36(%rip),%eax
je     1367 <bnldev+0x1f7>
cvtsi2ssl -0x8(%rbp),%xmm0
movss  %xmm0,0x2d3b(%rip)
movss  0x2d33(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcbf(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1080 <gammln@plt>
movss  %xmm0,0x2d16(%rip)
mov    -0x8(%rbp),%eax
mov    %eax,0x2cf1(%rip)
movss  -0x28(%rbp),%xmm0
ucomiss 0x2ce9(%rip),%xmm0
jne    1384 <bnldev+0x214>
jp     1384 <bnldev+0x214>
jmp    13d9 <bnldev+0x269>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xc73(%rip),%xmm0
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x2cbf(%rip)
movss  -0x28(%rbp),%xmm0
call   1060 <log@plt>
movss  %xmm0,0x2cb1(%rip)
movss  0x2ca5(%rip),%xmm0
call   1060 <log@plt>
movss  %xmm0,0x2ca0(%rip)
movss  -0x28(%rbp),%xmm0
movss  %xmm0,0x2c83(%rip)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xc26(%rip),%xmm0
mulsd  %xmm1,%xmm0
movss  0x2c6e(%rip),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
movss  %xmm0,-0x30(%rbp)
jmp    140d <bnldev+0x29d>
mov    -0x10(%rbp),%rdi
call   1050 <ran1@plt>
cvtss2sd %xmm0,%xmm1
movsd  0xbf6(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
call   1040 <tan@plt>
movss  %xmm0,-0x38(%rbp)
movss  -0x30(%rbp),%xmm0
movss  -0x38(%rbp),%xmm2
movss  -0x18(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
mov    $0x1,%al
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
mov    %al,-0x45(%rbp)
ja     14a0 <bnldev+0x330>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x2bea(%rip),%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xb76(%rip),%xmm2
addsd  %xmm2,%xmm1
ucomisd %xmm1,%xmm0
setae  %al
mov    %al,-0x45(%rbp)
mov    -0x45(%rbp),%al
test   $0x1,%al
jne    140d <bnldev+0x29d>
movss  -0x1c(%rbp),%xmm0
call   1090 <floor@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x30(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xb55(%rip),%xmm0
mulsd  %xmm1,%xmm0
movss  -0x38(%rbp),%xmm1
mulss  -0x38(%rbp),%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xb23(%rip),%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movss  0x2b7a(%rip),%xmm0
movss  %xmm0,-0x58(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xaf8(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1080 <gammln@plt>
movaps %xmm0,%xmm1
movss  -0x58(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x54(%rbp)
movss  0x2b3a(%rip),%xmm0
subss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xac1(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1080 <gammln@plt>
movaps %xmm0,%xmm1
movss  -0x54(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  -0x1c(%rbp),%xmm1
movss  0x2afb(%rip),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  0x2af3(%rip),%xmm0
subss  -0x1c(%rbp),%xmm0
movss  0x2ae2(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <ran1@plt>
ucomiss -0x34(%rbp),%xmm0
ja     1408 <bnldev+0x298>
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
jmp    15ce <bnldev+0x45e>
movss  -0x28(%rbp),%xmm0
ucomiss -0x4(%rbp),%xmm0
jne    15e8 <bnldev+0x478>
jp     15e8 <bnldev+0x478>
jmp    15f7 <bnldev+0x487>
cvtsi2ssl -0x8(%rbp),%xmm0
subss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bnldev>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
movss  0xe7b(%rip),%xmm3
movaps %xmm3,%xmm1
movaps %xmm0,%xmm4
cmpnless 0xe70(%rip),%xmm4
subss  %xmm0,%xmm1
andps  %xmm4,%xmm1
andnps %xmm0,%xmm4
orps   %xmm1,%xmm4
movaps %xmm4,%xmm2
xorps  %xmm1,%xmm1
cvtsi2ss %edi,%xmm1
cmp    $0x18,%edi
movaps %xmm0,0x50(%rsp)
movaps %xmm1,0x40(%rsp)
jg     1210 <bnldev+0xa0>
test   %ebp,%ebp
jle    14a1 <bnldev+0x331>
xorps  %xmm0,%xmm0
movss  %xmm2,(%rsp)
nopw   0x0(%rax,%rax,1)
movaps %xmm0,0x10(%rsp)
mov    %r14,%rdi
call   1060 <ran1@plt>
movss  (%rsp),%xmm2
movaps %xmm0,%xmm3
movaps 0x10(%rsp),%xmm1
movaps %xmm1,%xmm0
addss  0xe0b(%rip),%xmm0
cmpltss %xmm2,%xmm3
andps  %xmm3,%xmm0
andnps %xmm1,%xmm3
orps   %xmm0,%xmm3
movaps %xmm3,%xmm0
add    $0xffffffff,%ebp
jne    11d0 <bnldev+0x60>
jmp    14b2 <bnldev+0x342>
mulss  %xmm1,%xmm4
ucomiss %xmm4,%xmm3
movss  %xmm2,(%rsp)
jbe    1287 <bnldev+0x117>
xorps  0xe0b(%rip),%xmm4
movaps %xmm4,%xmm0
call   1040 <exp@plt>
movss  0xdcb(%rip),%xmm1
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
add    $0x1,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movss  %xmm1,0x10(%rsp)
mov    %r14,%rdi
call   1060 <ran1@plt>
movaps %xmm0,%xmm1
mulss  0x10(%rsp),%xmm1
movss  0x8(%rsp),%xmm0
ucomiss %xmm1,%xmm0
ja     14a6 <bnldev+0x336>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1250 <bnldev+0xe0>
movaps 0x40(%rsp),%xmm3
jmp    14ad <bnldev+0x33d>
cmp    %ebp,0x2dcb(%rip)
movaps %xmm4,0x10(%rsp)
je     12c5 <bnldev+0x155>
movss  %xmm1,0x2dd4(%rip)
movss  0xd5c(%rip),%xmm0
addss  %xmm1,%xmm0
call   1090 <gammln@plt>
movaps 0x10(%rsp),%xmm4
movss  (%rsp),%xmm2
movss  %xmm0,0x2db5(%rip)
mov    %ebp,0x2d93(%rip)
xorps  %xmm1,%xmm1
cvtss2sd %xmm4,%xmm1
movss  0x2d88(%rip),%xmm0
ucomiss %xmm2,%xmm0
jne    12db <bnldev+0x16b>
jnp    132d <bnldev+0x1bd>
movss  0xd1d(%rip),%xmm0
subss  %xmm2,%xmm0
movss  %xmm0,0x2d75(%rip)
movaps %xmm2,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1070 <log@plt>
movss  %xmm0,0x2d63(%rip)
movss  0x2d57(%rip),%xmm0
call   1070 <log@plt>
movsd  0x8(%rsp),%xmm1
movss  (%rsp),%xmm2
movss  %xmm0,0x2d47(%rip)
movss  %xmm2,0x2d2f(%rip)
addsd  %xmm1,%xmm1
movss  0x2d2b(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
call   1080 <sqrt@plt>
movss  %xmm0,0x8(%rsp)
cvtss2sd %xmm0,%xmm0
mulsd  0xcb8(%rip),%xmm0
movsd  %xmm0,0x30(%rsp)
xchg   %ax,%ax
mov    %r14,%rdi
call   1060 <ran1@plt>
cvtss2sd %xmm0,%xmm0
mulsd  0xca4(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <tan@plt>
movaps %xmm0,%xmm3
movss  0x8(%rsp),%xmm0
mulss  %xmm3,%xmm0
addss  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     1360 <bnldev+0x1f0>
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movss  0x2cc8(%rip),%xmm2
cvtss2sd %xmm2,%xmm2
addsd  0xc6c(%rip),%xmm2
ucomisd %xmm2,%xmm1
jae    1360 <bnldev+0x1f0>
movss  %xmm3,0x4(%rsp)
call   1030 <floorf@plt>
movaps %xmm0,0x20(%rsp)
movss  0x4(%rsp),%xmm1
mulss  %xmm1,%xmm1
cvtss2sd %xmm1,%xmm1
addsd  0xc40(%rip),%xmm1
mulsd  0x30(%rsp),%xmm1
movsd  %xmm1,0x38(%rsp)
movss  0x2c80(%rip),%xmm1
movss  %xmm1,0x4(%rsp)
movss  0xbfe(%rip),%xmm1
addss  %xmm1,%xmm0
call   1090 <gammln@plt>
movss  0x4(%rsp),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,0x4(%rsp)
movss  0x2c4d(%rip),%xmm0
subss  0x20(%rsp),%xmm0
addss  0xbcf(%rip),%xmm0
call   1090 <gammln@plt>
movss  0x4(%rsp),%xmm3
subss  %xmm0,%xmm3
movss  0x2c20(%rip),%xmm1
movaps 0x20(%rsp),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm3,%xmm1
movss  0x2c13(%rip),%xmm0
subss  %xmm2,%xmm0
mulss  0x2c03(%rip),%xmm0
addss  %xmm1,%xmm0
call   1040 <exp@plt>
mulsd  0x38(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
mov    %r14,%rdi
call   1060 <ran1@plt>
ucomiss 0x4(%rsp),%xmm0
ja     1360 <bnldev+0x1f0>
movss  (%rsp),%xmm2
movaps 0x20(%rsp),%xmm3
jmp    14b2 <bnldev+0x342>
xorps  %xmm3,%xmm3
jmp    14b2 <bnldev+0x342>
xorps  %xmm3,%xmm3
cvtsi2ss %ebx,%xmm3
movss  (%rsp),%xmm2
movaps 0x40(%rsp),%xmm1
subss  %xmm3,%xmm1
movaps 0x50(%rsp),%xmm0
cmpneqss %xmm2,%xmm0
andps  %xmm0,%xmm1
andnps %xmm3,%xmm0
orps   %xmm1,%xmm0
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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