#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(double);
double pow(unsigned int, unsigned int);
double sqrt(int);
double st_perm(unsigned int n) {
  if (n == 0)
    return 1;
  return sqrt(2 * 3.1415926) * pow(n, n + 0.5) *
         exp(-(double)n + 1.0 / (12 * n));
}


x86 assembly (clang, -O0):
<st_perm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1157 <st_perm+0x27>
movsd  0xeb3(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e1 <st_perm+0xb1>
mov    $0x6,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%edi
cvtsi2sd %rax,%xmm0
movsd  0xe90(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,%esi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
cvtsi2sd %rax,%xmm0
movaps 0xe66(%rip),%xmm1
pxor   %xmm1,%xmm0
shl    $0x2,%ecx
mov    %ecx,%eax
lea    (%rax,%rax,2),%eax
cvtsi2sd %rax,%xmm2
movsd  0xe3d(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<st_perm>:
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
je     11a5 <st_perm+0x75>
mov    %edi,%ebx
mov    $0x6,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,(%rsp)
mov    %ebx,%eax
cvtsi2sd %rax,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0xea9(%rip),%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rsi
mov    %ebx,%edi
call   1040 <pow@plt>
shl    $0x2,%ebx
lea    (%rbx,%rbx,2),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe71(%rip),%xmm0
divsd  %xmm1,%xmm0
subsd  0x8(%rsp),%xmm0
call   1030 <exp@plt>
mulsd  (%rsp),%xmm0
jmp    11ad <st_perm+0x7d>
movsd  0xe53(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @st_perm(i32 %0) {
%2 = alloca double
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
store double 1.000000e+00, double* %2
br label %26
7: ; preds = %1
%8 = call double @sqrt(i32 6)
%9 = load i32, i32* %3
%10 = load i32, i32* %3
%11 = uitofp i32 %10 to double
%12 = fadd double %11, 5.000000e-01
%13 = fptoui double %12 to i32
%14 = call double @pow(i32 %9, i32 %13)
%15 = fmul double %8, %14
%16 = load i32, i32* %3
%17 = uitofp i32 %16 to double
%18 = fneg double %17
%19 = load i32, i32* %3
%20 = mul i32 12, %19
%21 = uitofp i32 %20 to double
%22 = fdiv double 1.000000e+00, %21
%23 = fadd double %18, %22
%24 = call double @exp(double %23)
%25 = fmul double %15, %24
store double %25, double* %2
br label %26
26: ; preds = %7, %6
%27 = load double, double* %2
ret double %27
}

LLVM IR (-O2):
define double @st_perm(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = tail call double @sqrt(i32 6)
%5 = uitofp i32 %0 to double
%6 = fadd double %5, 5.000000e-01
%7 = fptoui double %6 to i32
%8 = tail call double @pow(i32 %0, i32 %7)
%9 = fmul double %4, %8
%10 = mul i32 %0, 12
%11 = uitofp i32 %10 to double
%12 = fdiv double 1.000000e+00, %11
%13 = fsub double %12, %5
%14 = tail call double @exp(double %13)
%15 = fmul double %9, %14
br label %16
16: ; preds = %1, %3
%17 = phi double [ %15, %3 ], [ 1.000000e+00, %1 ]
ret double %17
}