#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*/ EXIT_FAILURE;
double chebyshev_eval(double, double const *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
double lngammacor(double x) {
  const static double algmcs[5] = {
      +.1666389480451863247205729650822e+0,
      -.1384948176067563840732986059135e-4,
      +.9810825646924729426157171547487e-8,
      -.1809129475572494194263306266719e-10,
      +.6221098041892605227126015543416e-13,
  };
  if (x < 10) {
    fprintf(stderr, "This function requires x >= 10");
    exit(EXIT_FAILURE);
  }
  if (x >= 3.745194030963158e306) {
    fprintf(stderr, "Underflow");
    exit(EXIT_FAILURE);
  }
  if (x < 94906265.62425156) {
    double tmp = 10 / x;
    return chebyshev_eval(tmp * tmp * 2 - 1, algmcs, 5) / x;
  }
  return 1 / (x * 12);
}


x86 assembly (clang, -O0):
<lngammacor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xebb(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1173 <lngammacor+0x43>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xef8(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movsd  -0x10(%rbp),%xmm0
movsd  0xe88(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11ad <lngammacor+0x7d>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    0xedd(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
movsd  0xe5b(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    120c <lngammacor+0xdc>
movsd  0xe38(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xe40(%rip),%xmm1
addsd  %xmm1,%xmm0
lea    0xe3d(%rip),%rdi
mov    $0x5,%esi
call   1030 <chebyshev_eval@plt>
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    122a <lngammacor+0xfa>
movsd  0xe0c(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xdf7(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lngammacor>:
push   %rax
movapd %xmm0,%xmm2
movsd  0xec3(%rip),%xmm0
ucomisd %xmm2,%xmm0
ja     11a2 <lngammacor+0x72>
ucomisd 0xebd(%rip),%xmm2
jae    11b4 <lngammacor+0x84>
movsd  0xebb(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    118c <lngammacor+0x5c>
divsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm0,%xmm0
addsd  0xeb9(%rip),%xmm0
lea    0xeba(%rip),%rdi
mov    $0x5,%esi
movsd  %xmm2,(%rsp)
call   1030 <chebyshev_eval@plt>
divsd  (%rsp),%xmm0
pop    %rax
ret
mulsd  0xe84(%rip),%xmm2
movsd  0xe84(%rip),%xmm0
divsd  %xmm2,%xmm0
pop    %rax
ret
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
lea    0xea6(%rip),%rsi
jmp    11c4 <lngammacor+0x94>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xeb3(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@lngammacor.algmcs = internal constant [5 x double] [double 0x3FC5546CD00C0585, double 0xBEED0B6247814E7C, double 0x3E45118EF5D24DA0, double 0xBDB3E43F2C52269E, double 0x3D3182C608CBFAD6]
@stderr = global i32 0
@.str = [31 x i8] c"This function requires x >= 10\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [10 x i8] c"Underflow\00"
define double @lngammacor(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %3
%5 = load double, double* %3
%6 = fcmp olt double %5, 1.000000e+01
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
%13 = load double, double* %3
%14 = fcmp oge double %13, 0x7F95555555555555
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %12
%21 = load double, double* %3
%22 = fcmp olt double %21, 0x4196A09E667F3BCD
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = load double, double* %3
%25 = fdiv double 1.000000e+01, %24
store double %25, double* %4
%26 = load double, double* %4
%27 = load double, double* %4
%28 = fmul double %26, %27
%29 = call double @llvm.fmuladd.f64(double %28, double 2.000000e+00, double -1.000000e+00)
%30 = call double @chebyshev_eval(double %29, double* getelementptr inbounds ([5 x double], [5 x double]* @lngammacor.algmcs, i64 0, i64 0), i32 5)
%31 = load double, double* %3
%32 = fdiv double %30, %31
store double %32, double* %2
br label %37
33: ; preds = %20
%34 = load double, double* %3
%35 = fmul double %34, 1.200000e+01
%36 = fdiv double 1.000000e+00, %35
store double %36, double* %2
br label %37
37: ; preds = %33, %23
%38 = load double, double* %2
ret double %38
}

LLVM IR (-O2):
@lngammacor.algmcs = internal constant [5 x double] [double 0x3FC5546CD00C0585, double 0xBEED0B6247814E7C, double 0x3E45118EF5D24DA0, double 0xBDB3E43F2C52269E, double 0x3D3182C608CBFAD6]
@stderr = global i32 0
@.str = [31 x i8] c"This function requires x >= 10\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [10 x i8] c"Underflow\00"
define double @lngammacor(double %0) {
%2 = fcmp olt double %0, 1.000000e+01
br i1 %2, label %3, label %8
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %1
%9 = fcmp ult double %0, 0x7F95555555555555
br i1 %9, label %15, label %10
10: ; preds = %8
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %8
%16 = fcmp olt double %0, 0x4196A09E667F3BCD
br i1 %16, label %17, label %23
17: ; preds = %15
%18 = fdiv double 1.000000e+01, %0
%19 = fmul double %18, %18
%20 = tail call double @llvm.fmuladd.f64(double %19, double 2.000000e+00, double -1.000000e+00)
%21 = tail call double @chebyshev_eval(double %20, double* getelementptr inbounds ([5 x double], [5 x double]* @lngammacor.algmcs, i64 0, i64 0), i32 5)
%22 = fdiv double %21, %0
br label %26
23: ; preds = %15
%24 = fmul double %0, 1.200000e+01
%25 = fdiv double 1.000000e+00, %24
br label %26
26: ; preds = %23, %17
%27 = phi double [ %22, %17 ], [ %25, %23 ]
ret double %27
}