#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 HUGE_VAL;
double S_approx(int, int, float);
int /*<<< orphan*/ assert(int);
int digammaRN(int);
double exp(double);
double lgamma(int);
double S_approx_da(int n, int m, float a) {
  double snm;
  assert(a > 0);
  if (n == m)
    return 0.0;
  if (n < m)
    return -HUGE_VAL;
  if (m == 1) {
    return -(digammaRN(n - a) - digammaRN(1 - a));
  }
  snm = S_approx(n, m, a);
  if (m == 2) {
    double ga = lgamma(n - a) - lgamma(1 - a);
    double g2a = lgamma(n - 2 * a) - lgamma(1 - 2 * a);
    double dga = -(digammaRN(n - a) - digammaRN(1 - a));
    double dg2a = -2.0 * (digammaRN(n - 2 * a) - digammaRN(1 - 2 * a));
    return (exp(ga - snm) * dga - exp(g2a - snm) * dg2a - 1) / a;
  } else if (m == 3) {
    double ga = lgamma(n - a) - lgamma(1 - a);
    double g2a = lgamma(n - 2 * a) - lgamma(1 - 2 * a);
    double g3a = lgamma(n - 3 * a) - lgamma(1 - 3 * a);
    double dga = -(digammaRN(n - a) - digammaRN(1 - a));
    double dg2a = -2 * (digammaRN(n - 2 * a) - digammaRN(1 - 2 * a));
    double dg3a = -3 * (digammaRN(n - 3 * a) - digammaRN(1 - 3 * a));
    return -2 / a + (exp(ga - snm) * dga - 2 * exp(g2a - snm) * dg2a +
                     exp(g3a - snm) * dg3a) /
                        2 / a / a;
  } else if (m == 4) {
    double ga = lgamma(n - a) - lgamma(1 - a);
    double g2a = lgamma(n - 2 * a) - lgamma(1 - 2 * a);
    double g3a = lgamma(n - 3 * a) - lgamma(1 - 3 * a);
    double g4a = lgamma(n - 4 * a) - lgamma(1 - 4 * a);
    double dga = -(digammaRN(n - a) - digammaRN(1 - a));
    double dg2a = -2 * (digammaRN(n - 2 * a) - digammaRN(1 - 2 * a));
    double dg3a = -3 * (digammaRN(n - 3 * a) - digammaRN(1 - 3 * a));
    double dg4a = -4 * (digammaRN(n - 4 * a) - digammaRN(1 - 4 * a));
    return -3 / a + (exp(ga - snm) * dga - 3 * exp(g2a - snm) * dg2a +
                     3 * exp(g3a - snm) * dg3a - exp(g4a - snm) * dg4a) /
                        3 / a / a / a;
  }
  return -HUGE_VAL;
}


