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


x86 assembly (clang, -O0):
<LnGammaFunction>:
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    11cd <LnGammaFunction+0xbd>
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 <LnGammaFunction+0x8d>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1165 <LnGammaFunction+0x55>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <log@plt>
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  0xe29(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe39(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <log@plt>
movsd  -0x30(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xdfc(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xddb(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdd7(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdb2(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd95(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  -0x10(%rbp),%xmm1
addsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LnGammaFunction>:
sub    $0x38,%rsp
movapd %xmm0,%xmm3
movsd  0xee0(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1179 <LnGammaFunction+0x69>
addsd  0xeda(%rip),%xmm3
movsd  0xeda(%rip),%xmm0
addsd  %xmm0,%xmm3
ucomisd %xmm3,%xmm1
jbe    115e <LnGammaFunction+0x4e>
movsd  0xec8(%rip),%xmm2
movapd %xmm2,%xmm0
nopl   0x0(%rax)
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm3
ucomisd %xmm3,%xmm1
ja     1150 <LnGammaFunction+0x40>
movsd  %xmm3,0x8(%rsp)
call   1030 <log@plt>
movsd  0x8(%rsp),%xmm3
xorpd  0xed9(%rip),%xmm0
jmp    117d <LnGammaFunction+0x6d>
xorpd  %xmm0,%xmm0
movapd %xmm0,0x20(%rsp)
movsd  %xmm3,0x8(%rsp)
movapd %xmm3,%xmm0
mulsd  %xmm3,%xmm0
movsd  0xe77(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0xe6d(%rip),%xmm0
addsd  %xmm3,%xmm0
movsd  %xmm0,0x10(%rsp)
movapd %xmm3,%xmm0
call   1030 <log@plt>
mulsd  0x10(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  0x8(%rsp),%xmm3
subsd  %xmm3,%xmm0
addsd  0xe44(%rip),%xmm0
movsd  0xe44(%rip),%xmm1
movsd  0x18(%rsp),%xmm2
mulsd  %xmm2,%xmm1
addsd  0xe3a(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xe36(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xe32(%rip),%xmm1
divsd  %xmm3,%xmm1
addsd  %xmm1,%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
define double @LnGammaFunction(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 %25
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 double @log(double %22)
%24 = fneg double %23
store double %24, double* %4
br label %25
25: ; preds = %20, %1
%26 = load double, double* %3
%27 = load double, double* %3
%28 = fmul double %26, %27
%29 = fdiv double 1.000000e+00, %28
store double %29, double* %5
%30 = load double, double* %4
%31 = load double, double* %3
%32 = fsub double %31, 5.000000e-01
%33 = load double, double* %3
%34 = call double @log(double %33)
%35 = call double @llvm.fmuladd.f64(double %32, double %34, double %30)
%36 = load double, double* %3
%37 = fsub double %35, %36
%38 = fadd double %37, 0x3FED67F1C864BEB7
%39 = load double, double* %5
%40 = call double @llvm.fmuladd.f64(double 0xBF438138138134A5, double %39, double 0x3F4A01A01A01A789)
%41 = load double, double* %5
%42 = call double @llvm.fmuladd.f64(double %40, double %41, double 0xBF66C16C16C16E17)
%43 = load double, double* %5
%44 = call double @llvm.fmuladd.f64(double %42, double %43, double 0x3FB555555555553D)
%45 = load double, double* %3
%46 = fdiv double %44, %45
%47 = fadd double %38, %46
ret double %47
}

LLVM IR (-O2):
define double @LnGammaFunction(double %0) {
%2 = fcmp olt double %0, 7.000000e+00
br i1 %2, label %3, label %18
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 double @log(double %14)
%17 = fneg double %16
br label %18
18: ; preds = %13, %1
%19 = phi double [ %15, %13 ], [ %0, %1 ]
%20 = phi double [ %17, %13 ], [ 0.000000e+00, %1 ]
%21 = fmul double %19, %19
%22 = fdiv double 1.000000e+00, %21
%23 = fadd double %19, -5.000000e-01
%24 = tail call double @log(double %19)
%25 = tail call double @llvm.fmuladd.f64(double %23, double %24, double %20)
%26 = fsub double %25, %19
%27 = fadd double %26, 0x3FED67F1C864BEB7
%28 = tail call double @llvm.fmuladd.f64(double %22, double 0xBF438138138134A5, double 0x3F4A01A01A01A789)
%29 = tail call double @llvm.fmuladd.f64(double %28, double %22, double 0xBF66C16C16C16E17)
%30 = tail call double @llvm.fmuladd.f64(double %29, double %22, double 0x3FB555555555553D)
%31 = fdiv double %30, %19
%32 = fadd double %27, %31
ret double %32
}