#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 fff_psi(double x) {
  double c = 8.5;
  double d1 = -0.5772156649;
  double r;
  double s = 0.00001;
  double s3 = 0.08333333333;
  double s4 = 0.0083333333333;
  double s5 = 0.003968253968;
  double out;
  double y;
  y = x;
  out = 0.0;
  if (y <= s) {
    out = d1 - 1.0 / y;
    return out;
  }
  while (y < c) {
    out = out - 1.0 / y;
    y = y + 1.0;
  }
  r = 1.0 / y;
  out += log(y) - 0.5 * r;
  r = r * r;
  out += -r * (s3 - r * (s4 - r * s5));
  return out;
}


x86 assembly (clang, -O0):
<fff_psi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xf03(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeee(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xed9(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xec4(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xeaf(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe9a(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x58(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11bb <fff_psi+0xab>
movsd  -0x20(%rbp),%xmm0
movsd  0xe9a(%rip),%xmm1
divsd  -0x58(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12e2 <fff_psi+0x1d2>
jmp    11c0 <fff_psi+0xb0>
movsd  -0x58(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1206 <fff_psi+0xf6>
movsd  -0x50(%rbp),%xmm0
movsd  0xe57(%rip),%xmm1
divsd  -0x58(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe41(%rip),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    11c0 <fff_psi+0xb0>
movsd  0xe2a(%rip),%xmm0
divsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  0xdfe(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm4
movsd  -0x28(%rbp),%xmm3
movsd  -0x48(%rbp),%xmm5
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm5,%xmm3
addsd  %xmm4,%xmm3
movq   %xmm2,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm2
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fff_psi>:
sub    $0x28,%rsp
movsd  0xee4(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11dc <fff_psi+0xcc>
xorpd  %xmm4,%xmm4
movsd  0xee6(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1166 <fff_psi+0x56>
xorpd  %xmm4,%xmm4
movsd  0xedc(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movapd %xmm2,%xmm3
divsd  %xmm0,%xmm3
subsd  %xmm3,%xmm4
addsd  %xmm2,%xmm0
ucomisd %xmm0,%xmm1
ja     1150 <fff_psi+0x40>
movsd  %xmm4,0x8(%rsp)
movsd  0xeac(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
call   1030 <log@plt>
movsd  0xe9d(%rip),%xmm1
movapd 0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
addsd  0x8(%rsp),%xmm0
movapd 0xea9(%rip),%xmm1
xorpd  %xmm2,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xe79(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xe75(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xe71(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  %xmm2,%xmm0
add    $0x28,%rsp
ret
movsd  0xe24(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  0xe20(%rip),%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @fff_psi(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double %0, double* %3
store double 8.500000e+00, double* %4
store double 0xBFE2788CFC6F802A, double* %5
store double 1.000000e-05, double* %7
store double 0x3FB555555551AB15, double* %8
store double 0x3F8111111110C602, double* %9
store double 0x3F704104103C8C4B, double* %10
%13 = load double, double* %3
store double %13, double* %12
store double 0.000000e+00, double* %11
%14 = load double, double* %12
%15 = load double, double* %7
%16 = fcmp ole double %14, %15
br i1 %16, label %17, label %23
17: ; preds = %1
%18 = load double, double* %5
%19 = load double, double* %12
%20 = fdiv double 1.000000e+00, %19
%21 = fsub double %18, %20
store double %21, double* %11
%22 = load double, double* %11
store double %22, double* %2
br label %61
23: ; preds = %1
br label %24
24: ; preds = %28, %23
%25 = load double, double* %12
%26 = load double, double* %4
%27 = fcmp olt double %25, %26
br i1 %27, label %28, label %35
28: ; preds = %24
%29 = load double, double* %11
%30 = load double, double* %12
%31 = fdiv double 1.000000e+00, %30
%32 = fsub double %29, %31
store double %32, double* %11
%33 = load double, double* %12
%34 = fadd double %33, 1.000000e+00
store double %34, double* %12
br label %24
35: ; preds = %24
%36 = load double, double* %12
%37 = fdiv double 1.000000e+00, %36
store double %37, double* %6
%38 = load double, double* %12
%39 = call double @log(double %38)
%40 = load double, double* %6
%41 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %40, double %39)
%42 = load double, double* %11
%43 = fadd double %42, %41
store double %43, double* %11
%44 = load double, double* %6
%45 = load double, double* %6
%46 = fmul double %44, %45
store double %46, double* %6
%47 = load double, double* %6
%48 = fneg double %47
%49 = load double, double* %8
%50 = load double, double* %6
%51 = load double, double* %9
%52 = load double, double* %6
%53 = load double, double* %10
%54 = fneg double %52
%55 = call double @llvm.fmuladd.f64(double %54, double %53, double %51)
%56 = fneg double %50
%57 = call double @llvm.fmuladd.f64(double %56, double %55, double %49)
%58 = load double, double* %11
%59 = call double @llvm.fmuladd.f64(double %48, double %57, double %58)
store double %59, double* %11
%60 = load double, double* %11
store double %60, double* %2
br label %61
61: ; preds = %35, %17
%62 = load double, double* %2
ret double %62
}

LLVM IR (-O2):
define double @fff_psi(double %0) {
%2 = fcmp ugt double %0, 1.000000e-05
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = fcmp olt double %0, 8.500000e+00
br i1 %4, label %8, label %15
5: ; preds = %1
%6 = fdiv double 1.000000e+00, %0
%7 = fsub double 0xBFE2788CFC6F802A, %6
br label %27
8: ; preds = %3, %8
%9 = phi double [ %13, %8 ], [ %0, %3 ]
%10 = phi double [ %12, %8 ], [ 0.000000e+00, %3 ]
%11 = fdiv double 1.000000e+00, %9
%12 = fsub double %10, %11
%13 = fadd double %9, 1.000000e+00
%14 = fcmp olt double %13, 8.500000e+00
br i1 %14, label %8, label %15
15: ; preds = %8, %3
%16 = phi double [ 0.000000e+00, %3 ], [ %12, %8 ]
%17 = phi double [ %0, %3 ], [ %13, %8 ]
%18 = fdiv double 1.000000e+00, %17
%19 = tail call double @log(double %17)
%20 = tail call double @llvm.fmuladd.f64(double %18, double -5.000000e-01, double %19)
%21 = fadd double %16, %20
%22 = fneg double %18
%23 = fmul double %18, %22
%24 = tail call double @llvm.fmuladd.f64(double %23, double 0x3F704104103C8C4B, double 0x3F8111111110C602)
%25 = tail call double @llvm.fmuladd.f64(double %23, double %24, double 0x3FB555555551AB15)
%26 = tail call double @llvm.fmuladd.f64(double %23, double %25, double %21)
br label %27
27: ; preds = %15, %5
%28 = phi double [ %7, %5 ], [ %26, %15 ]
ret double %28
}