#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 INFINITY;
double M_PI;
double NAN;
double floor(double);
int isinf(double);
scalar_t__ isnan(double);
double sin(double);
double trigamma(double x) {
  double small = 1e-4, large = 8, c = 1.6449340668482264365,
         c1 = -2.404113806319188570799476, b2 = 1. / 6, b4 = -1. / 30,
         b6 = 1. / 42, b8 = -1. / 30, b10 = 5. / 66;
  double result;
  if ((isinf(x) == -1) || isnan(x)) {
    return NAN;
  }
  if ((x <= 0) && (floor(x) == x)) {
    return -INFINITY;
  }
  if (x < 0) {
    result = M_PI / sin(-M_PI * x);
    return -trigamma(1 - x) + result * result;
  }
  if (x <= small) {
    return 1 / (x * x) + c + c1 * x;
  }
  result = 0;
  while (x < large) {
    result += 1 / (x * x);
    x++;
  }
  if (x >= large) {
    double r = 1 / (x * x);
    result +=
        0.5 * r + (1 + r * (b2 + r * (b4 + r * (b6 + r * (b8 + r * b10))))) / x;
  }
  return result;
}


x86 assembly (clang, -O0):
<trigamma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xed3(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xebe(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xea9(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe94(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe7f(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe62(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe5d(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe48(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe33(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1070 <isinf@plt>
cmp    $0xffffffff,%eax
je     11f9 <trigamma+0xa9>
movsd  -0x10(%rbp),%xmm0
call   1050 <isnan@plt>
cmp    $0x0,%rax
je     120e <trigamma+0xbe>
mov    0x2df8(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1462 <trigamma+0x312>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1263 <trigamma+0x113>
movsd  -0x10(%rbp),%xmm0
call   1060 <floor@plt>
ucomisd -0x10(%rbp),%xmm0
jne    1263 <trigamma+0x113>
jp     1263 <trigamma+0x113>
mov    0x2da2(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1462 <trigamma+0x312>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1303 <trigamma+0x1b3>
mov    0x2d60(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    0x2d50(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xd82(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
call   1030 <trigamma@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  -0x60(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1462 <trigamma+0x312>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     134e <trigamma+0x1fe>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xd1f(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1462 <trigamma+0x312>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    13a1 <trigamma+0x251>
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xccc(%rip),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xcb6(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1356 <trigamma+0x206>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1458 <trigamma+0x308>
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xc85(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm3
movsd  -0x68(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm5
movsd  -0x68(%rbp),%xmm4
movsd  -0x48(%rbp),%xmm7
movsd  -0x68(%rbp),%xmm6
movsd  -0x50(%rbp),%xmm9
movsd  -0x68(%rbp),%xmm8
movsd  -0x58(%rbp),%xmm10
mulsd  %xmm10,%xmm8
addsd  %xmm9,%xmm8
mulsd  %xmm8,%xmm6
addsd  %xmm7,%xmm6
mulsd  %xmm6,%xmm4
addsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xc13(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  -0x10(%rbp),%xmm1
movsd  0xbfa(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trigamma>:
sub    $0x28,%rsp
movsd  %xmm0,0x8(%rsp)
call   1070 <isinf@plt>
cmp    $0xffffffff,%eax
je     1174 <trigamma+0x24>
movsd  0x8(%rsp),%xmm0
call   1050 <isnan@plt>
test   %rax,%rax
je     1184 <trigamma+0x34>
mov    0x2e7d(%rip),%rax
movsd  (%rax),%xmm0
add    $0x28,%rsp
ret
movsd  0x8(%rsp),%xmm0
call   1060 <floor@plt>
xorpd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm5
ucomisd %xmm5,%xmm1
jb     11bf <trigamma+0x6f>
ucomisd %xmm5,%xmm0
jne    11bf <trigamma+0x6f>
jp     11bf <trigamma+0x6f>
mov    0x2e32(%rip),%rax
movsd  (%rax),%xmm0
xorpd  0xe96(%rip),%xmm0
add    $0x28,%rsp
ret
ucomisd %xmm5,%xmm1
jbe    1225 <trigamma+0xd5>
mov    0x2e0c(%rip),%rax
movsd  (%rax),%xmm1
movapd %xmm1,0x10(%rsp)
movapd 0xe72(%rip),%xmm0
xorpd  %xmm1,%xmm0
mulsd  %xmm5,%xmm0
call   1040 <sin@plt>
movapd 0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
movsd  0xe05(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
call   1030 <trigamma@plt>
movapd 0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret
movsd  0xdd3(%rip),%xmm0
ucomisd %xmm5,%xmm0
jae    12fd <trigamma+0x1ad>
xorpd  %xmm0,%xmm0
movsd  0xddd(%rip),%xmm1
ucomisd %xmm5,%xmm1
jbe    127e <trigamma+0x12e>
xorpd  %xmm0,%xmm0
movsd  0xdb3(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
nop
movapd %xmm5,%xmm3
mulsd  %xmm5,%xmm3
movapd %xmm2,%xmm4
divsd  %xmm3,%xmm4
addsd  %xmm4,%xmm0
addsd  %xmm2,%xmm5
ucomisd %xmm5,%xmm1
ja     1260 <trigamma+0x110>
ucomisd 0xd9a(%rip),%xmm5
jb     11ba <trigamma+0x6a>
movapd %xmm5,%xmm1
mulsd  %xmm5,%xmm1
movsd  0xd6c(%rip),%xmm2
movapd %xmm2,%xmm3
divsd  %xmm1,%xmm3
movsd  0xd7c(%rip),%xmm1
mulsd  %xmm3,%xmm1
movsd  0xd78(%rip),%xmm4
addsd  %xmm4,%xmm1
mulsd  %xmm3,%xmm1
addsd  0xd70(%rip),%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm4,%xmm1
mulsd  %xmm3,%xmm1
addsd  0xd64(%rip),%xmm1
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm5,%xmm1
mulsd  0xd58(%rip),%xmm3
addsd  %xmm1,%xmm3
addsd  %xmm3,%xmm0
add    $0x28,%rsp
ret
movapd %xmm5,%xmm0
mulsd  %xmm5,%xmm0
movsd  0xcfb(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  0xcf7(%rip),%xmm1
mulsd  0xcf7(%rip),%xmm5
addsd  %xmm1,%xmm5
movapd %xmm5,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@NAN = global double 0.000000e+00
@INFINITY = global double 0.000000e+00
@M_PI = global double 0.000000e+00
define double @trigamma(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
%13 = alloca double
%14 = alloca double
store double %0, double* %3
store double 1.000000e-04, double* %4
store double 8.000000e+00, double* %5
store double 0x3FFA51A6625307D3, double* %6
store double 0xC0033BA004F00621, double* %7
store double 0x3FC5555555555555, double* %8
store double 0xBFA1111111111111, double* %9
store double 0x3F98618618618618, double* %10
store double 0xBFA1111111111111, double* %11
store double 0x3FB364D9364D9365, double* %12
%15 = load double, double* %3
%16 = call i32 @isinf(double %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %22, label %18
18: ; preds = %1
%19 = load double, double* %3
%20 = call i64 @isnan(double %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18, %1
%23 = load double, double* @NAN
store double %23, double* %2
br label %113
24: ; preds = %18
%25 = load double, double* %3
%26 = fcmp ole double %25, 0.000000e+00
br i1 %26, label %27, label %35
27: ; preds = %24
%28 = load double, double* %3
%29 = call double @llvm.floor.f64(double %28)
%30 = load double, double* %3
%31 = fcmp oeq double %29, %30
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = load double, double* @INFINITY
%34 = fneg double %33
store double %34, double* %2
br label %113
35: ; preds = %27, %24
%36 = load double, double* %3
%37 = fcmp olt double %36, 0.000000e+00
br i1 %37, label %38, label %53
38: ; preds = %35
%39 = load double, double* @M_PI
%40 = load double, double* @M_PI
%41 = fneg double %40
%42 = load double, double* %3
%43 = fmul double %41, %42
%44 = call double @sin(double %43)
%45 = fdiv double %39, %44
store double %45, double* %13
%46 = load double, double* %3
%47 = fsub double 1.000000e+00, %46
%48 = call double @trigamma(double %47)
%49 = fneg double %48
%50 = load double, double* %13
%51 = load double, double* %13
%52 = call double @llvm.fmuladd.f64(double %50, double %51, double %49)
store double %52, double* %2
br label %113
53: ; preds = %35
%54 = load double, double* %3
%55 = load double, double* %4
%56 = fcmp ole double %54, %55
br i1 %56, label %57, label %67
57: ; preds = %53
%58 = load double, double* %3
%59 = load double, double* %3
%60 = fmul double %58, %59
%61 = fdiv double 1.000000e+00, %60
%62 = load double, double* %6
%63 = fadd double %61, %62
%64 = load double, double* %7
%65 = load double, double* %3
%66 = call double @llvm.fmuladd.f64(double %64, double %65, double %63)
store double %66, double* %2
br label %113
67: ; preds = %53
store double 0.000000e+00, double* %13
br label %68
68: ; preds = %72, %67
%69 = load double, double* %3
%70 = load double, double* %5
%71 = fcmp olt double %69, %70
br i1 %71, label %72, label %81
72: ; preds = %68
%73 = load double, double* %3
%74 = load double, double* %3
%75 = fmul double %73, %74
%76 = fdiv double 1.000000e+00, %75
%77 = load double, double* %13
%78 = fadd double %77, %76
store double %78, double* %13
%79 = load double, double* %3
%80 = fadd double %79, 1.000000e+00
store double %80, double* %3
br label %68
81: ; preds = %68
%82 = load double, double* %3
%83 = load double, double* %5
%84 = fcmp oge double %82, %83
br i1 %84, label %85, label %111
85: ; preds = %81
%86 = load double, double* %3
%87 = load double, double* %3
%88 = fmul double %86, %87
%89 = fdiv double 1.000000e+00, %88
store double %89, double* %14
%90 = load double, double* %14
%91 = load double, double* %14
%92 = load double, double* %8
%93 = load double, double* %14
%94 = load double, double* %9
%95 = load double, double* %14
%96 = load double, double* %10
%97 = load double, double* %14
%98 = load double, double* %11
%99 = load double, double* %14
%100 = load double, double* %12
%101 = call double @llvm.fmuladd.f64(double %99, double %100, double %98)
%102 = call double @llvm.fmuladd.f64(double %97, double %101, double %96)
%103 = call double @llvm.fmuladd.f64(double %95, double %102, double %94)
%104 = call double @llvm.fmuladd.f64(double %93, double %103, double %92)
%105 = call double @llvm.fmuladd.f64(double %91, double %104, double 1.000000e+00)
%106 = load double, double* %3
%107 = fdiv double %105, %106
%108 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %90, double %107)
%109 = load double, double* %13
%110 = fadd double %109, %108
store double %110, double* %13
br label %111
111: ; preds = %85, %81
%112 = load double, double* %13
store double %112, double* %2
br label %113
113: ; preds = %111, %57, %38, %32, %22
%114 = load double, double* %2
ret double %114
}

LLVM IR (-O2):
@NAN = global double 0.000000e+00
@INFINITY = global double 0.000000e+00
@M_PI = global double 0.000000e+00
define double @trigamma(double %0) {
%2 = tail call i32 @isinf(double %0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i64 @isnan(double %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %4, %1
%8 = load double, double* @NAN
br label %19
9: ; preds = %4
%10 = fcmp ole double %0, 0.000000e+00
%11 = tail call double @llvm.floor.f64(double %0)
%12 = fcmp oeq double %11, %0
%13 = select i1 %10, i1 %12, i1 false
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = load double, double* @INFINITY
%16 = fneg double %15
br label %19
17: ; preds = %9
%18 = fcmp olt double %0, 0.000000e+00
br i1 %18, label %21, label %31
19: ; preds = %7, %14, %35, %52, %48, %21
%20 = phi double [ %30, %21 ], [ %8, %7 ], [ %16, %14 ], [ %39, %35 ], [ %62, %52 ], [ %50, %48 ]
ret double %20
21: ; preds = %17
%22 = load double, double* @M_PI
%23 = fneg double %22
%24 = fmul double %23, %0
%25 = tail call double @sin(double %24)
%26 = fdiv double %22, %25
%27 = fsub double 1.000000e+00, %0
%28 = tail call double @trigamma(double %27)
%29 = fneg double %28
%30 = tail call double @llvm.fmuladd.f64(double %26, double %26, double %29)
br label %19
31: ; preds = %17
%32 = fcmp ugt double %0, 1.000000e-04
br i1 %32, label %33, label %35
33: ; preds = %31
%34 = fcmp olt double %0, 8.000000e+00
br i1 %34, label %40, label %48
35: ; preds = %31
%36 = fmul double %0, %0
%37 = fdiv double 1.000000e+00, %36
%38 = fadd double %37, 0x3FFA51A6625307D3
%39 = tail call double @llvm.fmuladd.f64(double %0, double 0xC0033BA004F00621, double %38)
br label %19
40: ; preds = %33, %40
%41 = phi double [ %45, %40 ], [ 0.000000e+00, %33 ]
%42 = phi double [ %46, %40 ], [ %0, %33 ]
%43 = fmul double %42, %42
%44 = fdiv double 1.000000e+00, %43
%45 = fadd double %41, %44
%46 = fadd double %42, 1.000000e+00
%47 = fcmp olt double %46, 8.000000e+00
br i1 %47, label %40, label %48
48: ; preds = %40, %33
%49 = phi double [ %0, %33 ], [ %46, %40 ]
%50 = phi double [ 0.000000e+00, %33 ], [ %45, %40 ]
%51 = fcmp ult double %49, 8.000000e+00
br i1 %51, label %19, label %52
52: ; preds = %48
%53 = fmul double %49, %49
%54 = fdiv double 1.000000e+00, %53
%55 = tail call double @llvm.fmuladd.f64(double %54, double 0x3FB364D9364D9365, double 0xBFA1111111111111)
%56 = tail call double @llvm.fmuladd.f64(double %54, double %55, double 0x3F98618618618618)
%57 = tail call double @llvm.fmuladd.f64(double %54, double %56, double 0xBFA1111111111111)
%58 = tail call double @llvm.fmuladd.f64(double %54, double %57, double 0x3FC5555555555555)
%59 = tail call double @llvm.fmuladd.f64(double %54, double %58, double 1.000000e+00)
%60 = fdiv double %59, %49
%61 = tail call double @llvm.fmuladd.f64(double %54, double 5.000000e-01, double %60)
%62 = fadd double %50, %61
br label %19
}