#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*/);
double exp(scalar_t__);
double fabs(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ lngammacor(double);
double log(double);
double sin(double);
int /*<<< orphan*/ stderr;
double gammafn(double x) {
  const double gamcs[22] = {
      +.8571195590989331421920062399942e-2,
      +.4415381324841006757191315771652e-2,
      +.5685043681599363378632664588789e-1,
      -.4219835396418560501012500186624e-2,
      +.1326808181212460220584006796352e-2,
      -.1893024529798880432523947023886e-3,
      +.3606925327441245256578082217225e-4,
      -.6056761904460864218485548290365e-5,
      +.1055829546302283344731823509093e-5,
      -.1811967365542384048291855891166e-6,
      +.3117724964715322277790254593169e-7,
      -.5354219639019687140874081024347e-8,
      +.9193275519859588946887786825940e-9,
      -.1577941280288339761767423273953e-9,
      +.2707980622934954543266540433089e-10,
      -.4646818653825730144081661058933e-11,
      +.7973350192007419656460767175359e-12,
      -.1368078209830916025799499172309e-12,
      +.2347319486563800657233471771688e-13,
      -.4027432614949066932766570534699e-14,
      +.6910051747372100912138336975257e-15,
      -.1185584500221992907052387126192e-15,
  };
  double y = fabs(x);
  if (y <= 10) {
    int n = (int)x;
    if (x < 0)
      --n;
    y = x - n;
    --n;
    double value = chebyshev_eval(y * 2 - 1, gamcs, 22) + .9375;
    if (n == 0)
      return value;
    if (n < 0) {
      if (x == 0 || (x < 0 && x == n + 2)) {
        fprintf(stderr, "x is 0 or a negative integer");
        exit(EXIT_FAILURE);
      }
      if (x < -0.5 && fabs((x - (int)(x - 0.5)) / x) < 67108864.0) {
        fprintf(
            stderr,
            "Answer < 1/2 precision because x is too near a negative integer");
        exit(EXIT_FAILURE);
      }
      if (y < 2.2474362225598545e-308) {
        fprintf(stderr, "x too close to 0");
        exit(EXIT_FAILURE);
      }
      n = -n;
      for (int i = 0; i < n; i++)
        value /= (x + i);
      return value;
    } else {
      for (int i = 1; i <= n; i++) {
        value *= (y + i);
      }
      return value;
    }
  } else {
    if (x > 171.61447887182298) {
      fprintf(stderr, "Overflow");
      exit(EXIT_FAILURE);
    }
    if (x < -170.5674972726612) {
      fprintf(stderr, "Underflow");
      exit(EXIT_FAILURE);
    }
    double value = exp((y - 0.5) * log(y) - y +
                       0.918938533204672741780329736406 + lngammacor(y));
    if (x > 0)
      return value;
    if (fabs((x - (int)(x - 0.5)) / x) < 67108864.0) {
      fprintf(
          stderr,
          "Answer < 1/2 precision because x is too near a negative integer");
      exit(EXIT_FAILURE);
    }
    double sinpiy = sin(3.141592653589793238462643383280 * y);
    if (sinpiy == 0) {
      fprintf(stderr, "Overflow");
      exit(EXIT_FAILURE);
    }
    return -3.141592653589793238462643383280 / (y * sinpiy * value);
  }
}


x86 assembly (clang, -O0):
<gammafn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movsd  %xmm0,-0x10(%rbp)
lea    -0xc0(%rbp),%rdi
lea    0xed2(%rip),%rsi
mov    $0xb0,%edx
call   1070 <memcpy@plt>
movsd  -0x10(%rbp),%xmm0
movaps 0xeac(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  0xe38(%rip),%xmm0
ucomisd -0xc8(%rbp),%xmm0
ff
jb     148d <gammafn+0x30d>
cvttsd2si -0x10(%rbp),%eax
mov    %eax,-0xcc(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11fe <gammafn+0x7e>
mov    -0xcc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xcc(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0xcc(%rbp),%xmm1
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
mov    -0xcc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xcc(%rbp)
movsd  -0xc8(%rbp),%xmm0
ff
addsd  %xmm0,%xmm0
movsd  0xe0e(%rip),%xmm1
addsd  %xmm1,%xmm0
lea    -0xc0(%rbp),%rdi
mov    $0x16,%esi
call   1040 <chebyshev_eval@plt>
movsd  0xde9(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
cmpl   $0x0,-0xcc(%rbp)
jne    1282 <gammafn+0x102>
movsd  -0xd8(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
jmp    16ab <gammafn+0x52b>
cmpl   $0x0,-0xcc(%rbp)
jge    1427 <gammafn+0x2a7>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12ac <gammafn+0x12c>
jp     12ac <gammafn+0x12c>
jmp    12dc <gammafn+0x15c>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    12ff <gammafn+0x17f>
movsd  -0x10(%rbp),%xmm0
mov    -0xcc(%rbp),%eax
add    $0x2,%eax
cvtsi2sd %eax,%xmm1
ucomisd %xmm1,%xmm0
jne    12ff <gammafn+0x17f>
jp     12ff <gammafn+0x17f>
mov    0x2cfd(%rip),%rax
mov    (%rax),%edi
lea    0xe34(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2ce0(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
movsd  0xd49(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1379 <gammafn+0x1f9>
movsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xcfc(%rip),%xmm2
subsd  %xmm2,%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
subsd  %xmm0,%xmm1
divsd  -0x10(%rbp),%xmm1
movaps 0xd20(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xcdc(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1379 <gammafn+0x1f9>
mov    0x2c83(%rip),%rax
mov    (%rax),%edi
lea    0xdd7(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2c66(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
movsd  0xcd7(%rip),%xmm0
ucomisd -0xc8(%rbp),%xmm0
ff
jbe    13b2 <gammafn+0x232>
mov    0x2c4a(%rip),%rax
mov    (%rax),%edi
lea    0xdde(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2c2d(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
xor    %eax,%eax
sub    -0xcc(%rbp),%eax
mov    %eax,-0xcc(%rbp)
movl   $0x0,-0xdc(%rbp)
mov    -0xdc(%rbp),%eax
cmp    -0xcc(%rbp),%eax
jge    1415 <gammafn+0x295>
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0xdc(%rbp),%xmm0
ff
addsd  %xmm0,%xmm1
movsd  -0xd8(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xd8(%rbp)
mov    -0xdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xdc(%rbp)
jmp    13ca <gammafn+0x24a>
movsd  -0xd8(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
jmp    16ab <gammafn+0x52b>
movl   $0x1,-0xe0(%rbp)
mov    -0xe0(%rbp),%eax
cmp    -0xcc(%rbp),%eax
jg     147b <gammafn+0x2fb>
movsd  -0xc8(%rbp),%xmm0
ff
cvtsi2sdl -0xe0(%rbp),%xmm1
ff
addsd  %xmm1,%xmm0
mulsd  -0xd8(%rbp),%xmm0
ff
movsd  %xmm0,-0xd8(%rbp)
ff
mov    -0xe0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe0(%rbp)
jmp    1431 <gammafn+0x2b1>
movsd  -0xd8(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
jmp    16ab <gammafn+0x52b>
movsd  -0x10(%rbp),%xmm0
movsd  0xb6e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    14c7 <gammafn+0x347>
mov    0x2b35(%rip),%rax
mov    (%rax),%edi
lea    0xcda(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2b18(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
movsd  0xb41(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    14fd <gammafn+0x37d>
mov    0x2aff(%rip),%rax
mov    (%rax),%edi
lea    0xcad(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2ae2(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
movsd  -0xc8(%rbp),%xmm0
ff
movsd  0xb13(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x100(%rbp)
ff
movsd  -0xc8(%rbp),%xmm0
ff
call   1090 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x100(%rbp),%xmm0
ff
movsd  -0xc8(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xab8(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xf8(%rbp)
ff
movsd  -0xc8(%rbp),%xmm0
ff
call   1030 <lngammacor@plt>
movsd  -0xf8(%rbp),%xmm0
ff
cvtsi2sd %rax,%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <exp@plt>
movsd  %xmm0,-0xe8(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    15c0 <gammafn+0x440>
movsd  -0xe8(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
jmp    16ab <gammafn+0x52b>
movsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xa4e(%rip),%xmm2
subsd  %xmm2,%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
subsd  %xmm0,%xmm1
divsd  -0x10(%rbp),%xmm1
movaps 0xa72(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xa2e(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1627 <gammafn+0x4a7>
mov    0x29d5(%rip),%rax
mov    (%rax),%edi
lea    0xb29(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x29b8(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
movsd  0xa01(%rip),%xmm0
mulsd  -0xc8(%rbp),%xmm0
ff
call   1060 <sin@plt>
movsd  %xmm0,-0xf0(%rbp)
ff
movsd  -0xf0(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1682 <gammafn+0x502>
jp     1682 <gammafn+0x502>
mov    0x297a(%rip),%rax
mov    (%rax),%edi
lea    0xb1f(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x295d(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
movsd  -0xc8(%rbp),%xmm1
ff
mulsd  -0xf0(%rbp),%xmm1
ff
mulsd  -0xe8(%rbp),%xmm1
ff
movsd  0x996(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gammafn>:
push   %r15
push   %r14
push   %rbx
sub    $0xe0,%rsp
movaps %xmm0,0x20(%rsp)
lea    0xee8(%rip),%rsi
lea    0x30(%rsp),%rdi
mov    $0xb0,%edx
call   1070 <memcpy@plt>
movapd 0x20(%rsp),%xmm1
movapd 0xe4b(%rip),%xmm0
andpd  %xmm1,%xmm0
movsd  0xe4f(%rip),%xmm2
ucomisd %xmm0,%xmm2
jae    12e7 <gammafn+0x167>
ucomisd 0xe85(%rip),%xmm1
ja     153a <gammafn+0x3ba>
movsd  0xe7f(%rip),%xmm2
ucomisd %xmm1,%xmm2
ja     154c <gammafn+0x3cc>
movsd  0xe45(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm0,0x10(%rsp)
call   1090 <log@plt>
mulsd  0x8(%rsp),%xmm0
movapd 0x10(%rsp),%xmm1
subsd  %xmm1,%xmm0
addsd  0xe48(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movapd %xmm1,%xmm0
call   1030 <lngammacor@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%rdi
call   1080 <exp@plt>
movapd %xmm0,%xmm3
xorpd  %xmm0,%xmm0
movapd 0x20(%rsp),%xmm2
ucomisd %xmm0,%xmm2
ja     1529 <gammafn+0x3a9>
movsd  %xmm3,0x8(%rsp)
movsd  0xdcb(%rip),%xmm0
addsd  %xmm2,%xmm0
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
movapd %xmm2,%xmm1
subsd  %xmm0,%xmm1
divsd  %xmm2,%xmm1
andpd  0xd73(%rip),%xmm1
movsd  0xdab(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     155e <gammafn+0x3de>
movsd  0xdc9(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
call   1060 <sin@plt>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    12c2 <gammafn+0x142>
jnp    153a <gammafn+0x3ba>
movapd 0x10(%rsp),%xmm2
mulsd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm1
mulsd  %xmm2,%xmm1
movsd  0xd9a(%rip),%xmm3
divsd  %xmm1,%xmm3
jmp    1529 <gammafn+0x3a9>
cvttsd2si %xmm1,%r14d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
ucomisd %xmm1,%xmm0
seta   %bl
mov    %r14d,%r15d
sub    %ebx,%r15d
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
subsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
addsd  %xmm1,%xmm0
addsd  0xcf7(%rip),%xmm0
lea    0x30(%rsp),%rdi
mov    $0x16,%esi
call   1040 <chebyshev_eval@plt>
movapd %xmm0,%xmm3
addsd  0xce4(%rip),%xmm3
cmp    $0x1,%r15d
je     1529 <gammafn+0x3a9>
jl     137e <gammafn+0x1fe>
neg    %ebx
lea    (%r14,%rbx,1),%edx
add    $0xffffffff,%edx
lea    (%r14,%rbx,1),%ecx
add    $0xfffffffe,%ecx
mov    %edx,%eax
and    $0x3,%eax
cmp    $0x3,%ecx
movapd 0x10(%rsp),%xmm5
jae    147d <gammafn+0x2fd>
mov    $0x1,%ecx
test   %eax,%eax
jne    1500 <gammafn+0x380>
jmp    1529 <gammafn+0x3a9>
xorpd  %xmm0,%xmm0
movapd 0x20(%rsp),%xmm4
ucomisd %xmm0,%xmm4
movapd 0x10(%rsp),%xmm2
jne    139a <gammafn+0x21a>
jnp    1570 <gammafn+0x3f0>
ucomisd %xmm4,%xmm0
jbe    13b7 <gammafn+0x237>
lea    0x1(%r15),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
ucomisd %xmm4,%xmm0
jne    13b7 <gammafn+0x237>
jnp    1570 <gammafn+0x3f0>
movsd  0xc79(%rip),%xmm0
ucomisd %xmm4,%xmm0
jbe    13ff <gammafn+0x27f>
movsd  0xc6b(%rip),%xmm0
addsd  %xmm4,%xmm0
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
movapd %xmm4,%xmm1
subsd  %xmm0,%xmm1
divsd  %xmm4,%xmm1
andpd  0xc13(%rip),%xmm1
movsd  0xc4b(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     155e <gammafn+0x3de>
movsd  0xc41(%rip),%xmm0
ucomisd %xmm2,%xmm0
ja     1582 <gammafn+0x402>
mov    $0x1,%eax
sub    %r15d,%eax
test   %eax,%eax
jle    1529 <gammafn+0x3a9>
test   %r15d,%r15d
je     1519 <gammafn+0x399>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
xor    %edx,%edx
xorpd  %xmm0,%xmm0
movsd  0xc13(%rip),%xmm1
nopl   (%rax)
movapd %xmm0,%xmm2
addsd  %xmm4,%xmm2
divsd  %xmm2,%xmm3
lea    0x1(%rdx),%esi
xorps  %xmm2,%xmm2
cvtsi2sd %esi,%xmm2
addsd  %xmm4,%xmm2
divsd  %xmm2,%xmm3
addsd  %xmm1,%xmm0
add    $0x2,%edx
cmp    %edx,%ecx
jne    1440 <gammafn+0x2c0>
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
test   $0x1,%al
jne    1521 <gammafn+0x3a1>
jmp    1529 <gammafn+0x3a9>
and    $0xfffffffc,%edx
neg    %edx
movsd  0xb9e(%rip),%xmm0
mov    $0x2,%ecx
movsd  0xb99(%rip),%xmm1
nopw   0x0(%rax,%rax,1)
movapd %xmm5,%xmm2
addsd  %xmm0,%xmm2
mulsd  %xmm3,%xmm2
xorps  %xmm3,%xmm3
cvtsi2sd %ecx,%xmm3
addsd  %xmm5,%xmm3
lea    0x1(%rcx),%esi
xorps  %xmm4,%xmm4
cvtsi2sd %esi,%xmm4
mulsd  %xmm2,%xmm3
addsd  %xmm5,%xmm4
mulsd  %xmm3,%xmm4
lea    0x2(%rcx),%esi
xorps  %xmm3,%xmm3
cvtsi2sd %esi,%xmm3
addsd  %xmm5,%xmm3
mulsd  %xmm4,%xmm3
addsd  %xmm1,%xmm0
mov    %ecx,%esi
add    $0x4,%ecx
add    %edx,%esi
add    $0x4,%esi
cmp    $0x2,%esi
jne    14a0 <gammafn+0x320>
add    $0xffffffff,%ecx
test   %eax,%eax
je     1529 <gammafn+0x3a9>
nopl   0x0(%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
addsd  %xmm5,%xmm0
mulsd  %xmm0,%xmm3
add    $0x1,%ecx
add    $0xffffffff,%eax
jne    1500 <gammafn+0x380>
jmp    1529 <gammafn+0x3a9>
xorpd  %xmm0,%xmm0
test   $0x1,%al
je     1529 <gammafn+0x3a9>
addsd  %xmm4,%xmm0
divsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
add    $0xe0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2a9f(%rip),%rax
mov    (%rax),%edi
lea    0xc54(%rip),%rsi
jmp    1592 <gammafn+0x412>
mov    0x2a8d(%rip),%rax
mov    (%rax),%edi
lea    0xc4b(%rip),%rsi
jmp    1592 <gammafn+0x412>
mov    0x2a7b(%rip),%rax
mov    (%rax),%edi
lea    0xbdf(%rip),%rsi
jmp    1592 <gammafn+0x412>
mov    0x2a69(%rip),%rax
mov    (%rax),%edi
lea    0xbb0(%rip),%rsi
jmp    1592 <gammafn+0x412>
mov    0x2a57(%rip),%rax
mov    (%rax),%edi
lea    0xbfb(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2a3a(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@__const.gammafn.gamcs = [22 x double] [double 0x3F818DC66601E198, double 0x3F7215DCE63BA49B, double 0x3FAD1B801DC6A8DB, double 0xBF7148D1705A9B75, double 0x3F55BD096FC4923F, double 0xBF28CFEFB06F916E, double 0x3F02E9221B0B1686, double 0xBED96766090001CE, double 0x3EB1B6C0DCF4B317, double 0xBE8851DF599CFB44, double 0x3E60BCF7F3C965FB, double 0xBE36FF06D9236CFB, double 0x3E0F967D9C3B28C0, double 0xBDE5AFE32702A03B, double 0x3DBDC649AF1415BD, double 0xBD946FDA49DB3346, double 0x3D6C0DC161495680, double 0xBD4341056E33D676, double 0x3D1A6DB012B7A94D, double 0xBCF223504CAF8514, double 0x3CC8E565D69D12A7, double 0xBCA11608E6BB0C2F]
@stderr = global i32 0
@.str = [29 x i8] c"x is 0 or a negative integer\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [64 x i8] c"Answer < 1/2 precision because x is too near a negative integer\00"
@.str.2 = [17 x i8] c"x too close to 0\00"
@.str.3 = [9 x i8] c"Overflow\00"
@.str.4 = [10 x i8] c"Underflow\00"
define double @gammafn(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca [22 x double]
%5 = alloca double
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double
store double %0, double* %3
%12 = bitcast [22 x double]* %4 to i8*
%13 = load double, double* %3
%14 = call double @llvm.fabs.f64(double %13)
store double %14, double* %5
%15 = load double, double* %5
%16 = fcmp ole double %15, 1.000000e+01
br i1 %16, label %17, label %124
17: ; preds = %1
%18 = load double, double* %3
%19 = fptosi double %18 to i32
store i32 %19, i32* %6
%20 = load double, double* %3
%21 = fcmp olt double %20, 0.000000e+00
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i32, i32* %6
%24 = add nsw i32 %23, -1
store i32 %24, i32* %6
br label %25
25: ; preds = %22, %17
%26 = load double, double* %3
%27 = load i32, i32* %6
%28 = sitofp i32 %27 to double
%29 = fsub double %26, %28
store double %29, double* %5
%30 = load i32, i32* %6
%31 = add nsw i32 %30, -1
store i32 %31, i32* %6
%32 = load double, double* %5
%33 = call double @llvm.fmuladd.f64(double %32, double 2.000000e+00, double -1.000000e+00)
%34 = getelementptr inbounds [22 x double], [22 x double]* %4, i64 0, i64 0
%35 = call double @chebyshev_eval(double %33, double* %34, i32 22)
%36 = fadd double %35, 9.375000e-01
store double %36, double* %7
%37 = load i32, i32* %6
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %25
%40 = load double, double* %7
store double %40, double* %2
br label %193
41: ; preds = %25
%42 = load i32, i32* %6
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %107
44: ; preds = %41
%45 = load double, double* %3
%46 = fcmp oeq double %45, 0.000000e+00
br i1 %46, label %56, label %47
47: ; preds = %44
%48 = load double, double* %3
%49 = fcmp olt double %48, 0.000000e+00
br i1 %49, label %50, label %61
50: ; preds = %47
%51 = load double, double* %3
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 2
%54 = sitofp i32 %53 to double
%55 = fcmp oeq double %51, %54
br i1 %55, label %56, label %61
56: ; preds = %50, %44
%57 = load i32, i32* @stderr
%58 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%59 = load i32, i32* @EXIT_FAILURE
%60 = call i32 @exit(i32 %59)
unreachable
61: ; preds = %50, %47
%62 = load double, double* %3
%63 = fcmp olt double %62, -5.000000e-01
br i1 %63, label %64, label %80
64: ; preds = %61
%65 = load double, double* %3
%66 = load double, double* %3
%67 = fsub double %66, 5.000000e-01
%68 = fptosi double %67 to i32
%69 = sitofp i32 %68 to double
%70 = fsub double %65, %69
%71 = load double, double* %3
%72 = fdiv double %70, %71
%73 = call double @llvm.fabs.f64(double %72)
%74 = fcmp olt double %73, 0x4190000000000000
br i1 %74, label %75, label %80
75: ; preds = %64
%76 = load i32, i32* @stderr
%77 = call i32 @fprintf(i32 %76, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.1, i64 0, i64 0))
%78 = load i32, i32* @EXIT_FAILURE
%79 = call i32 @exit(i32 %78)
unreachable
80: ; preds = %64, %61
%81 = load double, double* %5
%82 = fcmp olt double %81, 0x10292A5D2F227A
br i1 %82, label %83, label %88
83: ; preds = %80
%84 = load i32, i32* @stderr
%85 = call i32 @fprintf(i32 %84, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%86 = load i32, i32* @EXIT_FAILURE
%87 = call i32 @exit(i32 %86)
unreachable
88: ; preds = %80
%89 = load i32, i32* %6
%90 = sub nsw i32 0, %89
store i32 %90, i32* %6
store i32 0, i32* %8
br label %91
91: ; preds = %102, %88
%92 = load i32, i32* %8
%93 = load i32, i32* %6
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %105
95: ; preds = %91
%96 = load double, double* %3
%97 = load i32, i32* %8
%98 = sitofp i32 %97 to double
%99 = fadd double %96, %98
%100 = load double, double* %7
%101 = fdiv double %100, %99
store double %101, double* %7
br label %102
102: ; preds = %95
%103 = load i32, i32* %8
%104 = add nsw i32 %103, 1
store i32 %104, i32* %8
br label %91
105: ; preds = %91
%106 = load double, double* %7
store double %106, double* %2
br label %193
107: ; preds = %41
store i32 1, i32* %9
br label %108
108: ; preds = %119, %107
%109 = load i32, i32* %9
%110 = load i32, i32* %6
%111 = icmp sle i32 %109, %110
br i1 %111, label %112, label %122
112: ; preds = %108
%113 = load double, double* %5
%114 = load i32, i32* %9
%115 = sitofp i32 %114 to double
%116 = fadd double %113, %115
%117 = load double, double* %7
%118 = fmul double %117, %116
store double %118, double* %7
br label %119
119: ; preds = %112
%120 = load i32, i32* %9
%121 = add nsw i32 %120, 1
store i32 %121, i32* %9
br label %108
122: ; preds = %108
%123 = load double, double* %7
store double %123, double* %2
br label %193
124: ; preds = %1
%125 = load double, double* %3
%126 = fcmp ogt double %125, 0x406573A9CF985201
br i1 %126, label %127, label %132
127: ; preds = %124
%128 = load i32, i32* @stderr
%129 = call i32 @fprintf(i32 %128, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%130 = load i32, i32* @EXIT_FAILURE
%131 = call i32 @exit(i32 %130)
unreachable
132: ; preds = %124
%133 = load double, double* %3
%134 = fcmp olt double %133, 0xC0655228F00A54C5
br i1 %134, label %135, label %140
135: ; preds = %132
%136 = load i32, i32* @stderr
%137 = call i32 @fprintf(i32 %136, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%138 = load i32, i32* @EXIT_FAILURE
%139 = call i32 @exit(i32 %138)
unreachable
140: ; preds = %132
%141 = load double, double* %5
%142 = fsub double %141, 5.000000e-01
%143 = load double, double* %5
%144 = call double @log(double %143)
%145 = load double, double* %5
%146 = fneg double %145
%147 = call double @llvm.fmuladd.f64(double %142, double %144, double %146)
%148 = fadd double %147, 0x3FED67F1C864BEB5
%149 = load double, double* %5
%150 = call i64 @lngammacor(double %149)
%151 = sitofp i64 %150 to double
%152 = fadd double %148, %151
%153 = fptosi double %152 to i64
%154 = call double @exp(i64 %153)
store double %154, double* %10
%155 = load double, double* %3
%156 = fcmp ogt double %155, 0.000000e+00
br i1 %156, label %157, label %159
157: ; preds = %140
%158 = load double, double* %10
store double %158, double* %2
br label %193
159: ; preds = %140
%160 = load double, double* %3
%161 = load double, double* %3
%162 = fsub double %161, 5.000000e-01
%163 = fptosi double %162 to i32
%164 = sitofp i32 %163 to double
%165 = fsub double %160, %164
%166 = load double, double* %3
%167 = fdiv double %165, %166
%168 = call double @llvm.fabs.f64(double %167)
%169 = fcmp olt double %168, 0x4190000000000000
br i1 %169, label %170, label %175
170: ; preds = %159
%171 = load i32, i32* @stderr
%172 = call i32 @fprintf(i32 %171, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.1, i64 0, i64 0))
%173 = load i32, i32* @EXIT_FAILURE
%174 = call i32 @exit(i32 %173)
unreachable
175: ; preds = %159
%176 = load double, double* %5
%177 = fmul double 0x400921FB54442D18, %176
%178 = call double @sin(double %177)
store double %178, double* %11
%179 = load double, double* %11
%180 = fcmp oeq double %179, 0.000000e+00
br i1 %180, label %181, label %186
181: ; preds = %175
%182 = load i32, i32* @stderr
%183 = call i32 @fprintf(i32 %182, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%184 = load i32, i32* @EXIT_FAILURE
%185 = call i32 @exit(i32 %184)
unreachable
186: ; preds = %175
%187 = load double, double* %5
%188 = load double, double* %11
%189 = fmul double %187, %188
%190 = load double, double* %10
%191 = fmul double %189, %190
%192 = fdiv double 0xC00921FB54442D18, %191
store double %192, double* %2
br label %193
193: ; preds = %186, %157, %122, %105, %39
%194 = load double, double* %2
ret double %194
}

LLVM IR (-O2):
@__const.gammafn.gamcs = [22 x double] [double 0x3F818DC66601E198, double 0x3F7215DCE63BA49B, double 0x3FAD1B801DC6A8DB, double 0xBF7148D1705A9B75, double 0x3F55BD096FC4923F, double 0xBF28CFEFB06F916E, double 0x3F02E9221B0B1686, double 0xBED96766090001CE, double 0x3EB1B6C0DCF4B317, double 0xBE8851DF599CFB44, double 0x3E60BCF7F3C965FB, double 0xBE36FF06D9236CFB, double 0x3E0F967D9C3B28C0, double 0xBDE5AFE32702A03B, double 0x3DBDC649AF1415BD, double 0xBD946FDA49DB3346, double 0x3D6C0DC161495680, double 0xBD4341056E33D676, double 0x3D1A6DB012B7A94D, double 0xBCF223504CAF8514, double 0x3CC8E565D69D12A7, double 0xBCA11608E6BB0C2F]
@stderr = global i32 0
@.str = [29 x i8] c"x is 0 or a negative integer\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [64 x i8] c"Answer < 1/2 precision because x is too near a negative integer\00"
@.str.2 = [17 x i8] c"x too close to 0\00"
@.str.3 = [9 x i8] c"Overflow\00"
@.str.4 = [10 x i8] c"Underflow\00"
define double @gammafn(double %0) {
%2 = alloca [22 x double]
%3 = bitcast [22 x double]* %2 to i8*
%4 = tail call double @llvm.fabs.f64(double %0)
%5 = fcmp ugt double %4, 1.000000e+01
br i1 %5, label %106, label %6
6: ; preds = %1
%7 = fptosi double %0 to i32
%8 = fcmp olt double %0, 0.000000e+00
%9 = sext i1 %8 to i32
%10 = add i32 %9, %7
%11 = sitofp i32 %10 to double
%12 = fsub double %0, %11
%13 = tail call double @llvm.fmuladd.f64(double %12, double 2.000000e+00, double -1.000000e+00)
%14 = getelementptr inbounds [22 x double], [22 x double]* %2, i64 0, i64 0
%15 = call double @chebyshev_eval(double %13, double* %14, i32 22)
%16 = fadd double %15, 9.375000e-01
%17 = icmp eq i32 %10, 1
br i1 %17, label %183, label %18
18: ; preds = %6
%19 = icmp slt i32 %10, 1
br i1 %19, label %28, label %20
20: ; preds = %18
%21 = add i32 %7, %9
%22 = add i32 %21, -1
%23 = add i32 %21, -2
%24 = and i32 %22, 3
%25 = icmp ult i32 %23, 3
br i1 %25, label %168, label %26
26: ; preds = %20
%27 = and i32 %22, -4
br label %84
28: ; preds = %18
%29 = fcmp oeq double %0, 0.000000e+00
br i1 %29, label %35, label %30
30: ; preds = %28
br i1 %8, label %31, label %40
31: ; preds = %30
%32 = add nsw i32 %10, 1
%33 = sitofp i32 %32 to double
%34 = fcmp oeq double %33, %0
br i1 %34, label %35, label %40
35: ; preds = %31, %28
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%38 = load i32, i32* @EXIT_FAILURE
%39 = call i32 @exit(i32 %38)
unreachable
40: ; preds = %31, %30
%41 = fcmp olt double %0, -5.000000e-01
br i1 %41, label %42, label %55
42: ; preds = %40
%43 = fadd double %0, -5.000000e-01
%44 = fptosi double %43 to i32
%45 = sitofp i32 %44 to double
%46 = fsub double %0, %45
%47 = fdiv double %46, %0
%48 = call double @llvm.fabs.f64(double %47)
%49 = fcmp olt double %48, 0x4190000000000000
br i1 %49, label %50, label %55
50: ; preds = %42
%51 = load i32, i32* @stderr
%52 = call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.1, i64 0, i64 0))
%53 = load i32, i32* @EXIT_FAILURE
%54 = call i32 @exit(i32 %53)
unreachable
55: ; preds = %42, %40
%56 = fcmp olt double %12, 0x10292A5D2F227A
br i1 %56, label %57, label %62
57: ; preds = %55
%58 = load i32, i32* @stderr
%59 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%60 = load i32, i32* @EXIT_FAILURE
%61 = call i32 @exit(i32 %60)
unreachable
62: ; preds = %55
%63 = sub i32 1, %10
%64 = icmp sgt i32 %63, 0
br i1 %64, label %65, label %183
65: ; preds = %62
%66 = and i32 %63, 1
%67 = icmp eq i32 %10, 0
br i1 %67, label %160, label %68
68: ; preds = %65
%69 = and i32 %63, -2
br label %70
70: ; preds = %70, %68
%71 = phi i32 [ 0, %68 ], [ %81, %70 ]
%72 = phi double [ %16, %68 ], [ %80, %70 ]
%73 = phi i32 [ 0, %68 ], [ %82, %70 ]
%74 = sitofp i32 %71 to double
%75 = fadd double %74, %0
%76 = fdiv double %72, %75
%77 = or i32 %71, 1
%78 = sitofp i32 %77 to double
%79 = fadd double %78, %0
%80 = fdiv double %76, %79
%81 = add nuw nsw i32 %71, 2
%82 = add i32 %73, 2
%83 = icmp eq i32 %82, %69
br i1 %83, label %158, label %70
84: ; preds = %84, %26
%85 = phi i32 [ 1, %26 ], [ %103, %84 ]
%86 = phi double [ %16, %26 ], [ %102, %84 ]
%87 = phi i32 [ 0, %26 ], [ %104, %84 ]
%88 = sitofp i32 %85 to double
%89 = fadd double %12, %88
%90 = fmul double %86, %89
%91 = add nuw nsw i32 %85, 1
%92 = sitofp i32 %91 to double
%93 = fadd double %12, %92
%94 = fmul double %90, %93
%95 = add nuw nsw i32 %85, 2
%96 = sitofp i32 %95 to double
%97 = fadd double %12, %96
%98 = fmul double %94, %97
%99 = add nuw nsw i32 %85, 3
%100 = sitofp i32 %99 to double
%101 = fadd double %12, %100
%102 = fmul double %98, %101
%103 = add nuw nsw i32 %85, 4
%104 = add i32 %87, 4
%105 = icmp eq i32 %104, %27
br i1 %105, label %168, label %84
106: ; preds = %1
%107 = fcmp ogt double %0, 0x406573A9CF985201
br i1 %107, label %108, label %113
108: ; preds = %106
%109 = load i32, i32* @stderr
%110 = tail call i32 @fprintf(i32 %109, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%111 = load i32, i32* @EXIT_FAILURE
%112 = tail call i32 @exit(i32 %111)
unreachable
113: ; preds = %106
%114 = fcmp olt double %0, 0xC0655228F00A54C5
br i1 %114, label %115, label %120
115: ; preds = %113
%116 = load i32, i32* @stderr
%117 = tail call i32 @fprintf(i32 %116, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%118 = load i32, i32* @EXIT_FAILURE
%119 = tail call i32 @exit(i32 %118)
unreachable
120: ; preds = %113
%121 = fadd double %4, -5.000000e-01
%122 = tail call double @log(double %4)
%123 = fneg double %4
%124 = tail call double @llvm.fmuladd.f64(double %121, double %122, double %123)
%125 = fadd double %124, 0x3FED67F1C864BEB5
%126 = tail call i64 @lngammacor(double %4)
%127 = sitofp i64 %126 to double
%128 = fadd double %125, %127
%129 = fptosi double %128 to i64
%130 = tail call double @exp(i64 %129)
%131 = fcmp ogt double %0, 0.000000e+00
br i1 %131, label %183, label %132
132: ; preds = %120
%133 = fadd double %0, -5.000000e-01
%134 = fptosi double %133 to i32
%135 = sitofp i32 %134 to double
%136 = fsub double %0, %135
%137 = fdiv double %136, %0
%138 = tail call double @llvm.fabs.f64(double %137)
%139 = fcmp olt double %138, 0x4190000000000000
br i1 %139, label %140, label %145
140: ; preds = %132
%141 = load i32, i32* @stderr
%142 = tail call i32 @fprintf(i32 %141, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.1, i64 0, i64 0))
%143 = load i32, i32* @EXIT_FAILURE
%144 = tail call i32 @exit(i32 %143)
unreachable
145: ; preds = %132
%146 = fmul double %4, 0x400921FB54442D18
%147 = tail call double @sin(double %146)
%148 = fcmp oeq double %147, 0.000000e+00
br i1 %148, label %149, label %154
149: ; preds = %145
%150 = load i32, i32* @stderr
%151 = tail call i32 @fprintf(i32 %150, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%152 = load i32, i32* @EXIT_FAILURE
%153 = tail call i32 @exit(i32 %152)
unreachable
154: ; preds = %145
%155 = fmul double %4, %147
%156 = fmul double %130, %155
%157 = fdiv double 0xC00921FB54442D18, %156
br label %183
158: ; preds = %70
%159 = sitofp i32 %81 to double
br label %160
160: ; preds = %158, %65
%161 = phi double [ undef, %65 ], [ %80, %158 ]
%162 = phi double [ 0.000000e+00, %65 ], [ %159, %158 ]
%163 = phi double [ %16, %65 ], [ %80, %158 ]
%164 = icmp eq i32 %66, 0
br i1 %164, label %183, label %165
165: ; preds = %160
%166 = fadd double %162, %0
%167 = fdiv double %163, %166
br label %183
168: ; preds = %84, %20
%169 = phi double [ undef, %20 ], [ %102, %84 ]
%170 = phi i32 [ 1, %20 ], [ %103, %84 ]
%171 = phi double [ %16, %20 ], [ %102, %84 ]
%172 = icmp eq i32 %24, 0
br i1 %172, label %183, label %173
173: ; preds = %168, %173
%174 = phi i32 [ %180, %173 ], [ %170, %168 ]
%175 = phi double [ %179, %173 ], [ %171, %168 ]
%176 = phi i32 [ %181, %173 ], [ 0, %168 ]
%177 = sitofp i32 %174 to double
%178 = fadd double %12, %177
%179 = fmul double %175, %178
%180 = add nuw nsw i32 %174, 1
%181 = add i32 %176, 1
%182 = icmp eq i32 %181, %24
br i1 %182, label %183, label %173
183: ; preds = %168, %173, %165, %160, %62, %154, %120, %6
%184 = phi double [ %16, %6 ], [ %157, %154 ], [ %130, %120 ], [ %16, %62 ], [ %161, %160 ], [ %167, %165 ], [ %169, %168 ], [ %179, %173 ]
ret double %184
}