#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 log(double);
double digammaRN(double x) {
  double r, f, t;
  r = 0;
  while (x <= 5) {
    r -= 1 / x;
    x += 1;
  }
  f = 1 / (x * x);
  t = f * (-1 / 12.0 +
           f * (1 / 120.0 +
                f * (-1 / 252.0 +
                     f * (1 / 240.0 +
                          f * (-1 / 132.0 +
                               f * (691 / 32760.0 +
                                    f * (-1 / 12.0 + f * 3617 / 8160.0)))))));
  return r + log(x) - 0.5 / x + t;
}


x86 assembly (clang, -O0):
<digammaRN>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xed3(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     116a <digammaRN+0x5a>
movsd  0xf10(%rip),%xmm1
divsd  -0x8(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xef5(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1125 <digammaRN+0x15>
movsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  0xed4(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x18(%rbp),%xmm4
movsd  -0x18(%rbp),%xmm5
movsd  -0x18(%rbp),%xmm6
movsd  0xe97(%rip),%xmm8
mulsd  -0x18(%rbp),%xmm8
movsd  0xe81(%rip),%xmm7
divsd  %xmm7,%xmm8
movsd  0xe44(%rip),%xmm7
addsd  %xmm8,%xmm7
mulsd  %xmm7,%xmm6
movsd  0xe5b(%rip),%xmm7
addsd  %xmm7,%xmm6
mulsd  %xmm6,%xmm5
movsd  0xe43(%rip),%xmm6
addsd  %xmm6,%xmm5
mulsd  %xmm5,%xmm4
movsd  0xe2b(%rip),%xmm5
addsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm3
movsd  0xe13(%rip),%xmm4
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm2
movsd  0xdfb(%rip),%xmm3
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xde3(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  0xda6(%rip),%xmm1
divsd  -0x8(%rbp),%xmm1
subsd  %xmm1,%xmm0
addsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<digammaRN>:
sub    $0x28,%rsp
xorpd  %xmm4,%xmm4
movsd  0xee0(%rip),%xmm1
ucomisd %xmm0,%xmm1
jb     1156 <digammaRN+0x46>
xorpd  %xmm4,%xmm4
movsd  0xed6(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movapd %xmm2,%xmm3
divsd  %xmm0,%xmm3
subsd  %xmm3,%xmm4
addsd  %xmm2,%xmm0
ucomisd %xmm0,%xmm1
jae    1140 <digammaRN+0x30>
movsd  %xmm4,(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
movapd 0xee1(%rip),%xmm2
divpd  %xmm1,%xmm2
movapd %xmm2,0x10(%rsp)
movsd  0xe8f(%rip),%xmm3
mulsd  %xmm2,%xmm3
divsd  0xe8b(%rip),%xmm3
movsd  0xe8b(%rip),%xmm1
addsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm3
addsd  0xe83(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  0xe7f(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  0xe7b(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  0xe77(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  0xe73(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  %xmm1,%xmm3
movsd  %xmm3,0x8(%rsp)
call   1030 <log@plt>
addsd  (%rsp),%xmm0
movapd 0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
subsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @digammaRN(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %2
store double 0.000000e+00, double* %3
br label %6
6: ; preds = %9, %1
%7 = load double, double* %2
%8 = fcmp ole double %7, 5.000000e+00
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load double, double* %2
%11 = fdiv double 1.000000e+00, %10
%12 = load double, double* %3
%13 = fsub double %12, %11
store double %13, double* %3
%14 = load double, double* %2
%15 = fadd double %14, 1.000000e+00
store double %15, double* %2
br label %6
16: ; preds = %6
%17 = load double, double* %2
%18 = load double, double* %2
%19 = fmul double %17, %18
%20 = fdiv double 1.000000e+00, %19
store double %20, double* %4
%21 = load double, double* %4
%22 = load double, double* %4
%23 = load double, double* %4
%24 = load double, double* %4
%25 = load double, double* %4
%26 = load double, double* %4
%27 = load double, double* %4
%28 = load double, double* %4
%29 = fmul double %28, 3.617000e+03
%30 = fdiv double %29, 8.160000e+03
%31 = fadd double 0xBFB5555555555555, %30
%32 = call double @llvm.fmuladd.f64(double %27, double %31, double 0x3F95995995995996)
%33 = call double @llvm.fmuladd.f64(double %26, double %32, double 0xBF7F07C1F07C1F08)
%34 = call double @llvm.fmuladd.f64(double %25, double %33, double 0x3F71111111111111)
%35 = call double @llvm.fmuladd.f64(double %24, double %34, double 0xBF70410410410410)
%36 = call double @llvm.fmuladd.f64(double %23, double %35, double 0x3F81111111111111)
%37 = call double @llvm.fmuladd.f64(double %22, double %36, double 0xBFB5555555555555)
%38 = fmul double %21, %37
store double %38, double* %5
%39 = load double, double* %3
%40 = load double, double* %2
%41 = call double @log(double %40)
%42 = fadd double %39, %41
%43 = load double, double* %2
%44 = fdiv double 5.000000e-01, %43
%45 = fsub double %42, %44
%46 = load double, double* %5
%47 = fadd double %45, %46
ret double %47
}

LLVM IR (-O2):
define double @digammaRN(double %0) {
%2 = fcmp ugt double %0, 5.000000e+00
br i1 %2, label %10, label %3
3: ; preds = %1, %3
%4 = phi double [ %8, %3 ], [ %0, %1 ]
%5 = phi double [ %7, %3 ], [ 0.000000e+00, %1 ]
%6 = fdiv double 1.000000e+00, %4
%7 = fsub double %5, %6
%8 = fadd double %4, 1.000000e+00
%9 = fcmp ugt double %8, 5.000000e+00
br i1 %9, label %10, label %3
10: ; preds = %3, %1
%11 = phi double [ 0.000000e+00, %1 ], [ %7, %3 ]
%12 = phi double [ %0, %1 ], [ %8, %3 ]
%13 = fmul double %12, %12
%14 = insertelement <2 x double> poison, double %13, i64 0
%15 = insertelement <2 x double> %14, double %12, i64 1
%16 = fdiv <2 x double> <double 1.000000e+00, double 5.000000e-01>, %15
%17 = extractelement <2 x double> %16, i64 0
%18 = fmul double %17, 3.617000e+03
%19 = fdiv double %18, 8.160000e+03
%20 = fadd double %19, 0xBFB5555555555555
%21 = tail call double @llvm.fmuladd.f64(double %17, double %20, double 0x3F95995995995996)
%22 = tail call double @llvm.fmuladd.f64(double %17, double %21, double 0xBF7F07C1F07C1F08)
%23 = tail call double @llvm.fmuladd.f64(double %17, double %22, double 0x3F71111111111111)
%24 = tail call double @llvm.fmuladd.f64(double %17, double %23, double 0xBF70410410410410)
%25 = tail call double @llvm.fmuladd.f64(double %17, double %24, double 0x3F81111111111111)
%26 = tail call double @llvm.fmuladd.f64(double %17, double %25, double 0xBFB5555555555555)
%27 = tail call double @log(double %12)
%28 = fadd double %11, %27
%29 = extractelement <2 x double> %16, i64 0
%30 = fmul double %26, %29
%31 = extractelement <2 x double> %16, i64 1
%32 = fsub double %28, %31
%33 = fadd double %30, %32
ret double %33
}