#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 DBL_MIN;
double NAN;
double chebyshev_eval(double, double *, int);
int /*<<< orphan*/ printf(char *);
double lgammacor(double x) {
  const double algmcs[15] = {+.1666389480451863247205729650822e+0,
                             -.1384948176067563840732986059135e-4,
                             +.9810825646924729426157171547487e-8,
                             -.1809129475572494194263306266719e-10,
                             +.6221098041892605227126015543416e-13,
                             -.3399615005417721944303330599666e-15,
                             +.2683181998482698748957538846666e-17,
                             -.2868042435334643284144622399999e-19,
                             +.3962837061046434803679306666666e-21,
                             -.6831888753985766870111999999999e-23,
                             +.1429227355942498147573333333333e-24,
                             -.3547598158101070547199999999999e-26,
                             +.1025680058010470912000000000000e-27,
                             -.3401102254316748799999999999999e-29,
                             +.1276642195630062933333333333333e-30};
  double tmp;
  if (x < 10)
    return NAN;
  else if (x >= 3.745194030963158e306) {
    printf("lgammacor: underflow\n");
    return (DBL_MIN * DBL_MIN);
  } else if (x < 94906265.62425156) {
    tmp = 10 / x;
    return chebyshev_eval(tmp * tmp * 2 - 1, (double *)algmcs, 5) / x;
  } else
    return 1 / (x * 12);
}


