#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 pow(double, double);
double log_gamma_lanczos(double x) {
  static double q[7] = {75122.6331530, 80916.6278952, 36308.2951477,
                        8687.24529705, 1168.92649479, 83.8676043424,
                        2.50662827511};
  double a = (x + 0.5) * log(x + 5.5) - (x + 5.5);
  double b = 0.0;
  int n;
  for (n = 0; n < 7; n++) {
    a -= log(x + (double)n);
    b += q[n] * pow(x, (double)n);
  }
  return a + log(b);
}


x86 assembly (clang, -O0):
<log_gamma_lanczos>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xed3(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xeb9(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
movsd  0xe9f(%rip),%xmm1
addsd  -0x8(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x7,-0x1c(%rbp)
jge    1213 <log_gamma_lanczos+0xf3>
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
addsd  %xmm1,%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movslq -0x1c(%rbp),%rcx
lea    0x2e6e(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1199 <log_gamma_lanczos+0x79>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
addsd  %xmm1,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_gamma_lanczos>:
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
movsd  0xece(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0xec5(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
call   1030 <log@plt>
mulsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
xorpd  %xmm0,%xmm0
addsd  0x10(%rsp),%xmm0
call   1030 <log@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0xe85(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
call   1030 <log@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0xe6c(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm0
addsd  0xe62(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe5c(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1030 <log@plt>
movsd  0x10(%rsp),%xmm2
movapd %xmm2,%xmm3
mulsd  %xmm2,%xmm3
mulsd  0xe45(%rip),%xmm3
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
addsd  0x8(%rsp),%xmm3
movsd  %xmm3,0x8(%rsp)
movapd %xmm2,%xmm0
addsd  0xe27(%rip),%xmm0
call   1030 <log@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  0xe06(%rip),%xmm1
call   1040 <pow@plt>
mulsd  0xe01(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
addsd  0xdef(%rip),%xmm0
call   1030 <log@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  0xdce(%rip),%xmm1
call   1040 <pow@plt>
mulsd  0xdc9(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
addsd  0xdb7(%rip),%xmm0
call   1030 <log@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  0xd96(%rip),%xmm1
call   1040 <pow@plt>
mulsd  0xd91(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
addsd  0xd7f(%rip),%xmm0
call   1030 <log@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  0xd5e(%rip),%xmm1
call   1040 <pow@plt>
mulsd  0xd59(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
call   1030 <log@plt>
addsd  (%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@log_gamma_lanczos.q = internal global [7 x double] [double 0x40F2572A21650A46, double 0x40F3C14A0BDBD655, double 0x40E1BA8971D996E0, double 0x40C0F79F65E4CBC7, double 0x409243B4BB0CDBDC, double 0x4054F786D45D1E70, double 0x40040D9320069C59]
define double @log_gamma_lanczos(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i32
store double %0, double* %2
%6 = load double, double* %2
%7 = fadd double %6, 5.000000e-01
%8 = load double, double* %2
%9 = fadd double %8, 5.500000e+00
%10 = call double @log(double %9)
%11 = load double, double* %2
%12 = fadd double %11, 5.500000e+00
%13 = fneg double %12
%14 = call double @llvm.fmuladd.f64(double %7, double %10, double %13)
store double %14, double* %3
store double 0.000000e+00, double* %4
store i32 0, i32* %5
br label %15
15: ; preds = %36, %1
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 7
br i1 %17, label %18, label %39
18: ; preds = %15
%19 = load double, double* %2
%20 = load i32, i32* %5
%21 = sitofp i32 %20 to double
%22 = fadd double %19, %21
%23 = call double @log(double %22)
%24 = load double, double* %3
%25 = fsub double %24, %23
store double %25, double* %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [7 x double], [7 x double]* @log_gamma_lanczos.q, i64 0, i64 %27
%29 = load double, double* %28
%30 = load double, double* %2
%31 = load i32, i32* %5
%32 = sitofp i32 %31 to double
%33 = call double @pow(double %30, double %32)
%34 = load double, double* %4
%35 = call double @llvm.fmuladd.f64(double %29, double %33, double %34)
store double %35, double* %4
br label %36
36: ; preds = %18
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %15
39: ; preds = %15
%40 = load double, double* %3
%41 = load double, double* %4
%42 = call double @log(double %41)
%43 = fadd double %40, %42
ret double %43
}

LLVM IR (-O2):
define double @log_gamma_lanczos(double %0) {
%2 = fadd double %0, 5.000000e-01
%3 = fadd double %0, 5.500000e+00
%4 = tail call double @log(double %3)
%5 = fneg double %3
%6 = tail call double @llvm.fmuladd.f64(double %2, double %4, double %5)
%7 = fadd double %0, 0.000000e+00
%8 = tail call double @log(double %7)
%9 = fsub double %6, %8
%10 = fadd double %0, 1.000000e+00
%11 = tail call double @log(double %10)
%12 = fsub double %9, %11
%13 = tail call double @llvm.fmuladd.f64(double %0, double 0x40F3C14A0BDBD655, double 0x40F2572A21650A46)
%14 = fadd double %0, 2.000000e+00
%15 = tail call double @log(double %14)
%16 = fsub double %12, %15
%17 = fmul double %0, %0
%18 = tail call double @llvm.fmuladd.f64(double %17, double 0x40E1BA8971D996E0, double %13)
%19 = fadd double %0, 3.000000e+00
%20 = tail call double @log(double %19)
%21 = fsub double %16, %20
%22 = tail call double @pow(double %0, double 3.000000e+00)
%23 = tail call double @llvm.fmuladd.f64(double %22, double 0x40C0F79F65E4CBC7, double %18)
%24 = fadd double %0, 4.000000e+00
%25 = tail call double @log(double %24)
%26 = fsub double %21, %25
%27 = tail call double @pow(double %0, double 4.000000e+00)
%28 = tail call double @llvm.fmuladd.f64(double %27, double 0x409243B4BB0CDBDC, double %23)
%29 = fadd double %0, 5.000000e+00
%30 = tail call double @log(double %29)
%31 = fsub double %26, %30
%32 = tail call double @pow(double %0, double 5.000000e+00)
%33 = tail call double @llvm.fmuladd.f64(double %32, double 0x4054F786D45D1E70, double %28)
%34 = fadd double %0, 6.000000e+00
%35 = tail call double @log(double %34)
%36 = fsub double %31, %35
%37 = tail call double @pow(double %0, double 6.000000e+00)
%38 = tail call double @llvm.fmuladd.f64(double %37, double 0x40040D9320069C59, double %33)
%39 = tail call double @log(double %38)
%40 = fadd double %36, %39
ret double %40
}