void cdflib_beta_grat(const double *a, const double *b, const double *x,
                      const double *y, double *w, const double *eps,
                      int *ierr) {
  double bm1, bp2n, cn, coef, dj, j, l, lnx, n2, nu, p, q, r, s, sum, t, t2, u,
      v, z;
  int i, n, nm1;
  double c[30], d[30], T1;
  bm1 = *b - 0.5e0 - 0.5e0;
  nu = *a + 0.5e0 * bm1;
  if (*y > 0.375e0) {
    goto S10;
  }
  T1 = -*y;
  lnx = cdflib_alnrel(&T1);
  goto S20;
S10:
  lnx = log(*x);
S20:
  z = -(nu * lnx);
  if (*b * z == 0.0e0) {
    goto S70;
  }
  r = *b * (1.0e0 + cdflib_gam1(b)) * exp(*b * log(z));
  r *= (exp(*a * lnx) * exp(0.5e0 * bm1 * lnx));
  u = cdflib_algdiv(b, a) + *b * log(nu);
  u = r * exp(-u);
  if (u == 0.0e0) {
    goto S70;
  }
  cdflib_gamma_rat1(b, &z, &r, &p, &q, eps);
  v = 0.25e0 * pow(1.0e0 / nu, 2.0);
  t2 = 0.25e0 * lnx * lnx;
  l = *w / u;
  j = q / r;
  sum = j;
  t = cn = 1.0e0;
  n2 = 0.0e0;
  for (n = 1; n <= 30; n++) {
    bp2n = *b + n2;
    j = (bp2n * (bp2n + 1.0e0) * j + (z + bp2n + 1.0e0) * t) * v;
    n2 = n2 + 2.0e0;
    t *= t2;
    cn /= (n2 * (n2 + 1.0e0));
    c[n - 1] = cn;
    s = 0.0e0;
    if (n == 1) {
      goto S40;
    }
    nm1 = n - 1;
    coef = *b - (double)n;
    for (i = 1; i <= nm1; i++) {
      s = s + (coef * c[i - 1] * d[n - i - 1]);
      coef = coef + *b;
    }
  S40:
    d[n - 1] = bm1 * cn + s / (double)n;
    dj = d[n - 1] * j;
    sum = sum + dj;
    if (sum <= 0.0e0) {
      goto S70;
    }
    if (fabs(dj) <= *eps * (sum + l)) {
      goto S60;
    }
  }
S60:
  *ierr = 0;
  *w = *w + (u * sum);
  return;
S70:
  *ierr = 1;
  return;
}


