#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 log10(double);
double approx_log_gamma(double N) {
  const double LOGPIHALF = 0.24857493634706692717563414414545;
  double D;
  D = 1.0 + (2.0 * N);
  D *= 4.0 * N;
  D += 1.0;
  D *= N;
  D = log10(D) * (1.0 / 6.0);
  D += N + (LOGPIHALF);
  D = (N * log(N)) - D;
  return D;
}


x86 assembly (clang, -O0):
<approx_log_gamma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xecb(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xec5(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xebc(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe9d(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <log10@plt>
movsd  0xe6a(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe51(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<approx_log_gamma>:
sub    $0x18,%rsp
movapd %xmm0,%xmm3
movsd  %xmm0,0x8(%rsp)
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0xec2(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  0xebe(%rip),%xmm0
mulsd  %xmm3,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm3,%xmm0
call   1040 <log10@plt>
mulsd  0xea9(%rip),%xmm0
movsd  0xea9(%rip),%xmm2
movsd  0x8(%rsp),%xmm1
addsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,0x10(%rsp)
movapd %xmm1,%xmm0
call   1030 <log@plt>
mulsd  0x8(%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @approx_log_gamma(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %2
store double 0x3FCFD14DB31BA3BB, double* %3
%5 = load double, double* %2
%6 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %5, double 1.000000e+00)
store double %6, double* %4
%7 = load double, double* %2
%8 = fmul double 4.000000e+00, %7
%9 = load double, double* %4
%10 = fmul double %9, %8
store double %10, double* %4
%11 = load double, double* %4
%12 = fadd double %11, 1.000000e+00
store double %12, double* %4
%13 = load double, double* %2
%14 = load double, double* %4
%15 = fmul double %14, %13
store double %15, double* %4
%16 = load double, double* %4
%17 = call double @log10(double %16)
%18 = fmul double %17, 0x3FC5555555555555
store double %18, double* %4
%19 = load double, double* %2
%20 = fadd double %19, 0x3FCFD14DB31BA3BB
%21 = load double, double* %4
%22 = fadd double %21, %20
store double %22, double* %4
%23 = load double, double* %2
%24 = load double, double* %2
%25 = call double @log(double %24)
%26 = load double, double* %4
%27 = fneg double %26
%28 = call double @llvm.fmuladd.f64(double %23, double %25, double %27)
store double %28, double* %4
%29 = load double, double* %4
ret double %29
}

LLVM IR (-O2):
define double @approx_log_gamma(double %0) {
%2 = tail call double @llvm.fmuladd.f64(double %0, double 2.000000e+00, double 1.000000e+00)
%3 = fmul double %0, 4.000000e+00
%4 = fmul double %2, %3
%5 = fadd double %4, 1.000000e+00
%6 = fmul double %5, %0
%7 = tail call double @log10(double %6)
%8 = fmul double %7, 0x3FC5555555555555
%9 = fadd double %0, 0x3FCFD14DB31BA3BB
%10 = fadd double %9, %8
%11 = tail call double @log(double %0)
%12 = fneg double %10
%13 = tail call double @llvm.fmuladd.f64(double %0, double %11, double %12)
ret double %13
}