#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 psi(double z) {
  double u, u2;
  if (z < 10) {
    u = -0.57721566490153286061;
    for (u2 = 1; u2 < z; u2++) {
      u += 1 / u2;
    }
    return u;
  } else {
    u = 1.0 / z;
    u2 = u * u;
    return log(z) +
           (-1.0 / 2 + (-1.0 / 12 + (1.0 / 120 - 1.0 / 252 * u2) * u2) * u) * u;
  }
}


x86 assembly (clang, -O0):
<psi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xedb(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    119b <psi+0x8b>
movsd  0xef8(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xee3(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    118c <psi+0x7c>
movsd  0xec2(%rip),%xmm0
divsd  -0x20(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeab(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    114a <psi+0x3a>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1222 <psi+0x112>
movsd  0xe85(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
movsd  0xe42(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  0xe3e(%rip),%xmm2
addsd  %xmm2,%xmm0
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm0
movsd  0xe19(%rip),%xmm2
addsd  %xmm2,%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
movsd  0xdfc(%rip),%xmm2
addsd  %xmm2,%xmm0
movsd  -0x18(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psi>:
sub    $0x18,%rsp
movsd  0xee4(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    115f <psi+0x4f>
movsd  0xf06(%rip),%xmm1
ucomisd 0xed6(%rip),%xmm0
jbe    1156 <psi+0x46>
movsd  0xecc(%rip),%xmm2
movapd %xmm2,%xmm3
movapd %xmm2,%xmm4
divsd  %xmm3,%xmm4
addsd  %xmm4,%xmm1
addsd  %xmm2,%xmm3
ucomisd %xmm3,%xmm0
ja     1140 <psi+0x30>
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret
movsd  0xea1(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
call   1030 <log@plt>
movsd  0xe88(%rip),%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm1
addsd  0xe7e(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xe7a(%rip),%xmm1
movsd  0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm1
addsd  0xe70(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define double @psi(double %0) {
%2 = fcmp olt double %0, 1.000000e+01
br i1 %2, label %3, label %12
3: ; preds = %1
%4 = fcmp ogt double %0, 1.000000e+00
br i1 %4, label %5, label %20
5: ; preds = %3, %5
%6 = phi double [ %10, %5 ], [ 1.000000e+00, %3 ]
%7 = phi double [ %9, %5 ], [ 0xBFE2788CFC6FB619, %3 ]
%8 = fdiv double 1.000000e+00, %6
%9 = fadd double %7, %8
%10 = fadd double %6, 1.000000e+00
%11 = fcmp olt double %10, %0
br i1 %11, label %5, label %20
12: ; preds = %1
%13 = fdiv double 1.000000e+00, %0
%14 = fmul double %13, %13
%15 = tail call double @log(double %0)
%16 = tail call double @llvm.fmuladd.f64(double %14, double 0xBF70410410410410, double 0x3F81111111111111)
%17 = tail call double @llvm.fmuladd.f64(double %16, double %14, double 0xBFB5555555555555)
%18 = tail call double @llvm.fmuladd.f64(double %17, double %13, double -5.000000e-01)
%19 = tail call double @llvm.fmuladd.f64(double %18, double %13, double %15)
br label %20
20: ; preds = %5, %3, %12
%21 = phi double [ %19, %12 ], [ 0xBFE2788CFC6FB619, %3 ], [ %9, %5 ]
ret double %21
}