#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 exp(int);
double pow(int, int);
double sqrt(double);
double stirlingsApproximation2(int n) {
  return (pow(n, n) * exp(-n) * sqrt(2.0 * 3.141592653589793 * n)) *
         (1.0 + (1.0 / (double)(12 * n)));
}


x86 assembly (clang, -O0):
<stirlingsApproximation2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1040 <pow@plt>
movsd  %xmm0,-0x18(%rbp)
xor    %edi,%edi
sub    -0x4(%rbp),%edi
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xe95(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
mulsd  %xmm1,%xmm0
imul   $0xc,-0x4(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xe68(%rip),%xmm2
divsd  %xmm1,%xmm2
movsd  0xe5c(%rip),%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stirlingsApproximation2>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    %edi,%esi
call   1040 <pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
neg    %edi
call   1030 <exp@plt>
movapd %xmm0,%xmm3
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  0xea0(%rip),%xmm0
mulsd  0x8(%rsp),%xmm3
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1176 <stirlingsApproximation2+0x46>
sqrtsd %xmm0,%xmm0
jmp    1187 <stirlingsApproximation2+0x57>
movsd  %xmm3,0x8(%rsp)
call   1050 <sqrt@plt>
movsd  0x8(%rsp),%xmm3
mulsd  %xmm0,%xmm3
shl    $0x2,%ebx
lea    (%rbx,%rbx,2),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0xe68(%rip),%xmm2
movapd %xmm2,%xmm0
divsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm3,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @stirlingsApproximation2(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* %2
%5 = call double @pow(i32 %3, i32 %4)
%6 = load i32, i32* %2
%7 = sub nsw i32 0, %6
%8 = call double @exp(i32 %7)
%9 = fmul double %5, %8
%10 = load i32, i32* %2
%11 = sitofp i32 %10 to double
%12 = fmul double 0x401921FB54442D18, %11
%13 = call double @sqrt(double %12)
%14 = fmul double %9, %13
%15 = load i32, i32* %2
%16 = mul nsw i32 12, %15
%17 = sitofp i32 %16 to double
%18 = fdiv double 1.000000e+00, %17
%19 = fadd double 1.000000e+00, %18
%20 = fmul double %14, %19
ret double %20
}

LLVM IR (-O2):
define double @stirlingsApproximation2(i32 %0) {
%2 = tail call double @pow(i32 %0, i32 %0)
%3 = sub nsw i32 0, %0
%4 = tail call double @exp(i32 %3)
%5 = fmul double %2, %4
%6 = sitofp i32 %0 to double
%7 = fmul double %6, 0x401921FB54442D18
%8 = tail call double @sqrt(double %7)
%9 = fmul double %5, %8
%10 = mul nsw i32 %0, 12
%11 = sitofp i32 %10 to double
%12 = fdiv double 1.000000e+00, %11
%13 = fadd double %12, 1.000000e+00
%14 = fmul double %13, %9
ret double %14
}