#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 digamma(double);
double exp(double);
double trigamma(double);
double invdigamma(double y) {
  double x = (y <= -2.22) ? (-1 / (y + 0.5772156649015353)) : (exp(y) + 0.5);
  x = x - (digamma(x) - y) / trigamma(x);
  x = x - (digamma(x) - y) / trigamma(x);
  x = x - (digamma(x) - y) / trigamma(x);
  x = x - (digamma(x) - y) / trigamma(x);
  x = x - (digamma(x) - y) / trigamma(x);
  return x;
}


x86 assembly (clang, -O0):
<invdigamma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xebb(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     1173 <invdigamma+0x43>
movsd  0xec0(%rip),%xmm1
addsd  -0x8(%rbp),%xmm1
movsd  0xeab(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    118e <invdigamma+0x5e>
movsd  -0x8(%rbp),%xmm0
call   1040 <exp@plt>
movsd  0xe83(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <digamma@plt>
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <trigamma@plt>
movsd  -0x68(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x60(%rbp),%xmm0
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <digamma@plt>
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <trigamma@plt>
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <digamma@plt>
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <trigamma@plt>
movsd  -0x48(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <digamma@plt>
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <trigamma@plt>
movsd  -0x38(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <digamma@plt>
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <trigamma@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<invdigamma>:
sub    $0x18,%rsp
movsd  0xec4(%rip),%xmm1
ucomisd %xmm0,%xmm1
movsd  %xmm0,0x10(%rsp)
jae    1157 <invdigamma+0x27>
call   1040 <exp@plt>
addsd  0xec3(%rip),%xmm0
jmp    116f <invdigamma+0x3f>
movsd  0xea9(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xea5(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1050 <digamma@plt>
subsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1030 <trigamma@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1050 <digamma@plt>
subsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1030 <trigamma@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1050 <digamma@plt>
subsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1030 <trigamma@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1050 <digamma@plt>
subsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1030 <trigamma@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1050 <digamma@plt>
subsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1030 <trigamma@plt>
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  (%rsp),%xmm0
subsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @invdigamma(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %2
%4 = load double, double* %2
%5 = fcmp ole double %4, -2.220000e+00
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load double, double* %2
%8 = fadd double %7, 0x3FE2788CFC6FB62F
%9 = fdiv double -1.000000e+00, %8
br label %14
10: ; preds = %1
%11 = load double, double* %2
%12 = call double @exp(double %11)
%13 = fadd double %12, 5.000000e-01
br label %14
14: ; preds = %10, %6
%15 = phi double [ %9, %6 ], [ %13, %10 ]
store double %15, double* %3
%16 = load double, double* %3
%17 = load double, double* %3
%18 = call double @digamma(double %17)
%19 = load double, double* %2
%20 = fsub double %18, %19
%21 = load double, double* %3
%22 = call double @trigamma(double %21)
%23 = fdiv double %20, %22
%24 = fsub double %16, %23
store double %24, double* %3
%25 = load double, double* %3
%26 = load double, double* %3
%27 = call double @digamma(double %26)
%28 = load double, double* %2
%29 = fsub double %27, %28
%30 = load double, double* %3
%31 = call double @trigamma(double %30)
%32 = fdiv double %29, %31
%33 = fsub double %25, %32
store double %33, double* %3
%34 = load double, double* %3
%35 = load double, double* %3
%36 = call double @digamma(double %35)
%37 = load double, double* %2
%38 = fsub double %36, %37
%39 = load double, double* %3
%40 = call double @trigamma(double %39)
%41 = fdiv double %38, %40
%42 = fsub double %34, %41
store double %42, double* %3
%43 = load double, double* %3
%44 = load double, double* %3
%45 = call double @digamma(double %44)
%46 = load double, double* %2
%47 = fsub double %45, %46
%48 = load double, double* %3
%49 = call double @trigamma(double %48)
%50 = fdiv double %47, %49
%51 = fsub double %43, %50
store double %51, double* %3
%52 = load double, double* %3
%53 = load double, double* %3
%54 = call double @digamma(double %53)
%55 = load double, double* %2
%56 = fsub double %54, %55
%57 = load double, double* %3
%58 = call double @trigamma(double %57)
%59 = fdiv double %56, %58
%60 = fsub double %52, %59
store double %60, double* %3
%61 = load double, double* %3
ret double %61
}

LLVM IR (-O2):
define double @invdigamma(double %0) {
%2 = fcmp ugt double %0, -2.220000e+00
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = fadd double %0, 0x3FE2788CFC6FB62F
%5 = fdiv double -1.000000e+00, %4
br label %9
6: ; preds = %1
%7 = tail call double @exp(double %0)
%8 = fadd double %7, 5.000000e-01
br label %9
9: ; preds = %6, %3
%10 = phi double [ %5, %3 ], [ %8, %6 ]
%11 = tail call double @digamma(double %10)
%12 = fsub double %11, %0
%13 = tail call double @trigamma(double %10)
%14 = fdiv double %12, %13
%15 = fsub double %10, %14
%16 = tail call double @digamma(double %15)
%17 = fsub double %16, %0
%18 = tail call double @trigamma(double %15)
%19 = fdiv double %17, %18
%20 = fsub double %15, %19
%21 = tail call double @digamma(double %20)
%22 = fsub double %21, %0
%23 = tail call double @trigamma(double %20)
%24 = fdiv double %22, %23
%25 = fsub double %20, %24
%26 = tail call double @digamma(double %25)
%27 = fsub double %26, %0
%28 = tail call double @trigamma(double %25)
%29 = fdiv double %27, %28
%30 = fsub double %25, %29
%31 = tail call double @digamma(double %30)
%32 = fsub double %31, %0
%33 = tail call double @trigamma(double %30)
%34 = fdiv double %32, %33
%35 = fsub double %30, %34
ret double %35
}