#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 */
int /*<<< orphan*/ EDOM;
double FP_NAN;
int /*<<< orphan*/ dpsifn(double, int, int, int, double *, int *, int *);
int /*<<< orphan*/ errno;
scalar_t__ isnan(double);
double MLtrigamma(double x) {
  double ans;
  int nz, ierr;
  if (isnan(x))
    return x;
  dpsifn(x, 1, 1, 1, &ans, &nz, &ierr);
  if (ierr != 0) {
    errno = EDOM;
    return FP_NAN;
  };
  return ans;
}


x86 assembly (clang, -O0):
<MLtrigamma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
je     1150 <MLtrigamma+0x30>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11aa <MLtrigamma+0x8a>
movsd  -0x10(%rbp),%xmm0
mov    $0x1,%edx
lea    -0x18(%rbp),%rcx
lea    -0x1c(%rbp),%r8
lea    -0x20(%rbp),%r9
mov    %edx,%edi
mov    %edx,%esi
call   1040 <dpsifn@plt>
cmpl   $0x0,-0x20(%rbp)
je     11a0 <MLtrigamma+0x80>
mov    0x2e60(%rip),%rax
mov    (%rax),%ecx
mov    0x2e47(%rip),%rax
mov    %ecx,(%rax)
mov    0x2e56(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11aa <MLtrigamma+0x8a>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MLtrigamma>:
sub    $0x28,%rsp
movsd  %xmm0,0x10(%rsp)
call   1030 <isnan@plt>
test   %rax,%rax
je     113f <MLtrigamma+0x1f>
movsd  0x10(%rsp),%xmm0
add    $0x28,%rsp
ret
lea    0x18(%rsp),%rcx
lea    0x24(%rsp),%r8
lea    0xc(%rsp),%r9
movsd  0x10(%rsp),%xmm0
mov    $0x1,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1040 <dpsifn@plt>
cmpl   $0x0,0xc(%rsp)
je     1191 <MLtrigamma+0x71>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    0x2e51(%rip),%rcx
mov    %eax,(%rcx)
mov    0x2e60(%rip),%rax
movsd  (%rax),%xmm0
add    $0x28,%rsp
ret
movsd  0x18(%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@EDOM = global i32 0
@errno = global i32 0
@FP_NAN = global double 0.000000e+00
define double @MLtrigamma(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
store double %0, double* %3
%7 = load double, double* %3
%8 = call i64 @isnan(double %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load double, double* %3
store double %11, double* %2
br label %22
12: ; preds = %1
%13 = load double, double* %3
%14 = call i32 @dpsifn(double %13, i32 1, i32 1, i32 1, double* %4, i32* %5, i32* %6)
%15 = load i32, i32* %6
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32, i32* @EDOM
store i32 %18, i32* @errno
%19 = load double, double* @FP_NAN
store double %19, double* %2
br label %22
20: ; preds = %12
%21 = load double, double* %4
store double %21, double* %2
br label %22
22: ; preds = %20, %17, %10
%23 = load double, double* %2
ret double %23
}

LLVM IR (-O2):
@EDOM = global i32 0
@errno = global i32 0
@FP_NAN = global double 0.000000e+00
define double @MLtrigamma(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
%5 = bitcast double* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = tail call i64 @isnan(double %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %1
%11 = call i32 @dpsifn(double %0, i32 1, i32 1, i32 1, double* %2, i32* %3, i32* %4)
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = load i32, i32* @EDOM
store i32 %15, i32* @errno
%16 = load double, double* @FP_NAN
br label %19
17: ; preds = %10
%18 = load double, double* %2
br label %19
19: ; preds = %1, %17, %14
%20 = phi double [ %16, %14 ], [ %18, %17 ], [ %0, %1 ]
ret double %20
}