#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 alnfac(int j) {
  static double r[7] = {0.0,           0.0,           0.69314718056,
                        1.79175946923, 3.17805383035, 4.78749174278,
                        6.57925121101};
  double w, z;
  if (j == 1)
    return (double)1.0;
  else if (j <= 7)
    return r[j];
  w = (double)j + 1;
  z = 1.0 / (w * w);
  return (w - 0.5) * log(w) - w + 0.918938522305 +
         (((4.0 - 3.0 * z) * z - 14.0) * z + 420.0) / (5040.0 * w);
}


x86 assembly (clang, -O0):
<alnfac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1137 <alnfac+0x27>
movsd  0xf0b(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    124a <alnfac+0x13a>
cmpl   $0x7,-0xc(%rbp)
jg     115b <alnfac+0x4b>
movslq -0xc(%rbp),%rcx
lea    0x2ee4(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    124a <alnfac+0x13a>
jmp    1160 <alnfac+0x50>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  0xecb(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
movsd  0xeb0(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe92(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x28(%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  0xe43(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  0xe22(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe1e(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdf9(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xddc(%rip),%xmm2
addsd  %xmm2,%xmm1
movsd  0xdc8(%rip),%xmm2
mulsd  -0x18(%rbp),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alnfac>:
sub    $0x18,%rsp
cmp    $0x1,%edi
jne    1126 <alnfac+0x16>
movsd  0xedf(%rip),%xmm0
add    $0x18,%rsp
ret
cmp    $0x7,%edi
jg     113f <alnfac+0x2f>
movslq %edi,%rax
lea    0xf0b(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
add    $0x18,%rsp
ret
cvtsi2sd %edi,%xmm0
movsd  0xeb5(%rip),%xmm2
addsd  %xmm2,%xmm0
movsd  %xmm0,(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
divsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rsp)
movsd  0xe9a(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
call   1030 <log@plt>
movapd %xmm0,%xmm1
mulsd  0x8(%rsp),%xmm1
movsd  (%rsp),%xmm3
subsd  %xmm3,%xmm1
addsd  0xe78(%rip),%xmm1
movsd  0xe78(%rip),%xmm0
movsd  0x10(%rsp),%xmm2
mulsd  %xmm2,%xmm0
addsd  0xe6e(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xe6a(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xe66(%rip),%xmm0
movapd %xmm3,%xmm2
mulsd  0xe62(%rip),%xmm2
divsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@alnfac.r = internal global [7 x double] [double 0.000000e+00, double 0.000000e+00, double 0x3FE62E42FEFA3BDC, double 0x3FFCAB0BFA2A423A, double 0x40096CA77C923F0B, double 0x401326643C4470CA, double 0x401A51273ABDD34C]
define double @alnfac(i32 %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca double
%5 = alloca double
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %9
8: ; preds = %1
store double 1.000000e+00, double* %2
br label %44
9: ; preds = %1
%10 = load i32, i32* %3
%11 = icmp sle i32 %10, 7
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [7 x double], [7 x double]* @alnfac.r, i64 0, i64 %14
%16 = load double, double* %15
store double %16, double* %2
br label %44
17: ; preds = %9
br label %18
18: ; preds = %17
%19 = load i32, i32* %3
%20 = sitofp i32 %19 to double
%21 = fadd double %20, 1.000000e+00
store double %21, double* %4
%22 = load double, double* %4
%23 = load double, double* %4
%24 = fmul double %22, %23
%25 = fdiv double 1.000000e+00, %24
store double %25, double* %5
%26 = load double, double* %4
%27 = fsub double %26, 5.000000e-01
%28 = load double, double* %4
%29 = call double @log(double %28)
%30 = load double, double* %4
%31 = fneg double %30
%32 = call double @llvm.fmuladd.f64(double %27, double %29, double %31)
%33 = fadd double %32, 0x3FED67F1C28AB490
%34 = load double, double* %5
%35 = call double @llvm.fmuladd.f64(double -3.000000e+00, double %34, double 4.000000e+00)
%36 = load double, double* %5
%37 = call double @llvm.fmuladd.f64(double %35, double %36, double -1.400000e+01)
%38 = load double, double* %5
%39 = call double @llvm.fmuladd.f64(double %37, double %38, double 4.200000e+02)
%40 = load double, double* %4
%41 = fmul double 5.040000e+03, %40
%42 = fdiv double %39, %41
%43 = fadd double %33, %42
store double %43, double* %2
br label %44
44: ; preds = %18, %12, %8
%45 = load double, double* %2
ret double %45
}

LLVM IR (-O2):
@alnfac.r = internal unnamed_addr constant [7 x double] [double 0.000000e+00, double 0.000000e+00, double 0x3FE62E42FEFA3BDC, double 0x3FFCAB0BFA2A423A, double 0x40096CA77C923F0B, double 0x401326643C4470CA, double 0x401A51273ABDD34C]
define double @alnfac(i32 %0) {
%2 = icmp eq i32 %0, 1
br i1 %2, label %25, label %3
3: ; preds = %1
%4 = icmp slt i32 %0, 8
br i1 %4, label %5, label %9
5: ; preds = %3
%6 = sext i32 %0 to i64
%7 = getelementptr inbounds [7 x double], [7 x double]* @alnfac.r, i64 0, i64 %6
%8 = load double, double* %7
br label %25
9: ; preds = %3
%10 = sitofp i32 %0 to double
%11 = fadd double %10, 1.000000e+00
%12 = fmul double %11, %11
%13 = fdiv double 1.000000e+00, %12
%14 = fadd double %11, -5.000000e-01
%15 = tail call double @log(double %11)
%16 = fneg double %11
%17 = tail call double @llvm.fmuladd.f64(double %14, double %15, double %16)
%18 = fadd double %17, 0x3FED67F1C28AB490
%19 = tail call double @llvm.fmuladd.f64(double %13, double -3.000000e+00, double 4.000000e+00)
%20 = tail call double @llvm.fmuladd.f64(double %19, double %13, double -1.400000e+01)
%21 = tail call double @llvm.fmuladd.f64(double %20, double %13, double 4.200000e+02)
%22 = fmul double %11, 5.040000e+03
%23 = fdiv double %21, %22
%24 = fadd double %23, %18
br label %25
25: ; preds = %1, %9, %5
%26 = phi double [ %8, %5 ], [ %24, %9 ], [ 1.000000e+00, %1 ]
ret double %26
}