#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 log_gamma(double x) {
  double z = 1 / (x * x);
  x = x + 6;
  z = (((-0.000595238095238 * z + 0.000793650793651) * z - 0.002777777777778) *
           z +
       0.083333333333333) /
      x;
  z = (x - 0.5) * log(x) - x + 0.918938533204673 + z - log(x - 1) - log(x - 2) -
      log(x - 3) - log(x - 4) - log(x - 5) - log(x - 6);
  return z;
}


x86 assembly (clang, -O0):
<log_gamma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm1
mulsd  -0x8(%rbp),%xmm1
movsd  0xef9(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xec0(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xef9(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xef5(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xed0(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeb3(%rip),%xmm1
addsd  %xmm1,%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe90(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe41(%rip),%xmm1
addsd  %xmm1,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe1e(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xdef(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xdc0(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xd91(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xd62(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xd33(%rip),%xmm1
subsd  %xmm1,%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_gamma>:
sub    $0x18,%rsp
movapd %xmm0,%xmm2
mulsd  %xmm0,%xmm2
movsd  0xedc(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  0xed8(%rip),%xmm0
movsd  0xed8(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xed4(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xed0(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xecc(%rip),%xmm2
movsd  %xmm0,0x8(%rsp)
divsd  %xmm0,%xmm2
movsd  %xmm2,(%rsp)
movsd  0xebd(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
call   1030 <log@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm1,%xmm0
addsd  0xe9e(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe94(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1030 <log@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0xe7d(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
call   1030 <log@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0xe64(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
call   1030 <log@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0xe4b(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
call   1030 <log@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0xe32(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
call   1030 <log@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0xe13(%rip),%xmm0
call   1030 <log@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define double @log_gamma(double %0) {
%2 = fmul double %0, %0
%3 = fdiv double 1.000000e+00, %2
%4 = fadd double %0, 6.000000e+00
%5 = tail call double @llvm.fmuladd.f64(double %3, double 0xBF438138138134A5, double 0x3F4A01A01A01A789)
%6 = tail call double @llvm.fmuladd.f64(double %5, double %3, double 0xBF66C16C16C16E17)
%7 = tail call double @llvm.fmuladd.f64(double %6, double %3, double 0x3FB555555555553D)
%8 = fdiv double %7, %4
%9 = fadd double %4, -5.000000e-01
%10 = tail call double @log(double %4)
%11 = fneg double %4
%12 = tail call double @llvm.fmuladd.f64(double %9, double %10, double %11)
%13 = fadd double %12, 0x3FED67F1C864BEB7
%14 = fadd double %8, %13
%15 = fadd double %4, -1.000000e+00
%16 = tail call double @log(double %15)
%17 = fsub double %14, %16
%18 = fadd double %4, -2.000000e+00
%19 = tail call double @log(double %18)
%20 = fsub double %17, %19
%21 = fadd double %4, -3.000000e+00
%22 = tail call double @log(double %21)
%23 = fsub double %20, %22
%24 = fadd double %4, -4.000000e+00
%25 = tail call double @log(double %24)
%26 = fsub double %23, %25
%27 = fadd double %4, -5.000000e+00
%28 = tail call double @log(double %27)
%29 = fsub double %26, %28
%30 = fadd double %4, -6.000000e+00
%31 = tail call double @log(double %30)
%32 = fsub double %29, %31
ret double %32
}