x86 assembly (clang, -O0):
<S_approx_da>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jne    1197 <S_approx_da+0x47>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1b99 <S_approx_da+0xa49>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11cf <S_approx_da+0x7f>
mov    0x2e3e(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1b99 <S_approx_da+0xa49>
cmpl   $0x1,-0x10(%rbp)
jne    1222 <S_approx_da+0xd2>
cvtsi2ssl -0xc(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,-0xb4(%rbp)
movss  0xe2e(%rip),%xmm0
subss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    -0xb4(%rbp),%ecx
sub    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1b99 <S_approx_da+0xa49>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
movss  -0x14(%rbp),%xmm0
call   1070 <S_approx@plt>
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x2,-0x10(%rbp)
jne    140a <S_approx_da+0x2ba>
cvtsi2ssl -0xc(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,-0xe0(%rbp)
ff
movss  0xdc4(%rip),%xmm0
subss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movaps %xmm0,%xmm1
movsd  -0xe0(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
addss  %xmm1,%xmm1
subss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,-0xd8(%rbp)
ff
movss  -0x14(%rbp),%xmm1
addss  %xmm1,%xmm1
movss  0xd6e(%rip),%xmm0
subss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movaps %xmm0,%xmm1
movsd  -0xd8(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,-0xd0(%rbp)
movss  0xd2c(%rip),%xmm0
subss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    -0xd0(%rbp),%ecx
sub    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
addss  %xmm1,%xmm1
subss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,-0xcc(%rbp)
movss  -0x14(%rbp),%xmm1
addss  %xmm1,%xmm1
movss  0xcd7(%rip),%xmm0
subss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,%ecx
mov    -0xcc(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm1
movsd  0xca4(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1050 <exp@plt>
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x30(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1050 <exp@plt>
movsd  -0xc8(%rbp),%xmm2
ff
movaps %xmm0,%xmm1
movsd  -0xc0(%rbp),%xmm0
ff
mulsd  -0x40(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xc21(%rip),%xmm1
subsd  %xmm1,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1b99 <S_approx_da+0xa49>
cmpl   $0x3,-0x10(%rbp)
jne    1711 <S_approx_da+0x5c1>
cvtsi2ssl -0xc(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,-0x128(%rbp)
ff
movss  0xbf1(%rip),%xmm0
subss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movaps %xmm0,%xmm1
movsd  -0x128(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
addss  %xmm1,%xmm1
subss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,-0x120(%rbp)
ff
movss  -0x14(%rbp),%xmm1
addss  %xmm1,%xmm1
movss  0xb9b(%rip),%xmm0
subss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movaps %xmm0,%xmm1
movsd  -0x120(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
movss  0xb60(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,-0x118(%rbp)
ff
movss  -0x14(%rbp),%xmm0
movss  0xb3a(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xb36(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movaps %xmm0,%xmm1
movsd  -0x118(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,-0x10c(%rbp)
movss  0xaf4(%rip),%xmm0
subss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    -0x10c(%rbp),%ecx
sub    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x60(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
addss  %xmm1,%xmm1
subss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,-0x108(%rbp)
movss  -0x14(%rbp),%xmm1
addss  %xmm1,%xmm1
movss  0xa9f(%rip),%xmm0
subss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,%ecx
mov    -0x108(%rbp),%eax
sub    %ecx,%eax
imul   $0xfffffffe,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x68(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
movss  0xa5f(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,-0x104(%rbp)
movss  -0x14(%rbp),%xmm0
movss  0xa3b(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0xa37(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,%ecx
mov    -0x104(%rbp),%eax
sub    %ecx,%eax
imul   $0xfffffffd,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x70(%rbp)
movss  0xa0d(%rip),%xmm0
divss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0xe8(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1050 <exp@plt>
movsd  %xmm0,-0xf8(%rbp)
ff
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x100(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1050 <exp@plt>
movsd  -0x100(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0xf8(%rbp),%xmm0
ff
movsd  0x98a(%rip),%xmm1
mulsd  %xmm3,%xmm1
mulsd  -0x68(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xf0(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1050 <exp@plt>
movsd  -0xf0(%rbp),%xmm2
ff
movaps %xmm0,%xmm1
movsd  -0xe8(%rbp),%xmm0
ff
movsd  -0x70(%rbp),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0x923(%rip),%xmm2
divsd  %xmm2,%xmm1
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
divsd  %xmm2,%xmm1
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1b99 <S_approx_da+0xa49>
cmpl   $0x4,-0x10(%rbp)
jne    1b68 <S_approx_da+0xa18>
cvtsi2ssl -0xc(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,-0x180(%rbp)
ff
movss  0x8ea(%rip),%xmm0
subss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movaps %xmm0,%xmm1
movsd  -0x180(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
addss  %xmm1,%xmm1
subss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,-0x178(%rbp)
ff
movss  -0x14(%rbp),%xmm1
addss  %xmm1,%xmm1
movss  0x894(%rip),%xmm0
subss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movaps %xmm0,%xmm1
movsd  -0x178(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
movss  0x859(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,-0x170(%rbp)
ff
movss  -0x14(%rbp),%xmm0
movss  0x833(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0x82f(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movaps %xmm0,%xmm1
movsd  -0x170(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
cvtsi2ssl -0xc(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
movss  0x7f5(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,-0x168(%rbp)
ff
movss  -0x14(%rbp),%xmm0
movss  0x7cf(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0x7c7(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1060 <lgamma@plt>
movaps %xmm0,%xmm1
movsd  -0x168(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
cvtsi2ssl -0xc(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,-0x160(%rbp)
movss  0x782(%rip),%xmm0
subss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    -0x160(%rbp),%ecx
sub    %eax,%ecx
xor    %eax,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
cvtsi2ssl -0xc(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
addss  %xmm1,%xmm1
subss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,-0x15c(%rbp)
movss  -0x14(%rbp),%xmm1
addss  %xmm1,%xmm1
movss  0x72a(%rip),%xmm0
subss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,%ecx
mov    -0x15c(%rbp),%eax
sub    %ecx,%eax
imul   $0xfffffffe,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
cvtsi2ssl -0xc(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
movss  0x6e7(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,-0x158(%rbp)
movss  -0x14(%rbp),%xmm0
movss  0x6c3(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0x6bf(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,%ecx
mov    -0x158(%rbp),%eax
sub    %ecx,%eax
imul   $0xfffffffd,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
cvtsi2ssl -0xc(%rbp),%xmm1
movss  -0x14(%rbp),%xmm0
movss  0x680(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,-0x154(%rbp)
movss  -0x14(%rbp),%xmm0
movss  0x65c(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  0x654(%rip),%xmm1
addss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,%ecx
mov    -0x154(%rbp),%eax
sub    %ecx,%eax
imul   $0xfffffffc,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movss  0x61b(%rip),%xmm0
divss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x130(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1050 <exp@plt>
movsd  %xmm0,-0x148(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0x150(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1050 <exp@plt>
movsd  -0x150(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0x148(%rbp),%xmm0
ff
movsd  0x599(%rip),%xmm1
mulsd  %xmm3,%xmm1
mulsd  -0xa0(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x140(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
subsd  -0x20(%rbp),%xmm0
call   1050 <exp@plt>
movsd  -0x140(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  0x541(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  -0xa8(%rbp),%xmm2
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x138(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
subsd  -0x20(%rbp),%xmm0
call   1050 <exp@plt>
movsd  -0x138(%rbp),%xmm2
ff
movaps %xmm0,%xmm1
movsd  -0x130(%rbp),%xmm0
ff
movsd  -0xb0(%rbp),%xmm3
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0x4d1(%rip),%xmm2
divsd  %xmm2,%xmm1
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
divsd  %xmm2,%xmm1
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
divsd  %xmm2,%xmm1
movss  -0x14(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1b99 <S_approx_da+0xa49>
jmp    1b6d <S_approx_da+0xa1d>
jmp    1b72 <S_approx_da+0xa22>
mov    0x246f(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<S_approx_da>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %esi,%ebp
mov    %edi,%ebx
xorps  %xmm1,%xmm1
xor    %edi,%edi
movss  %xmm0,0x4(%rsp)
ucomiss %xmm1,%xmm0
seta   %dil
call   1030 <assert@plt>
xorps  %xmm1,%xmm1
cmp    %ebp,%ebx
je     183a <S_approx_da+0x6ea>
jge    119d <S_approx_da+0x4d>
mov    0x2e5b(%rip),%rax
movsd  (%rax),%xmm1
xorps  0xea8(%rip),%xmm1
jmp    183a <S_approx_da+0x6ea>
cmp    $0x1,%ebp
jne    11df <S_approx_da+0x8f>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
subss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
mov    %eax,%ebx
movss  0xe3e(%rip),%xmm0
subss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%edi
call   1040 <digammaRN@plt>
sub    %ebx,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
jmp    183a <S_approx_da+0x6ea>
mov    %ebx,%edi
mov    %ebp,%esi
movss  0x4(%rsp),%xmm0
call   1070 <S_approx@plt>
cmp    $0x4,%ebp
je     1357 <S_approx_da+0x207>
cmp    $0x3,%ebp
je     1623 <S_approx_da+0x4d3>
cmp    $0x2,%ebp
jne    1186 <S_approx_da+0x36>
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
movss  %xmm1,0x18(%rsp)
movsd  %xmm0,0x38(%rsp)
movaps %xmm1,%xmm0
subss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%r14d
mov    %r14d,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,0x20(%rsp)
movss  0xdc4(%rip),%xmm0
subss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%r15d
mov    %r15d,%edi
call   1060 <lgamma@plt>
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
movss  0xd9d(%rip),%xmm1
mulss  0x4(%rsp),%xmm1
movss  %xmm1,0x8(%rsp)
movss  0x18(%rsp),%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%r12d
mov    %r12d,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,0x18(%rsp)
movss  0x8(%rsp),%xmm0
addss  0xd62(%rip),%xmm0
cvttss2si %xmm0,%ebp
mov    %ebp,%edi
call   1060 <lgamma@plt>
movsd  0x18(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
mov    %r14d,%edi
call   1040 <digammaRN@plt>
mov    %eax,%ebx
mov    %r15d,%edi
call   1040 <digammaRN@plt>
sub    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r12d,%edi
call   1040 <digammaRN@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1040 <digammaRN@plt>
sub    %eax,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x20(%rsp),%xmm0
subsd  0x38(%rsp),%xmm0
call   1050 <exp@plt>
movapd %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
subsd  0x38(%rsp),%xmm0
call   1050 <exp@plt>
movapd 0x20(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
addsd  0xcec(%rip),%xmm1
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  %xmm0,%xmm1
jmp    183a <S_approx_da+0x6ea>
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
movss  %xmm1,0x10(%rsp)
movsd  %xmm0,0x38(%rsp)
movaps %xmm1,%xmm0
subss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%ebx
mov    %ebx,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,0x20(%rsp)
movss  0xc74(%rip),%xmm0
subss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%edi
mov    %edi,0x58(%rsp)
call   1060 <lgamma@plt>
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
movss  0xc4d(%rip),%xmm0
mulss  0x4(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
addss  0x10(%rsp),%xmm0
cvttss2si %xmm0,%edi
mov    %edi,0x50(%rsp)
call   1060 <lgamma@plt>
movsd  %xmm0,0x18(%rsp)
movss  0x8(%rsp),%xmm0
addss  0xc16(%rip),%xmm0
cvttss2si %xmm0,%edi
mov    %edi,0x48(%rsp)
call   1060 <lgamma@plt>
movsd  0x18(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movss  0x4(%rsp),%xmm0
mulss  0xbf3(%rip),%xmm0
movss  %xmm0,0x40(%rsp)
addss  0x10(%rsp),%xmm0
cvttss2si %xmm0,%r13d
mov    %r13d,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,0x8(%rsp)
movss  0x40(%rsp),%xmm0
addss  0xbbe(%rip),%xmm0
cvttss2si %xmm0,%ebp
mov    %ebp,%edi
call   1060 <lgamma@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movss  0xba7(%rip),%xmm1
mulss  0x4(%rsp),%xmm1
movss  %xmm1,0x40(%rsp)
movss  0x10(%rsp),%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%r14d
mov    %r14d,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,0x10(%rsp)
movss  0x40(%rsp),%xmm0
addss  0xb64(%rip),%xmm0
cvttss2si %xmm0,%r15d
mov    %r15d,%edi
call   1060 <lgamma@plt>
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    %ebx,%edi
call   1040 <digammaRN@plt>
mov    %eax,%r12d
mov    0x58(%rsp),%edi
call   1040 <digammaRN@plt>
sub    %r12d,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x58(%rsp)
mov    0x50(%rsp),%edi
call   1040 <digammaRN@plt>
mov    %eax,%ebx
mov    0x48(%rsp),%edi
call   1040 <digammaRN@plt>
sub    %ebx,%eax
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x48(%rsp)
mov    %r13d,%edi
call   1040 <digammaRN@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1040 <digammaRN@plt>
sub    %eax,%ebx
lea    (%rbx,%rbx,2),%eax
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x40(%rsp)
mov    %r14d,%edi
call   1040 <digammaRN@plt>
mov    %eax,%ebx
mov    %r15d,%edi
call   1040 <digammaRN@plt>
sub    %ebx,%eax
shl    $0x2,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x60(%rsp)
movss  0xab6(%rip),%xmm0
divss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x50(%rsp)
movsd  0x20(%rsp),%xmm0
subsd  0x38(%rsp),%xmm0
call   1050 <exp@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
subsd  0x38(%rsp),%xmm0
call   1050 <exp@plt>
mulsd  0xa7e(%rip),%xmm0
mulsd  0x48(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
mulsd  0x58(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
subsd  0x38(%rsp),%xmm0
call   1050 <exp@plt>
mulsd  0xa51(%rip),%xmm0
mulsd  0x40(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
movapd %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
subsd  0x38(%rsp),%xmm0
call   1050 <exp@plt>
movapd 0x20(%rsp),%xmm1
mulsd  0x60(%rsp),%xmm0
subsd  %xmm0,%xmm1
divsd  0xa16(%rip),%xmm1
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  %xmm0,%xmm1
divsd  %xmm0,%xmm1
divsd  %xmm0,%xmm1
addsd  0x50(%rsp),%xmm1
jmp    183a <S_approx_da+0x6ea>
xorps  %xmm1,%xmm1
cvtsi2ss %ebx,%xmm1
movss  %xmm1,0x8(%rsp)
movsd  %xmm0,0x38(%rsp)
movaps %xmm1,%xmm0
subss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%ebx
mov    %ebx,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,0x20(%rsp)
movss  0x9a8(%rip),%xmm0
subss  0x4(%rsp),%xmm0
cvttss2si %xmm0,%r15d
mov    %r15d,%edi
call   1060 <lgamma@plt>
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
movss  0x4(%rsp),%xmm0
mulss  0x97b(%rip),%xmm0
movss  %xmm0,0x10(%rsp)
addss  0x8(%rsp),%xmm0
cvttss2si %xmm0,%r12d
mov    %r12d,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,0x18(%rsp)
movss  0x10(%rsp),%xmm0
addss  0x94a(%rip),%xmm0
cvttss2si %xmm0,%r13d
mov    %r13d,%edi
call   1060 <lgamma@plt>
movsd  0x18(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movss  0x92d(%rip),%xmm1
mulss  0x4(%rsp),%xmm1
movss  %xmm1,0x10(%rsp)
movss  0x8(%rsp),%xmm0
addss  %xmm1,%xmm0
cvttss2si %xmm0,%r14d
mov    %r14d,%edi
call   1060 <lgamma@plt>
movsd  %xmm0,0x8(%rsp)
movss  0x10(%rsp),%xmm0
addss  0x8ee(%rip),%xmm0
cvttss2si %xmm0,%ebp
mov    %ebp,%edi
call   1060 <lgamma@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %ebx,%edi
call   1040 <digammaRN@plt>
mov    %eax,%ebx
mov    %r15d,%edi
call   1040 <digammaRN@plt>
sub    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r12d,%edi
call   1040 <digammaRN@plt>
mov    %eax,%ebx
mov    %r13d,%edi
call   1040 <digammaRN@plt>
sub    %ebx,%eax
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x50(%rsp)
mov    %r14d,%edi
call   1040 <digammaRN@plt>
mov    %eax,%ebx
mov    %ebp,%edi
call   1040 <digammaRN@plt>
sub    %eax,%ebx
lea    (%rbx,%rbx,2),%eax
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x48(%rsp)
movss  0x867(%rip),%xmm0
divss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x58(%rsp)
movsd  0x20(%rsp),%xmm0
subsd  0x38(%rsp),%xmm0
call   1050 <exp@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
subsd  0x38(%rsp),%xmm0
call   1050 <exp@plt>
mulsd  0x843(%rip),%xmm0
mulsd  0x50(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
subsd  0x38(%rsp),%xmm0
call   1050 <exp@plt>
movapd %xmm0,%xmm1
mulsd  0x48(%rsp),%xmm1
addsd  0x20(%rsp),%xmm1
mulsd  0x806(%rip),%xmm1
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
divsd  %xmm0,%xmm1
divsd  %xmm0,%xmm1
addsd  0x58(%rsp),%xmm1
movaps %xmm1,%xmm0
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@HUGE_VAL = global double 0.000000e+00
define double @S_approx_da(i32 %0, i32 %1, float %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
%8 = alloca double
%9 = alloca double
%10 = alloca double
%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
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
%26 = alloca double
store i32 %0, i32* %5
store i32 %1, i32* %6
store float %2, float* %7
%27 = load float, float* %7
%28 = fcmp ogt float %27, 0.000000e+00
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i32, i32* %5
%32 = load i32, i32* %6
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %35
34: ; preds = %3
store double 0.000000e+00, double* %4
br label %386
35: ; preds = %3
%36 = load i32, i32* %5
%37 = load i32, i32* %6
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = load double, double* @HUGE_VAL
%41 = fneg double %40
store double %41, double* %4
br label %386
42: ; preds = %35
%43 = load i32, i32* %6
%44 = icmp eq i32 %43, 1
br i1 %44, label %45, label %59
45: ; preds = %42
%46 = load i32, i32* %5
%47 = sitofp i32 %46 to float
%48 = load float, float* %7
%49 = fsub float %47, %48
%50 = fptosi float %49 to i32
%51 = call i32 @digammaRN(i32 %50)
%52 = load float, float* %7
%53 = fsub float 1.000000e+00, %52
%54 = fptosi float %53 to i32
%55 = call i32 @digammaRN(i32 %54)
%56 = sub nsw i32 %51, %55
%57 = sub nsw i32 0, %56
%58 = sitofp i32 %57 to double
store double %58, double* %4
br label %386
59: ; preds = %42
%60 = load i32, i32* %5
%61 = load i32, i32* %6
%62 = load float, float* %7
%63 = call double @S_approx(i32 %60, i32 %61, float %62)
store double %63, double* %8
%64 = load i32, i32* %6
%65 = icmp eq i32 %64, 2
br i1 %65, label %66, label %132
66: ; preds = %59
%67 = load i32, i32* %5
%68 = sitofp i32 %67 to float
%69 = load float, float* %7
%70 = fsub float %68, %69
%71 = fptosi float %70 to i32
%72 = call double @lgamma(i32 %71)
%73 = load float, float* %7
%74 = fsub float 1.000000e+00, %73
%75 = fptosi float %74 to i32
%76 = call double @lgamma(i32 %75)
%77 = fsub double %72, %76
store double %77, double* %9
%78 = load i32, i32* %5
%79 = sitofp i32 %78 to float
%80 = load float, float* %7
%81 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %80, float %79)
%82 = fptosi float %81 to i32
%83 = call double @lgamma(i32 %82)
%84 = load float, float* %7
%85 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %84, float 1.000000e+00)
%86 = fptosi float %85 to i32
%87 = call double @lgamma(i32 %86)
%88 = fsub double %83, %87
store double %88, double* %10
%89 = load i32, i32* %5
%90 = sitofp i32 %89 to float
%91 = load float, float* %7
%92 = fsub float %90, %91
%93 = fptosi float %92 to i32
%94 = call i32 @digammaRN(i32 %93)
%95 = load float, float* %7
%96 = fsub float 1.000000e+00, %95
%97 = fptosi float %96 to i32
%98 = call i32 @digammaRN(i32 %97)
%99 = sub nsw i32 %94, %98
%100 = sub nsw i32 0, %99
%101 = sitofp i32 %100 to double
store double %101, double* %11
%102 = load i32, i32* %5
%103 = sitofp i32 %102 to float
%104 = load float, float* %7
%105 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %104, float %103)
%106 = fptosi float %105 to i32
%107 = call i32 @digammaRN(i32 %106)
%108 = load float, float* %7
%109 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %108, float 1.000000e+00)
%110 = fptosi float %109 to i32
%111 = call i32 @digammaRN(i32 %110)
%112 = sub nsw i32 %107, %111
%113 = sitofp i32 %112 to double
%114 = fmul double -2.000000e+00, %113
store double %114, double* %12
%115 = load double, double* %9
%116 = load double, double* %8
%117 = fsub double %115, %116
%118 = call double @exp(double %117)
%119 = load double, double* %11
%120 = load double, double* %10
%121 = load double, double* %8
%122 = fsub double %120, %121
%123 = call double @exp(double %122)
%124 = load double, double* %12
%125 = fmul double %123, %124
%126 = fneg double %125
%127 = call double @llvm.fmuladd.f64(double %118, double %119, double %126)
%128 = fsub double %127, 1.000000e+00
%129 = load float, float* %7
%130 = fpext float %129 to double
%131 = fdiv double %128, %130
store double %131, double* %4
br label %386
132: ; preds = %59
%133 = load i32, i32* %6
%134 = icmp eq i32 %133, 3
br i1 %134, label %135, label %239
135: ; preds = %132
%136 = load i32, i32* %5
%137 = sitofp i32 %136 to float
%138 = load float, float* %7
%139 = fsub float %137, %138
%140 = fptosi float %139 to i32
%141 = call double @lgamma(i32 %140)
%142 = load float, float* %7
%143 = fsub float 1.000000e+00, %142
%144 = fptosi float %143 to i32
%145 = call double @lgamma(i32 %144)
%146 = fsub double %141, %145
store double %146, double* %13
%147 = load i32, i32* %5
%148 = sitofp i32 %147 to float
%149 = load float, float* %7
%150 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %149, float %148)
%151 = fptosi float %150 to i32
%152 = call double @lgamma(i32 %151)
%153 = load float, float* %7
%154 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %153, float 1.000000e+00)
%155 = fptosi float %154 to i32
%156 = call double @lgamma(i32 %155)
%157 = fsub double %152, %156
store double %157, double* %14
%158 = load i32, i32* %5
%159 = sitofp i32 %158 to float
%160 = load float, float* %7
%161 = call float @llvm.fmuladd.f32(float -3.000000e+00, float %160, float %159)
%162 = fptosi float %161 to i32
%163 = call double @lgamma(i32 %162)
%164 = load float, float* %7
%165 = call float @llvm.fmuladd.f32(float -3.000000e+00, float %164, float 1.000000e+00)
%166 = fptosi float %165 to i32
%167 = call double @lgamma(i32 %166)
%168 = fsub double %163, %167
store double %168, double* %15
%169 = load i32, i32* %5
%170 = sitofp i32 %169 to float
%171 = load float, float* %7
%172 = fsub float %170, %171
%173 = fptosi float %172 to i32
%174 = call i32 @digammaRN(i32 %173)
%175 = load float, float* %7
%176 = fsub float 1.000000e+00, %175
%177 = fptosi float %176 to i32
%178 = call i32 @digammaRN(i32 %177)
%179 = sub nsw i32 %174, %178
%180 = sub nsw i32 0, %179
%181 = sitofp i32 %180 to double
store double %181, double* %16
%182 = load i32, i32* %5
%183 = sitofp i32 %182 to float
%184 = load float, float* %7
%185 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %184, float %183)
%186 = fptosi float %185 to i32
%187 = call i32 @digammaRN(i32 %186)
%188 = load float, float* %7
%189 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %188, float 1.000000e+00)
%190 = fptosi float %189 to i32
%191 = call i32 @digammaRN(i32 %190)
%192 = sub nsw i32 %187, %191
%193 = mul nsw i32 -2, %192
%194 = sitofp i32 %193 to double
store double %194, double* %17
%195 = load i32, i32* %5
%196 = sitofp i32 %195 to float
%197 = load float, float* %7
%198 = call float @llvm.fmuladd.f32(float -3.000000e+00, float %197, float %196)
%199 = fptosi float %198 to i32
%200 = call i32 @digammaRN(i32 %199)
%201 = load float, float* %7
%202 = call float @llvm.fmuladd.f32(float -3.000000e+00, float %201, float 1.000000e+00)
%203 = fptosi float %202 to i32
%204 = call i32 @digammaRN(i32 %203)
%205 = sub nsw i32 %200, %204
%206 = mul nsw i32 -3, %205
%207 = sitofp i32 %206 to double
store double %207, double* %18
%208 = load float, float* %7
%209 = fdiv float -2.000000e+00, %208
%210 = fpext float %209 to double
%211 = load double, double* %13
%212 = load double, double* %8
%213 = fsub double %211, %212
%214 = call double @exp(double %213)
%215 = load double, double* %16
%216 = load double, double* %14
%217 = load double, double* %8
%218 = fsub double %216, %217
%219 = call double @exp(double %218)
%220 = fmul double 2.000000e+00, %219
%221 = load double, double* %17
%222 = fmul double %220, %221
%223 = fneg double %222
%224 = call double @llvm.fmuladd.f64(double %214, double %215, double %223)
%225 = load double, double* %15
%226 = load double, double* %8
%227 = fsub double %225, %226
%228 = call double @exp(double %227)
%229 = load double, double* %18
%230 = call double @llvm.fmuladd.f64(double %228, double %229, double %224)
%231 = fdiv double %230, 2.000000e+00
%232 = load float, float* %7
%233 = fpext float %232 to double
%234 = fdiv double %231, %233
%235 = load float, float* %7
%236 = fpext float %235 to double
%237 = fdiv double %234, %236
%238 = fadd double %210, %237
store double %238, double* %4
br label %386
239: ; preds = %132
%240 = load i32, i32* %6
%241 = icmp eq i32 %240, 4
br i1 %241, label %242, label %381
242: ; preds = %239
%243 = load i32, i32* %5
%244 = sitofp i32 %243 to float
%245 = load float, float* %7
%246 = fsub float %244, %245
%247 = fptosi float %246 to i32
%248 = call double @lgamma(i32 %247)
%249 = load float, float* %7
%250 = fsub float 1.000000e+00, %249
%251 = fptosi float %250 to i32
%252 = call double @lgamma(i32 %251)
%253 = fsub double %248, %252
store double %253, double* %19
%254 = load i32, i32* %5
%255 = sitofp i32 %254 to float
%256 = load float, float* %7
%257 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %256, float %255)
%258 = fptosi float %257 to i32
%259 = call double @lgamma(i32 %258)
%260 = load float, float* %7
%261 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %260, float 1.000000e+00)
%262 = fptosi float %261 to i32
%263 = call double @lgamma(i32 %262)
%264 = fsub double %259, %263
store double %264, double* %20
%265 = load i32, i32* %5
%266 = sitofp i32 %265 to float
%267 = load float, float* %7
%268 = call float @llvm.fmuladd.f32(float -3.000000e+00, float %267, float %266)
%269 = fptosi float %268 to i32
%270 = call double @lgamma(i32 %269)
%271 = load float, float* %7
%272 = call float @llvm.fmuladd.f32(float -3.000000e+00, float %271, float 1.000000e+00)
%273 = fptosi float %272 to i32
%274 = call double @lgamma(i32 %273)
%275 = fsub double %270, %274
store double %275, double* %21
%276 = load i32, i32* %5
%277 = sitofp i32 %276 to float
%278 = load float, float* %7
%279 = call float @llvm.fmuladd.f32(float -4.000000e+00, float %278, float %277)
%280 = fptosi float %279 to i32
%281 = call double @lgamma(i32 %280)
%282 = load float, float* %7
%283 = call float @llvm.fmuladd.f32(float -4.000000e+00, float %282, float 1.000000e+00)
%284 = fptosi float %283 to i32
%285 = call double @lgamma(i32 %284)
%286 = fsub double %281, %285
store double %286, double* %22
%287 = load i32, i32* %5
%288 = sitofp i32 %287 to float
%289 = load float, float* %7
%290 = fsub float %288, %289
%291 = fptosi float %290 to i32
%292 = call i32 @digammaRN(i32 %291)
%293 = load float, float* %7
%294 = fsub float 1.000000e+00, %293
%295 = fptosi float %294 to i32
%296 = call i32 @digammaRN(i32 %295)
%297 = sub nsw i32 %292, %296
%298 = sub nsw i32 0, %297
%299 = sitofp i32 %298 to double
store double %299, double* %23
%300 = load i32, i32* %5
%301 = sitofp i32 %300 to float
%302 = load float, float* %7
%303 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %302, float %301)
%304 = fptosi float %303 to i32
%305 = call i32 @digammaRN(i32 %304)
%306 = load float, float* %7
%307 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %306, float 1.000000e+00)
%308 = fptosi float %307 to i32
%309 = call i32 @digammaRN(i32 %308)
%310 = sub nsw i32 %305, %309
%311 = mul nsw i32 -2, %310
%312 = sitofp i32 %311 to double
store double %312, double* %24
%313 = load i32, i32* %5
%314 = sitofp i32 %313 to float
%315 = load float, float* %7
%316 = call float @llvm.fmuladd.f32(float -3.000000e+00, float %315, float %314)
%317 = fptosi float %316 to i32
%318 = call i32 @digammaRN(i32 %317)
%319 = load float, float* %7
%320 = call float @llvm.fmuladd.f32(float -3.000000e+00, float %319, float 1.000000e+00)
%321 = fptosi float %320 to i32
%322 = call i32 @digammaRN(i32 %321)
%323 = sub nsw i32 %318, %322
%324 = mul nsw i32 -3, %323
%325 = sitofp i32 %324 to double
store double %325, double* %25
%326 = load i32, i32* %5
%327 = sitofp i32 %326 to float
%328 = load float, float* %7
%329 = call float @llvm.fmuladd.f32(float -4.000000e+00, float %328, float %327)
%330 = fptosi float %329 to i32
%331 = call i32 @digammaRN(i32 %330)
%332 = load float, float* %7
%333 = call float @llvm.fmuladd.f32(float -4.000000e+00, float %332, float 1.000000e+00)
%334 = fptosi float %333 to i32
%335 = call i32 @digammaRN(i32 %334)
%336 = sub nsw i32 %331, %335
%337 = mul nsw i32 -4, %336
%338 = sitofp i32 %337 to double
store double %338, double* %26
%339 = load float, float* %7
%340 = fdiv float -3.000000e+00, %339
%341 = fpext float %340 to double
%342 = load double, double* %19
%343 = load double, double* %8
%344 = fsub double %342, %343
%345 = call double @exp(double %344)
%346 = load double, double* %23
%347 = load double, double* %20
%348 = load double, double* %8
%349 = fsub double %347, %348
%350 = call double @exp(double %349)
%351 = fmul double 3.000000e+00, %350
%352 = load double, double* %24
%353 = fmul double %351, %352
%354 = fneg double %353
%355 = call double @llvm.fmuladd.f64(double %345, double %346, double %354)
%356 = load double, double* %21
%357 = load double, double* %8
%358 = fsub double %356, %357
%359 = call double @exp(double %358)
%360 = fmul double 3.000000e+00, %359
%361 = load double, double* %25
%362 = call double @llvm.fmuladd.f64(double %360, double %361, double %355)
%363 = load double, double* %22
%364 = load double, double* %8
%365 = fsub double %363, %364
%366 = call double @exp(double %365)
%367 = load double, double* %26
%368 = fneg double %366
%369 = call double @llvm.fmuladd.f64(double %368, double %367, double %362)
%370 = fdiv double %369, 3.000000e+00
%371 = load float, float* %7
%372 = fpext float %371 to double
%373 = fdiv double %370, %372
%374 = load float, float* %7
%375 = fpext float %374 to double
%376 = fdiv double %373, %375
%377 = load float, float* %7
%378 = fpext float %377 to double
%379 = fdiv double %376, %378
%380 = fadd double %341, %379
store double %380, double* %4
br label %386
381: ; preds = %239
br label %382
382: ; preds = %381
br label %383
383: ; preds = %382
%384 = load double, double* @HUGE_VAL
%385 = fneg double %384
store double %385, double* %4
br label %386
386: ; preds = %383, %242, %135, %66, %45, %39, %34
%387 = load double, double* %4
ret double %387
}

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