#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 exp(double);
double fabs(double);
double log(double);
double logGamma(double);
double gammaCF(double x, double a) {
  int n, maxit = 100;
  double eps = 0.0000003;
  double gln = logGamma(a), g = 0, gold = 0, a0 = 1, a1 = x, b0 = 0, b1 = 1,
         fac = 1;
  double an, ana, anf;
  for (n = 1; n <= maxit; n++) {
    an = 1.0 * n;
    ana = an - a;
    a0 = (a1 + a0 * ana) * fac;
    b0 = (b1 + b0 * ana) * fac;
    anf = an * fac;
    a1 = x * a0 + anf * a1;
    b1 = x * b0 + anf * b1;
    if (a1 != 0) {
      fac = 1.0 / a1;
      g = b1 * fac;
      if (fabs((g - gold) / g) < eps)
        break;
      gold = g;
    }
  }
  return exp(-x + a * log(x) - gln) * g;
}


x86 assembly (clang, -O0):
<gammaCF>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movl   $0x64,-0x18(%rbp)
movsd  0xeb4(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <logGamma@plt>
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe80(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe61(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe54(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1305 <gammaCF+0x1d5>
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xe2f(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x58(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x68(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x78(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1299 <gammaCF+0x169>
jp     1299 <gammaCF+0x169>
jmp    12f2 <gammaCF+0x1c2>
movsd  0xd5f(%rip),%xmm0
divsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
divsd  -0x30(%rbp),%xmm1
movaps 0xd40(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12e8 <gammaCF+0x1b8>
jmp    1305 <gammaCF+0x1d5>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    12f7 <gammaCF+0x1c7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b8 <gammaCF+0x88>
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <log@plt>
movsd  -0x88(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x28(%rbp),%xmm0
call   1030 <exp@plt>
mulsd  -0x30(%rbp),%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gammaCF>:
sub    $0x38,%rsp
movsd  %xmm1,(%rsp)
movaps %xmm0,0x10(%rsp)
movapd %xmm1,%xmm0
call   1040 <logGamma@plt>
movsd  (%rsp),%xmm13
movsd  %xmm0,0x8(%rsp)
movapd 0xea5(%rip),%xmm2
movapd 0x10(%rsp),%xmm6
unpcklpd %xmm6,%xmm2
movsd  0xeb2(%rip),%xmm10
xorpd  %xmm3,%xmm3
unpcklpd %xmm10,%xmm3
movapd %xmm6,%xmm11
unpcklpd %xmm6,%xmm6
xorpd  %xmm12,%xmm12
mov    $0x1,%eax
movapd 0xe7d(%rip),%xmm8
movsd  0xe8c(%rip),%xmm9
xorpd  %xmm5,%xmm5
xorpd  %xmm4,%xmm4
movapd %xmm10,%xmm1
jmp    11bc <gammaCF+0x8c>
nopl   0x0(%rax,%rax,1)
add    $0x1,%eax
cmp    $0x65,%eax
je     123e <gammaCF+0x10e>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd %xmm1,%xmm7
mulsd  %xmm0,%xmm7
subsd  %xmm13,%xmm0
unpcklpd %xmm0,%xmm0
mulpd  %xmm3,%xmm0
addpd  %xmm2,%xmm0
movapd %xmm1,%xmm3
unpcklpd %xmm1,%xmm3
mulpd  %xmm0,%xmm3
unpcklpd %xmm7,%xmm7
mulpd  %xmm2,%xmm7
movapd %xmm6,%xmm2
mulpd  %xmm3,%xmm2
addpd  %xmm7,%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
ucomisd %xmm12,%xmm0
jne    120d <gammaCF+0xdd>
jnp    11b0 <gammaCF+0x80>
movapd %xmm10,%xmm1
divsd  %xmm0,%xmm1
movapd %xmm2,%xmm5
mulsd  %xmm1,%xmm5
movapd %xmm5,%xmm0
subsd  %xmm4,%xmm0
divsd  %xmm5,%xmm0
andpd  %xmm8,%xmm0
ucomisd %xmm0,%xmm9
movapd %xmm5,%xmm4
jbe    11b0 <gammaCF+0x80>
movapd %xmm5,0x20(%rsp)
movapd %xmm11,%xmm0
call   1050 <log@plt>
mulsd  (%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
call   1030 <exp@plt>
mulsd  0x20(%rsp),%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define double @gammaCF(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store double %0, double* %3
store double %1, double* %4
store i32 100, i32* %6
store double 3.000000e-07, double* %7
%19 = load double, double* %4
%20 = call double @logGamma(double %19)
store double %20, double* %8
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %10
store double 1.000000e+00, double* %11
%21 = load double, double* %3
store double %21, double* %12
store double 0.000000e+00, double* %13
store double 1.000000e+00, double* %14
store double 1.000000e+00, double* %15
store i32 1, i32* %5
br label %22
22: ; preds = %80, %2
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %83
26: ; preds = %22
%27 = load i32, i32* %5
%28 = sitofp i32 %27 to double
%29 = fmul double 1.000000e+00, %28
store double %29, double* %16
%30 = load double, double* %16
%31 = load double, double* %4
%32 = fsub double %30, %31
store double %32, double* %17
%33 = load double, double* %12
%34 = load double, double* %11
%35 = load double, double* %17
%36 = call double @llvm.fmuladd.f64(double %34, double %35, double %33)
%37 = load double, double* %15
%38 = fmul double %36, %37
store double %38, double* %11
%39 = load double, double* %14
%40 = load double, double* %13
%41 = load double, double* %17
%42 = call double @llvm.fmuladd.f64(double %40, double %41, double %39)
%43 = load double, double* %15
%44 = fmul double %42, %43
store double %44, double* %13
%45 = load double, double* %16
%46 = load double, double* %15
%47 = fmul double %45, %46
store double %47, double* %18
%48 = load double, double* %3
%49 = load double, double* %11
%50 = load double, double* %18
%51 = load double, double* %12
%52 = fmul double %50, %51
%53 = call double @llvm.fmuladd.f64(double %48, double %49, double %52)
store double %53, double* %12
%54 = load double, double* %3
%55 = load double, double* %13
%56 = load double, double* %18
%57 = load double, double* %14
%58 = fmul double %56, %57
%59 = call double @llvm.fmuladd.f64(double %54, double %55, double %58)
store double %59, double* %14
%60 = load double, double* %12
%61 = fcmp une double %60, 0.000000e+00
br i1 %61, label %62, label %79
62: ; preds = %26
%63 = load double, double* %12
%64 = fdiv double 1.000000e+00, %63
store double %64, double* %15
%65 = load double, double* %14
%66 = load double, double* %15
%67 = fmul double %65, %66
store double %67, double* %9
%68 = load double, double* %9
%69 = load double, double* %10
%70 = fsub double %68, %69
%71 = load double, double* %9
%72 = fdiv double %70, %71
%73 = call double @llvm.fabs.f64(double %72)
%74 = load double, double* %7
%75 = fcmp olt double %73, %74
br i1 %75, label %76, label %77
76: ; preds = %62
br label %83
77: ; preds = %62
%78 = load double, double* %9
store double %78, double* %10
br label %79
79: ; preds = %77, %26
br label %80
80: ; preds = %79
%81 = load i32, i32* %5
%82 = add nsw i32 %81, 1
store i32 %82, i32* %5
br label %22
83: ; preds = %76, %22
%84 = load double, double* %3
%85 = fneg double %84
%86 = load double, double* %4
%87 = load double, double* %3
%88 = call double @log(double %87)
%89 = call double @llvm.fmuladd.f64(double %86, double %88, double %85)
%90 = load double, double* %8
%91 = fsub double %89, %90
%92 = call double @exp(double %91)
%93 = load double, double* %9
%94 = fmul double %92, %93
ret double %94
}

LLVM IR (-O2):
define double @gammaCF(double %0, double %1) {
%3 = tail call double @logGamma(double %1)
%4 = insertelement <2 x double> <double 1.000000e+00, double poison>, double %0, i64 1
%5 = insertelement <2 x double> poison, double %0, i64 0
%6 = shufflevector <2 x double> %5, <2 x double> poison, <2 x i32> zeroinitializer
br label %7
7: ; preds = %2, %37
%8 = phi i32 [ 1, %2 ], [ %41, %37 ]
%9 = phi double [ 0.000000e+00, %2 ], [ %40, %37 ]
%10 = phi double [ 0.000000e+00, %2 ], [ %39, %37 ]
%11 = phi double [ 1.000000e+00, %2 ], [ %38, %37 ]
%12 = phi <2 x double> [ <double 0.000000e+00, double 1.000000e+00>, %2 ], [ %21, %37 ]
%13 = phi <2 x double> [ %4, %2 ], [ %26, %37 ]
%14 = sitofp i32 %8 to double
%15 = fsub double %14, %1
%16 = insertelement <2 x double> poison, double %15, i64 0
%17 = shufflevector <2 x double> %16, <2 x double> poison, <2 x i32> zeroinitializer
%18 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %12, <2 x double> %17, <2 x double> %13)
%19 = insertelement <2 x double> poison, double %11, i64 0
%20 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> zeroinitializer
%21 = fmul <2 x double> %20, %18
%22 = fmul double %11, %14
%23 = insertelement <2 x double> poison, double %22, i64 0
%24 = shufflevector <2 x double> %23, <2 x double> poison, <2 x i32> zeroinitializer
%25 = fmul <2 x double> %13, %24
%26 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %6, <2 x double> %21, <2 x double> %25)
%27 = extractelement <2 x double> %26, i64 1
%28 = fcmp une double %27, 0.000000e+00
br i1 %28, label %29, label %37
29: ; preds = %7
%30 = fdiv double 1.000000e+00, %27
%31 = extractelement <2 x double> %26, i64 0
%32 = fmul double %31, %30
%33 = fsub double %32, %10
%34 = fdiv double %33, %32
%35 = tail call double @llvm.fabs.f64(double %34)
%36 = fcmp olt double %35, 3.000000e-07
br i1 %36, label %43, label %37
37: ; preds = %29, %7
%38 = phi double [ %11, %7 ], [ %30, %29 ]
%39 = phi double [ %10, %7 ], [ %32, %29 ]
%40 = phi double [ %9, %7 ], [ %32, %29 ]
%41 = add nuw nsw i32 %8, 1
%42 = icmp eq i32 %41, 101
br i1 %42, label %43, label %7
43: ; preds = %29, %37
%44 = phi double [ %32, %29 ], [ %40, %37 ]
%45 = fneg double %0
%46 = tail call double @log(double %0)
%47 = tail call double @llvm.fmuladd.f64(double %1, double %46, double %45)
%48 = fsub double %47, %3
%49 = tail call double @exp(double %48)
%50 = fmul double %44, %49
ret double %50
}