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


x86 assembly (clang, -O0):
<MLdigamma>:
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 <MLdigamma+0x30>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c1 <MLdigamma+0xa1>
movsd  -0x10(%rbp),%xmm0
xor    %edi,%edi
mov    $0x1,%edx
lea    -0x18(%rbp),%rcx
lea    -0x1c(%rbp),%r8
lea    -0x20(%rbp),%r9
mov    %edx,%esi
call   1040 <dpsifn@plt>
cmpl   $0x0,-0x20(%rbp)
je     11a0 <MLdigamma+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    11c1 <MLdigamma+0xa1>
movsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MLdigamma>:
sub    $0x38,%rsp
movaps %xmm0,0x20(%rsp)
call   1030 <isnan@plt>
test   %rax,%rax
je     113d <MLdigamma+0x1d>
movaps 0x20(%rsp),%xmm0
add    $0x38,%rsp
ret
lea    0x10(%rsp),%rcx
lea    0x1c(%rsp),%r8
lea    0xc(%rsp),%r9
movaps 0x20(%rsp),%xmm0
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1040 <dpsifn@plt>
cmpl   $0x0,0xc(%rsp)
je     118b <MLdigamma+0x6b>
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
mov    0x2e57(%rip),%rcx
mov    %eax,(%rcx)
mov    0x2e66(%rip),%rax
movsd  (%rax),%xmm0
add    $0x38,%rsp
ret
movsd  0x10(%rsp),%xmm0
xorps  0xe68(%rip),%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
@EDOM = global i32 0
@errno = global i32 0
@FP_NAN = global double 0.000000e+00
define double @MLdigamma(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 %23
12: ; preds = %1
%13 = load double, double* %3
%14 = call i32 @dpsifn(double %13, i32 0, 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 %23
20: ; preds = %12
%21 = load double, double* %4
%22 = fneg double %21
store double %22, double* %2
br label %23
23: ; preds = %20, %17, %10
%24 = load double, double* %2
ret double %24
}

LLVM IR (-O2):
@EDOM = global i32 0
@errno = global i32 0
@FP_NAN = global double 0.000000e+00
define double @MLdigamma(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 %20
10: ; preds = %1
%11 = call i32 @dpsifn(double %0, i32 0, 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 %20
17: ; preds = %10
%18 = load double, double* %2
%19 = fneg double %18
br label %20
20: ; preds = %1, %17, %14
%21 = phi double [ %16, %14 ], [ %19, %17 ], [ %0, %1 ]
ret double %21
}