#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 */
scalar_t__ log(double);
double LnGamma(double alpha) {
  double x = alpha, f = 0, z;
  if (x < 7) {
    f = 1;
    z = x - 1;
    while (++z < 7)
      f *= z;
    x = z;
    f = -(double)log(f);
  }
  z = 1 / (x * x);
  return f + (x - 0.5) * (double)log(x) - x + .918938533204673 +
         (((-.000595238095238 * z + .000793650793651) * z - .002777777777778) *
              z +
          .083333333333333) /
             x;
}


x86 assembly (clang, -O0):
<LnGamma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xec9(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11d2 <LnGamma+0xc2>
movsd  0xebe(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xeac(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe9b(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
movsd  %xmm1,-0x20(%rbp)
movsd  0xe81(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    119d <LnGamma+0x8d>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1165 <LnGamma+0x55>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <log@plt>
cvtsi2sd %rax,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xe24(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe34(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <log@plt>
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
cvtsi2sd %rax,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xdf5(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xdd4(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdd0(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdab(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd8e(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  -0x10(%rbp),%xmm1
addsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LnGamma>:
sub    $0x38,%rsp
movapd %xmm0,%xmm3
movsd  0xee0(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1181 <LnGamma+0x71>
addsd  0xeda(%rip),%xmm3
movsd  0xeda(%rip),%xmm0
addsd  %xmm0,%xmm3
ucomisd %xmm3,%xmm1
jbe    115e <LnGamma+0x4e>
movsd  0xec8(%rip),%xmm2
movapd %xmm2,%xmm0
nopl   0x0(%rax)
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm3
ucomisd %xmm3,%xmm1
ja     1150 <LnGamma+0x40>
movsd  %xmm3,0x8(%rsp)
call   1030 <log@plt>
movsd  0x8(%rsp),%xmm3
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
xorpd  0xed1(%rip),%xmm0
jmp    1185 <LnGamma+0x75>
xorpd  %xmm0,%xmm0
movapd %xmm0,0x20(%rsp)
movsd  %xmm3,0x8(%rsp)
movapd %xmm3,%xmm0
mulsd  %xmm3,%xmm0
movsd  0xe6f(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0xe65(%rip),%xmm0
addsd  %xmm3,%xmm0
movsd  %xmm0,0x10(%rsp)
movapd %xmm3,%xmm0
call   1030 <log@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  0x20(%rsp),%xmm1
movsd  0x8(%rsp),%xmm3
subsd  %xmm3,%xmm1
addsd  0xe34(%rip),%xmm1
movsd  0xe34(%rip),%xmm0
movsd  0x18(%rsp),%xmm2
mulsd  %xmm2,%xmm0
addsd  0xe2a(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xe26(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xe22(%rip),%xmm0
divsd  %xmm3,%xmm0
addsd  %xmm1,%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define double @LnGamma(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %2
%6 = load double, double* %2
store double %6, double* %3
store double 0.000000e+00, double* %4
%7 = load double, double* %3
%8 = fcmp olt double %7, 7.000000e+00
br i1 %8, label %9, label %26
9: ; preds = %1
store double 1.000000e+00, double* %4
%10 = load double, double* %3
%11 = fsub double %10, 1.000000e+00
store double %11, double* %5
br label %12
12: ; preds = %16, %9
%13 = load double, double* %5
%14 = fadd double %13, 1.000000e+00
store double %14, double* %5
%15 = fcmp olt double %14, 7.000000e+00
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load double, double* %5
%18 = load double, double* %4
%19 = fmul double %18, %17
store double %19, double* %4
br label %12
20: ; preds = %12
%21 = load double, double* %5
store double %21, double* %3
%22 = load double, double* %4
%23 = call i64 @log(double %22)
%24 = sitofp i64 %23 to double
%25 = fneg double %24
store double %25, double* %4
br label %26
26: ; preds = %20, %1
%27 = load double, double* %3
%28 = load double, double* %3
%29 = fmul double %27, %28
%30 = fdiv double 1.000000e+00, %29
store double %30, double* %5
%31 = load double, double* %4
%32 = load double, double* %3
%33 = fsub double %32, 5.000000e-01
%34 = load double, double* %3
%35 = call i64 @log(double %34)
%36 = sitofp i64 %35 to double
%37 = call double @llvm.fmuladd.f64(double %33, double %36, double %31)
%38 = load double, double* %3
%39 = fsub double %37, %38
%40 = fadd double %39, 0x3FED67F1C864BEB7
%41 = load double, double* %5
%42 = call double @llvm.fmuladd.f64(double 0xBF438138138134A5, double %41, double 0x3F4A01A01A01A789)
%43 = load double, double* %5
%44 = call double @llvm.fmuladd.f64(double %42, double %43, double 0xBF66C16C16C16E17)
%45 = load double, double* %5
%46 = call double @llvm.fmuladd.f64(double %44, double %45, double 0x3FB555555555553D)
%47 = load double, double* %3
%48 = fdiv double %46, %47
%49 = fadd double %40, %48
ret double %49
}

LLVM IR (-O2):
define double @LnGamma(double %0) {
%2 = fcmp olt double %0, 7.000000e+00
br i1 %2, label %3, label %19
3: ; preds = %1
%4 = fadd double %0, -1.000000e+00
%5 = fadd double %4, 1.000000e+00
%6 = fcmp olt double %5, 7.000000e+00
br i1 %6, label %7, label %13
7: ; preds = %3, %7
%8 = phi double [ %11, %7 ], [ %5, %3 ]
%9 = phi double [ %10, %7 ], [ 1.000000e+00, %3 ]
%10 = fmul double %9, %8
%11 = fadd double %8, 1.000000e+00
%12 = fcmp olt double %11, 7.000000e+00
br i1 %12, label %7, label %13
13: ; preds = %7, %3
%14 = phi double [ 1.000000e+00, %3 ], [ %10, %7 ]
%15 = phi double [ %5, %3 ], [ %11, %7 ]
%16 = tail call i64 @log(double %14)
%17 = sitofp i64 %16 to double
%18 = fneg double %17
br label %19
19: ; preds = %13, %1
%20 = phi double [ %15, %13 ], [ %0, %1 ]
%21 = phi double [ %18, %13 ], [ 0.000000e+00, %1 ]
%22 = fmul double %20, %20
%23 = fdiv double 1.000000e+00, %22
%24 = fadd double %20, -5.000000e-01
%25 = tail call i64 @log(double %20)
%26 = sitofp i64 %25 to double
%27 = tail call double @llvm.fmuladd.f64(double %24, double %26, double %21)
%28 = fsub double %27, %20
%29 = fadd double %28, 0x3FED67F1C864BEB7
%30 = tail call double @llvm.fmuladd.f64(double %23, double 0xBF438138138134A5, double 0x3F4A01A01A01A789)
%31 = tail call double @llvm.fmuladd.f64(double %30, double %23, double 0xBF66C16C16C16E17)
%32 = tail call double @llvm.fmuladd.f64(double %31, double %23, double 0x3FB555555555553D)
%33 = fdiv double %32, %20
%34 = fadd double %29, %33
ret double %34
}