x86 assembly (clang, -O0):
<lgammacor>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  %xmm0,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xee2(%rip),%rsi
mov    $0x78,%edx
call   1050 <memcpy@plt>
movsd  0xea0(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1180 <lgammacor+0x50>
mov    0x2e86(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1249 <lgammacor+0x119>
movsd  -0x10(%rbp),%xmm0
movsd  0xe7b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11c3 <lgammacor+0x93>
lea    0xf0a(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e2e(%rip),%rax
movsd  (%rax),%xmm0
mov    0x2e23(%rip),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1249 <lgammacor+0x119>
movsd  0xe45(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    122b <lgammacor+0xfb>
movsd  0xe22(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
mulsd  -0x98(%rbp),%xmm0
ff
addsd  %xmm0,%xmm0
movsd  0xe21(%rip),%xmm1
addsd  %xmm1,%xmm0
lea    -0x90(%rbp),%rdi
mov    $0x5,%esi
call   1030 <chebyshev_eval@plt>
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1249 <lgammacor+0x119>
movsd  0xded(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xdd8(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lgammacor>:
sub    $0x88,%rsp
movapd %xmm0,%xmm2
mov    0xf6e(%rip),%rax
mov    %rax,0x80(%rsp)
movaps 0xf4f(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xf33(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xf17(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xefb(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xedf(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xec3(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xea7(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movsd  0xe6a(%rip),%xmm0
ucomisd %xmm2,%xmm0
jbe    11af <lgammacor+0x8f>
mov    0x2e55(%rip),%rax
movsd  (%rax),%xmm0
add    $0x88,%rsp
ret
ucomisd 0xe51(%rip),%xmm2
jae    11fe <lgammacor+0xde>
movsd  0xe4f(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    1221 <lgammacor+0x101>
divsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm0,%xmm0
addsd  0xe4d(%rip),%xmm0
lea    0x10(%rsp),%rdi
mov    $0x5,%esi
movsd  %xmm2,0x8(%rsp)
call   1040 <chebyshev_eval@plt>
divsd  0x8(%rsp),%xmm0
add    $0x88,%rsp
ret
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dc7(%rip),%rax
movsd  (%rax),%xmm0
mulsd  %xmm0,%xmm0
add    $0x88,%rsp
ret
mulsd  0xdef(%rip),%xmm2
movsd  0xdef(%rip),%xmm0
divsd  %xmm2,%xmm0
add    $0x88,%rsp
ret

LLVM IR (-O0):
@__const.lgammacor.algmcs = [15 x double] [double 0x3FC5546CD00C0585, double 0xBEED0B6247814E7C, double 0x3E45118EF5D24DA0, double 0xBDB3E43F2C52269E, double 0x3D3182C608CBFAD6, double 0xBCB87F2ECBAE0CB1, double 0x3C48BF7BFF939163, double 0xBBE0EE102D34A3CE, double 0x3B7DF13DDDE77ADE, double 0xBB2084BBFC265C04, double 0x3AC61DC0BB850565, double 0xBA71911D6C58AFE7, double 0x3A2040A71190AE84, double 0xB9D13EE2154F4C7B, double 0x3984B6F6D66E9EFA]
@NAN = global double 0.000000e+00
@.str = [22 x i8] c"lgammacor: underflow\0A\00"
@DBL_MIN = global double 0.000000e+00
define double @lgammacor(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca [15 x double]
%5 = alloca double
store double %0, double* %3
%6 = bitcast [15 x double]* %4 to i8*
%7 = load double, double* %3
%8 = fcmp olt double %7, 1.000000e+01
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load double, double* @NAN
store double %10, double* %2
br label %37
11: ; preds = %1
%12 = load double, double* %3
%13 = fcmp oge double %12, 0x7F95555555555555
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%16 = load double, double* @DBL_MIN
%17 = load double, double* @DBL_MIN
%18 = fmul double %16, %17
store double %18, double* %2
br label %37
19: ; preds = %11
%20 = load double, double* %3
%21 = fcmp olt double %20, 0x4196A09E667F3BCD
br i1 %21, label %22, label %33
22: ; preds = %19
%23 = load double, double* %3
%24 = fdiv double 1.000000e+01, %23
store double %24, double* %5
%25 = load double, double* %5
%26 = load double, double* %5
%27 = fmul double %25, %26
%28 = call double @llvm.fmuladd.f64(double %27, double 2.000000e+00, double -1.000000e+00)
%29 = getelementptr inbounds [15 x double], [15 x double]* %4, i64 0, i64 0
%30 = call double @chebyshev_eval(double %28, double* %29, i32 5)
%31 = load double, double* %3
%32 = fdiv double %30, %31
store double %32, double* %2
br label %37
33: ; preds = %19
%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, %22, %14, %9
%38 = load double, double* %2
ret double %38
}

LLVM IR (-O2):
@__const.lgammacor.algmcs = [15 x double] [double 0x3FC5546CD00C0585, double 0xBEED0B6247814E7C, double 0x3E45118EF5D24DA0, double 0xBDB3E43F2C52269E, double 0x3D3182C608CBFAD6, double 0xBCB87F2ECBAE0CB1, double 0x3C48BF7BFF939163, double 0xBBE0EE102D34A3CE, double 0x3B7DF13DDDE77ADE, double 0xBB2084BBFC265C04, double 0x3AC61DC0BB850565, double 0xBA71911D6C58AFE7, double 0x3A2040A71190AE84, double 0xB9D13EE2154F4C7B, double 0x3984B6F6D66E9EFA]
@NAN = global double 0.000000e+00
@DBL_MIN = global double 0.000000e+00
@str = [21 x i8] c"lgammacor: underflow\00"
define double @lgammacor(double %0) {
%2 = alloca [15 x double]
%3 = bitcast [15 x double]* %2 to i8*
%4 = fcmp olt double %0, 1.000000e+01
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = load double, double* @NAN
br label %25
7: ; preds = %1
%8 = fcmp ult double %0, 0x7F95555555555555
br i1 %8, label %13, label %9
9: ; preds = %7
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%11 = load double, double* @DBL_MIN
%12 = fmul double %11, %11
br label %25
13: ; preds = %7
%14 = fcmp olt double %0, 0x4196A09E667F3BCD
br i1 %14, label %15, label %22
15: ; preds = %13
%16 = fdiv double 1.000000e+01, %0
%17 = fmul double %16, %16
%18 = tail call double @llvm.fmuladd.f64(double %17, double 2.000000e+00, double -1.000000e+00)
%19 = getelementptr inbounds [15 x double], [15 x double]* %2, i64 0, i64 0
%20 = call double @chebyshev_eval(double %18, double* %19, i32 5)
%21 = fdiv double %20, %0
br label %25
22: ; preds = %13
%23 = fmul double %0, 1.200000e+01
%24 = fdiv double 1.000000e+00, %23
br label %25
25: ; preds = %22, %15, %9, %5
%26 = phi double [ %6, %5 ], [ %12, %9 ], [ %21, %15 ], [ %24, %22 ]
ret double %26
}