x86 assembly (clang, -O0):
<cdflib_beta_grat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x300,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe61(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe55(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  0xe37(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe12(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11fd <cdflib_beta_grat+0x8d>
jmp    1240 <cdflib_beta_grat+0xd0>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x2c8(%rbp)
ff
lea    -0x2c8(%rbp),%rdi
mov    $0x0,%al
call   1030 <cdflib_alnrel@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    1252 <cdflib_beta_grat+0xe2>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
call   1080 <log@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x80(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mulsd  -0xd0(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12a3 <cdflib_beta_grat+0x133>
jp     12a3 <cdflib_beta_grat+0x133>
jmp    17d7 <cdflib_beta_grat+0x667>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x300(%rbp)
ff
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1050 <cdflib_gam1@plt>
movsd  -0x300(%rbp),%xmm0
ff
cvtsi2sd %eax,%xmm2
movsd  0xd3e(%rip),%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x2f0(%rbp)
ff
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x2f8(%rbp)
ff
movsd  -0xd0(%rbp),%xmm0
ff
call   1080 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x2f8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
call   1070 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x2f0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mulsd  -0x70(%rbp),%xmm0
call   1070 <exp@plt>
movsd  %xmm0,-0x2e8(%rbp)
ff
movsd  0xcbc(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
call   1070 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x2e8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
mulsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0x98(%rbp)
ff
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1060 <cdflib_algdiv@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x2e0(%rbp)
ff
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x2d8(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
call   1080 <log@plt>
movsd  -0x2e0(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x2d8(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0x2d0(%rbp)
ff
movsd  -0xc0(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1070 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x2d0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0xc0(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    143d <cdflib_beta_grat+0x2cd>
jp     143d <cdflib_beta_grat+0x2cd>
jmp    17d7 <cdflib_beta_grat+0x667>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%r9
lea    -0xd0(%rbp),%rsi
lea    -0x98(%rbp),%rdx
lea    -0x88(%rbp),%rcx
lea    -0x90(%rbp),%r8
mov    $0x0,%al
call   1040 <cdflib_gamma_rat1@plt>
movsd  0xba0(%rip),%xmm0
divsd  -0x80(%rbp),%xmm0
movsd  0xba3(%rip),%xmm1
call   1090 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xb8b(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  0xb77(%rip),%xmm0
mulsd  -0x70(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0xc0(%rbp),%xmm0
ff
movsd  %xmm0,-0x68(%rbp)
movsd  -0x90(%rbp),%xmm0
ff
divsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  0xb1e(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xb11(%rip),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x78(%rbp)
movl   $0x1,-0xd8(%rbp)
cmpl   $0x1e,-0xd8(%rbp)
jg     179b <cdflib_beta_grat+0x62b>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
addsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xacb(%rip),%xmm1
addsd  -0x40(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x60(%rbp),%xmm2
movsd  -0xd0(%rbp),%xmm1
ff
addsd  -0x40(%rbp),%xmm1
movsd  0xaa8(%rip),%xmm3
addsd  %xmm3,%xmm1
mulsd  -0xb0(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0xc8(%rbp),%xmm0
ff
movsd  %xmm0,-0x60(%rbp)
movsd  0xa8f(%rip),%xmm0
addsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0xb8(%rbp),%xmm0
ff
mulsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x78(%rbp),%xmm1
movsd  0xa50(%rip),%xmm0
addsd  -0x78(%rbp),%xmm0
mulsd  %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0xd8(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  %xmm0,-0x1d0(%rbp,%rax,8)
ff ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
cmpl   $0x1,-0xd8(%rbp)
jne    160d <cdflib_beta_grat+0x49d>
jmp    16c7 <cdflib_beta_grat+0x557>
mov    -0xd8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xdc(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
cvtsi2sdl -0xd8(%rbp),%xmm1
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x1,-0xd4(%rbp)
mov    -0xd4(%rbp),%eax
cmp    -0xdc(%rbp),%eax
jg     16c2 <cdflib_beta_grat+0x552>
movsd  -0xa0(%rbp),%xmm1
ff
movsd  -0x50(%rbp),%xmm0
mov    -0xd4(%rbp),%eax
sub    $0x1,%eax
cltq
mulsd  -0x1d0(%rbp,%rax,8),%xmm0
ff ff
mov    -0xd8(%rbp),%eax
sub    -0xd4(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x2c0(%rbp,%rax,8),%xmm2
ff ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
mov    -0x10(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    163f <cdflib_beta_grat+0x4cf>
jmp    16c7 <cdflib_beta_grat+0x557>
movsd  -0x38(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0xa0(%rbp),%xmm1
ff
cvtsi2sdl -0xd8(%rbp),%xmm3
ff
divsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0xd8(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  %xmm0,-0x2c0(%rbp,%rax,8)
ff ff
mov    -0xd8(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x2c0(%rbp,%rax,8),%xmm0
ff ff
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0xa8(%rbp),%xmm0
ff
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
xorps  %xmm0,%xmm0
ucomisd -0xa8(%rbp),%xmm0
ff
jb     174a <cdflib_beta_grat+0x5da>
jmp    17d7 <cdflib_beta_grat+0x667>
movsd  -0x58(%rbp),%xmm1
movaps 0x8da(%rip),%xmm0
pand   %xmm0,%xmm1
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0xa8(%rbp),%xmm2
ff
addsd  -0x68(%rbp),%xmm2
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jb     1782 <cdflib_beta_grat+0x612>
jmp    17a0 <cdflib_beta_grat+0x630>
jmp    1787 <cdflib_beta_grat+0x617>
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    1519 <cdflib_beta_grat+0x3a9>
jmp    17a0 <cdflib_beta_grat+0x630>
mov    0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0xc0(%rbp),%xmm0
ff
movsd  -0xa8(%rbp),%xmm2
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    17e1 <cdflib_beta_grat+0x671>
mov    0x10(%rbp),%rax
movl   $0x1,(%rax)
add    $0x300,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdflib_beta_grat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x268,%rsp
mov    %r9,%r15
mov    %r8,%r14
mov    %rsi,%rbp
mov    %rdi,%r12
movsd  0xe7b(%rip),%xmm0
movsd  (%rsi),%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe6f(%rip),%xmm2
movsd  %xmm1,0x48(%rsp)
mulsd  %xmm1,%xmm2
movsd  (%rdi),%xmm1
addsd  %xmm2,%xmm1
movsd  (%rcx),%xmm0
ucomisd 0xe59(%rip),%xmm0
movapd %xmm1,0x20(%rsp)
movsd  %xmm2,0x18(%rsp)
jbe    11d6 <cdflib_beta_grat+0x76>
movsd  (%rdx),%xmm0
call   1080 <log@plt>
movapd 0x20(%rsp),%xmm1
jmp    11fd <cdflib_beta_grat+0x9d>
xorpd  0xe62(%rip),%xmm0
movlpd %xmm0,0x50(%rsp)
lea    0x50(%rsp),%rdi
xor    %eax,%eax
call   1030 <cdflib_alnrel@plt>
movapd 0x20(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    0x2a0(%rsp),%r13
movapd 0xe33(%rip),%xmm5
xorpd  %xmm1,%xmm5
mulsd  %xmm0,%xmm5
movsd  %xmm5,0x38(%rsp)
movsd  0x0(%rbp),%xmm4
movapd %xmm5,%xmm2
mulsd  %xmm4,%xmm2
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm2
jne    1238 <cdflib_beta_grat+0xd8>
jnp    133c <cdflib_beta_grat+0x1dc>
mov    %rbp,%rdi
xor    %eax,%eax
movsd  %xmm0,0x10(%rsp)
movsd  %xmm4,(%rsp)
movapd %xmm5,0x60(%rsp)
call   1050 <cdflib_gam1@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0xdb6(%rip),%xmm0
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x0(%rbp),%xmm0
movsd  %xmm0,0x40(%rsp)
movapd 0x60(%rsp),%xmm0
call   1080 <log@plt>
mulsd  0x40(%rsp),%xmm0
call   1070 <exp@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%r12),%xmm0
mulsd  0x10(%rsp),%xmm0
call   1070 <exp@plt>
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
call   1070 <exp@plt>
mulsd  (%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbp,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <cdflib_algdiv@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x0(%rbp),%xmm0
movsd  %xmm0,0x18(%rsp)
movapd 0x20(%rsp),%xmm0
call   1080 <log@plt>
mulsd  0x18(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  %xmm1,(%rsp)
xorpd  0xd1f(%rip),%xmm0
call   1070 <exp@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
ucomisd 0xcf8(%rip),%xmm0
jne    1356 <cdflib_beta_grat+0x1f6>
jp     1356 <cdflib_beta_grat+0x1f6>
movl   $0x1,0x0(%r13)
add    $0x268,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
lea    0x38(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x78(%rsp),%rcx
lea    0x58(%rsp),%r8
mov    %rbp,%rdi
mov    %r15,%r9
xor    %eax,%eax
call   1040 <cdflib_gamma_rat1@plt>
movsd  0xc97(%rip),%xmm0
movapd %xmm0,%xmm14
divsd  0x20(%rsp),%xmm14
mulsd  %xmm14,%xmm14
movsd  0xc85(%rip),%xmm10
mulsd  %xmm10,%xmm14
movsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm10
mulsd  %xmm1,%xmm10
movsd  (%r14),%xmm1
movsd  %xmm1,0x20(%rsp)
movapd %xmm1,%xmm7
divsd  (%rsp),%xmm7
movsd  0x58(%rsp),%xmm5
divsd  0x8(%rsp),%xmm5
movsd  0x0(%rbp),%xmm11
movsd  0x38(%rsp),%xmm12
lea    0x168(%rsp),%rax
mov    $0x1,%ecx
movapd %xmm0,%xmm15
movapd %xmm0,%xmm1
movapd %xmm5,%xmm3
xorpd  %xmm4,%xmm4
xorpd  %xmm13,%xmm13
addsd  0xc1f(%rip),%xmm13
movapd %xmm13,%xmm6
addsd  %xmm0,%xmm6
mulsd  %xmm13,%xmm6
divsd  %xmm6,%xmm15
movsd  %xmm15,0x78(%rsp,%rcx,8)
xorps  %xmm8,%xmm8
cvtsi2sd %ecx,%xmm8
xorpd  %xmm6,%xmm6
cmp    $0x1,%rcx
je     1520 <cdflib_beta_grat+0x3c0>
movapd %xmm14,%xmm0
movapd %xmm12,%xmm14
movapd %xmm10,%xmm2
movapd %xmm11,%xmm9
subsd  %xmm8,%xmm9
cmp    $0x1,%rbx
jne    1470 <cdflib_beta_grat+0x310>
xorpd  %xmm6,%xmm6
mov    $0x1,%edx
jmp    14e8 <cdflib_beta_grat+0x388>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rsi
and    $0xfffffffffffffffe,%rsi
neg    %rsi
xorpd  %xmm12,%xmm12
mov    $0x1,%edx
mov    %rax,%rdi
movapd %xmm9,%xmm10
nopl   0x0(%rax)
movapd %xmm11,%xmm6
addsd  %xmm10,%xmm6
mulsd  0x78(%rsp,%rdx,8),%xmm10
mulsd  (%rdi),%xmm10
movapd %xmm11,%xmm9
addsd  %xmm6,%xmm9
mulsd  0x80(%rsp,%rdx,8),%xmm6
addsd  %xmm12,%xmm10
mulsd  -0x8(%rdi),%xmm6
addsd  %xmm10,%xmm6
add    $0xfffffffffffffff0,%rdi
lea    (%rsi,%rdx,1),%rbp
add    $0x2,%rbp
add    $0x2,%rdx
movapd %xmm9,%xmm10
movapd %xmm6,%xmm12
cmp    $0x1,%rbp
jne    1490 <cdflib_beta_grat+0x330>
test   $0x1,%bl
movapd %xmm2,%xmm10
movapd %xmm14,%xmm12
movapd %xmm0,%xmm14
movsd  0xb16(%rip),%xmm0
je     1520 <cdflib_beta_grat+0x3c0>
mulsd  0x78(%rsp,%rdx,8),%xmm9
not    %rdx
add    %rcx,%rdx
mulsd  0x170(%rsp,%rdx,8),%xmm9
addsd  %xmm9,%xmm6
addsd  %xmm11,%xmm4
movapd %xmm4,%xmm2
addsd  %xmm0,%xmm2
mulsd  %xmm4,%xmm2
mulsd  %xmm2,%xmm5
addsd  %xmm12,%xmm4
addsd  %xmm0,%xmm4
mulsd  %xmm1,%xmm4
addsd  %xmm4,%xmm5
mulsd  %xmm14,%xmm5
divsd  %xmm8,%xmm6
movsd  0x48(%rsp),%xmm2
mulsd  %xmm15,%xmm2
addsd  %xmm6,%xmm2
movsd  %xmm2,0x168(%rsp,%rcx,8)
mulsd  %xmm5,%xmm2
addsd  %xmm2,%xmm3
xorpd  %xmm4,%xmm4
ucomisd %xmm3,%xmm4
jae    133c <cdflib_beta_grat+0x1dc>
andpd  0xaca(%rip),%xmm2
movapd %xmm7,%xmm4
addsd  %xmm3,%xmm4
mulsd  (%r15),%xmm4
ucomisd %xmm2,%xmm4
jae    15b9 <cdflib_beta_grat+0x459>
mulsd  %xmm10,%xmm1
add    $0x1,%rcx
add    $0x1,%rbx
add    $0x8,%rax
movapd %xmm13,%xmm4
cmp    $0x1f,%rcx
jne    1400 <cdflib_beta_grat+0x2a0>
movl   $0x0,0x0(%r13)
movsd  (%rsp),%xmm0
mulsd  %xmm3,%xmm0
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%r14)
jmp    1344 <cdflib_beta_grat+0x1e4>

LLVM IR (-O0):
define void @cdflib_beta_grat(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5, i32* %6) {
%8 = alloca double*
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca i32*
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
%27 = alloca double
%28 = alloca double
%29 = alloca double
%30 = alloca double
%31 = alloca double
%32 = alloca double
%33 = alloca double
%34 = alloca double
%35 = alloca i32
%36 = alloca i32
%37 = alloca i32
%38 = alloca [30 x double]
%39 = alloca [30 x double]
%40 = alloca double
store double* %0, double** %8
store double* %1, double** %9
store double* %2, double** %10
store double* %3, double** %11
store double* %4, double** %12
store double* %5, double** %13
store i32* %6, i32** %14
%41 = load double*, double** %9
%42 = load double, double* %41
%43 = fsub double %42, 5.000000e-01
%44 = fsub double %43, 5.000000e-01
store double %44, double* %15
%45 = load double*, double** %8
%46 = load double, double* %45
%47 = load double, double* %15
%48 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %47, double %46)
store double %48, double* %24
%49 = load double*, double** %11
%50 = load double, double* %49
%51 = fcmp ogt double %50, 3.750000e-01
br i1 %51, label %52, label %53
52: ; preds = %7
br label %59
53: ; preds = %7
%54 = load double*, double** %11
%55 = load double, double* %54
%56 = fneg double %55
store double %56, double* %40
%57 = call i32 (double*, ...) bitcast (i32 (...)* @cdflib_alnrel to i32 (double*, ...)*)(double* %40)
%58 = sitofp i32 %57 to double
store double %58, double* %22
br label %63
59: ; preds = %52
%60 = load double*, double** %10
%61 = load double, double* %60
%62 = call double @log(double %61)
store double %62, double* %22
br label %63
63: ; preds = %59, %53
%64 = load double, double* %24
%65 = load double, double* %22
%66 = fmul double %64, %65
%67 = fneg double %66
store double %67, double* %34
%68 = load double*, double** %9
%69 = load double, double* %68
%70 = load double, double* %34
%71 = fmul double %69, %70
%72 = fcmp oeq double %71, 0.000000e+00
br i1 %72, label %73, label %74
73: ; preds = %63
br label %266
74: ; preds = %63
%75 = load double*, double** %9
%76 = load double, double* %75
%77 = load double*, double** %9
%78 = call i32 (double*, ...) bitcast (i32 (...)* @cdflib_gam1 to i32 (double*, ...)*)(double* %77)
%79 = sitofp i32 %78 to double
%80 = fadd double 1.000000e+00, %79
%81 = fmul double %76, %80
%82 = load double*, double** %9
%83 = load double, double* %82
%84 = load double, double* %34
%85 = call double @log(double %84)
%86 = fmul double %83, %85
%87 = call double @exp(double %86)
%88 = fmul double %81, %87
store double %88, double* %27
%89 = load double*, double** %8
%90 = load double, double* %89
%91 = load double, double* %22
%92 = fmul double %90, %91
%93 = call double @exp(double %92)
%94 = load double, double* %15
%95 = fmul double 5.000000e-01, %94
%96 = load double, double* %22
%97 = fmul double %95, %96
%98 = call double @exp(double %97)
%99 = fmul double %93, %98
%100 = load double, double* %27
%101 = fmul double %100, %99
store double %101, double* %27
%102 = load double*, double** %9
%103 = load double*, double** %8
%104 = call i32 (double*, double*, ...) bitcast (i32 (...)* @cdflib_algdiv to i32 (double*, double*, ...)*)(double* %102, double* %103)
%105 = sitofp i32 %104 to double
%106 = load double*, double** %9
%107 = load double, double* %106
%108 = load double, double* %24
%109 = call double @log(double %108)
%110 = call double @llvm.fmuladd.f64(double %107, double %109, double %105)
store double %110, double* %32
%111 = load double, double* %27
%112 = load double, double* %32
%113 = fneg double %112
%114 = call double @exp(double %113)
%115 = fmul double %111, %114
store double %115, double* %32
%116 = load double, double* %32
%117 = fcmp oeq double %116, 0.000000e+00
br i1 %117, label %118, label %119
118: ; preds = %74
br label %266
119: ; preds = %74
%120 = load double*, double** %9
%121 = load double*, double** %13
%122 = call i32 (double*, double*, double*, double*, double*, double*, ...) bitcast (i32 (...)* @cdflib_gamma_rat1 to i32 (double*, double*, double*, double*, double*, double*, ...)*)(double* %120, double* %34, double* %27, double* %25, double* %26, double* %121)
%123 = load double, double* %24
%124 = fdiv double 1.000000e+00, %123
%125 = call double @pow(double %124, double 2.000000e+00)
%126 = fmul double 2.500000e-01, %125
store double %126, double* %33
%127 = load double, double* %22
%128 = fmul double 2.500000e-01, %127
%129 = load double, double* %22
%130 = fmul double %128, %129
store double %130, double* %31
%131 = load double*, double** %12
%132 = load double, double* %131
%133 = load double, double* %32
%134 = fdiv double %132, %133
store double %134, double* %21
%135 = load double, double* %26
%136 = load double, double* %27
%137 = fdiv double %135, %136
store double %137, double* %20
%138 = load double, double* %20
store double %138, double* %29
store double 1.000000e+00, double* %17
store double 1.000000e+00, double* %30
store double 0.000000e+00, double* %23
store i32 1, i32* %36
br label %139
139: ; preds = %254, %119
%140 = load i32, i32* %36
%141 = icmp sle i32 %140, 30
br i1 %141, label %142, label %257
142: ; preds = %139
%143 = load double*, double** %9
%144 = load double, double* %143
%145 = load double, double* %23
%146 = fadd double %144, %145
store double %146, double* %16
%147 = load double, double* %16
%148 = load double, double* %16
%149 = fadd double %148, 1.000000e+00
%150 = fmul double %147, %149
%151 = load double, double* %20
%152 = load double, double* %34
%153 = load double, double* %16
%154 = fadd double %152, %153
%155 = fadd double %154, 1.000000e+00
%156 = load double, double* %30
%157 = fmul double %155, %156
%158 = call double @llvm.fmuladd.f64(double %150, double %151, double %157)
%159 = load double, double* %33
%160 = fmul double %158, %159
store double %160, double* %20
%161 = load double, double* %23
%162 = fadd double %161, 2.000000e+00
store double %162, double* %23
%163 = load double, double* %31
%164 = load double, double* %30
%165 = fmul double %164, %163
store double %165, double* %30
%166 = load double, double* %23
%167 = load double, double* %23
%168 = fadd double %167, 1.000000e+00
%169 = fmul double %166, %168
%170 = load double, double* %17
%171 = fdiv double %170, %169
store double %171, double* %17
%172 = load double, double* %17
%173 = load i32, i32* %36
%174 = sub nsw i32 %173, 1
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds [30 x double], [30 x double]* %38, i64 0, i64 %175
store double %172, double* %176
store double 0.000000e+00, double* %28
%177 = load i32, i32* %36
%178 = icmp eq i32 %177, 1
br i1 %178, label %179, label %180
179: ; preds = %142
br label %217
180: ; preds = %142
%181 = load i32, i32* %36
%182 = sub nsw i32 %181, 1
store i32 %182, i32* %37
%183 = load double*, double** %9
%184 = load double, double* %183
%185 = load i32, i32* %36
%186 = sitofp i32 %185 to double
%187 = fsub double %184, %186
store double %187, double* %18
store i32 1, i32* %35
br label %188
188: ; preds = %213, %180
%189 = load i32, i32* %35
%190 = load i32, i32* %37
%191 = icmp sle i32 %189, %190
br i1 %191, label %192, label %216
192: ; preds = %188
%193 = load double, double* %28
%194 = load double, double* %18
%195 = load i32, i32* %35
%196 = sub nsw i32 %195, 1
%197 = sext i32 %196 to i64
%198 = getelementptr inbounds [30 x double], [30 x double]* %38, i64 0, i64 %197
%199 = load double, double* %198
%200 = fmul double %194, %199
%201 = load i32, i32* %36
%202 = load i32, i32* %35
%203 = sub nsw i32 %201, %202
%204 = sub nsw i32 %203, 1
%205 = sext i32 %204 to i64
%206 = getelementptr inbounds [30 x double], [30 x double]* %39, i64 0, i64 %205
%207 = load double, double* %206
%208 = call double @llvm.fmuladd.f64(double %200, double %207, double %193)
store double %208, double* %28
%209 = load double, double* %18
%210 = load double*, double** %9
%211 = load double, double* %210
%212 = fadd double %209, %211
store double %212, double* %18
br label %213
213: ; preds = %192
%214 = load i32, i32* %35
%215 = add nsw i32 %214, 1
store i32 %215, i32* %35
br label %188
216: ; preds = %188
br label %217
217: ; preds = %216, %179
%218 = load double, double* %15
%219 = load double, double* %17
%220 = load double, double* %28
%221 = load i32, i32* %36
%222 = sitofp i32 %221 to double
%223 = fdiv double %220, %222
%224 = call double @llvm.fmuladd.f64(double %218, double %219, double %223)
%225 = load i32, i32* %36
%226 = sub nsw i32 %225, 1
%227 = sext i32 %226 to i64
%228 = getelementptr inbounds [30 x double], [30 x double]* %39, i64 0, i64 %227
store double %224, double* %228
%229 = load i32, i32* %36
%230 = sub nsw i32 %229, 1
%231 = sext i32 %230 to i64
%232 = getelementptr inbounds [30 x double], [30 x double]* %39, i64 0, i64 %231
%233 = load double, double* %232
%234 = load double, double* %20
%235 = fmul double %233, %234
store double %235, double* %19
%236 = load double, double* %29
%237 = load double, double* %19
%238 = fadd double %236, %237
store double %238, double* %29
%239 = load double, double* %29
%240 = fcmp ole double %239, 0.000000e+00
br i1 %240, label %241, label %242
241: ; preds = %217
br label %266
242: ; preds = %217
%243 = load double, double* %19
%244 = call double @llvm.fabs.f64(double %243)
%245 = load double*, double** %13
%246 = load double, double* %245
%247 = load double, double* %29
%248 = load double, double* %21
%249 = fadd double %247, %248
%250 = fmul double %246, %249
%251 = fcmp ole double %244, %250
br i1 %251, label %252, label %253
252: ; preds = %242
br label %258
253: ; preds = %242
br label %254
254: ; preds = %253
%255 = load i32, i32* %36
%256 = add nsw i32 %255, 1
store i32 %256, i32* %36
br label %139
257: ; preds = %139
br label %258
258: ; preds = %257, %252
%259 = load i32*, i32** %14
store i32 0, i32* %259
%260 = load double*, double** %12
%261 = load double, double* %260
%262 = load double, double* %32
%263 = load double, double* %29
%264 = call double @llvm.fmuladd.f64(double %262, double %263, double %261)
%265 = load double*, double** %12
store double %264, double* %265
br label %268
266: ; preds = %241, %118, %73
%267 = load i32*, i32** %14
store i32 1, i32* %267
br label %268
268: ; preds = %266, %258
ret void
}

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