#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(double, double);
double sqrt(int);
double factorial(double n) {
  double t, asintotica, aproximacion, suma = 0.0, producto = 1.0, func, funcn;
  unsigned int i;
  t = 50.0 + n;
  asintotica = pow(t, t) * exp(-t) * sqrt(2 * 3.14159265358979323846 * t);
  aproximacion = exp(1.0 / (12.0 * t) - 1.0 / (360.0 * pow(t, 3.0)) +
                     1.0 / (1260 * pow(t, 5.0)) - 1.0 / (1680.0 * pow(t, 7.0)));
  func = asintotica * aproximacion;
  for (i = 1; i <= 50; i++)
    producto *= (n + (double)i);
  funcn = func / producto;
  return (funcn);
}


x86 assembly (clang, -O0):
<factorial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xeb3(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xeee(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1040 <pow@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xe8e(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe5f(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  0xe1a(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe34(%rip),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
movsd  0xe17(%rip),%xmm2
mulsd  %xmm1,%xmm2
movsd  0xde3(%rip),%xmm1
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xde9(%rip),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  0xdcc(%rip),%xmm2
mulsd  %xmm1,%xmm2
movsd  0xda8(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xd9e(%rip),%xmm1
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
movsd  0xd81(%rip),%xmm2
mulsd  %xmm1,%xmm2
movsd  0xd6d(%rip),%xmm1
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x44(%rbp)
cmpl   $0x32,-0x44(%rbp)
ja     12ee <factorial+0x1be>
movsd  -0x8(%rbp),%xmm0
mov    -0x44(%rbp),%eax
cvtsi2sd %rax,%xmm1
addsd  %xmm1,%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    12bb <factorial+0x18b>
movsd  -0x38(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<factorial>:
sub    $0x48,%rsp
movsd  %xmm0,0x28(%rsp)
movsd  0xebe(%rip),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
call   1040 <pow@plt>
movsd  %xmm0,0x40(%rsp)
movaps 0xeee(%rip),%xmm0
xorps  0x10(%rsp),%xmm0
call   1030 <exp@plt>
movsd  %xmm0,0x38(%rsp)
movsd  0xe8e(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0xe79(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe6f(%rip),%xmm2
divsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
movsd  0xe65(%rip),%xmm1
call   1040 <pow@plt>
mulsd  0xe60(%rip),%xmm0
movsd  0xe48(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0xe48(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
call   1040 <pow@plt>
mulsd  0xe3d(%rip),%xmm0
movsd  0xe15(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0xe25(%rip),%xmm1
movapd 0x10(%rsp),%xmm0
call   1040 <pow@plt>
mulsd  0xe1a(%rip),%xmm0
movsd  0xde2(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm0
call   1030 <exp@plt>
movsd  0xddf(%rip),%xmm6
movsd  0xdbf(%rip),%xmm5
movsd  0x28(%rsp),%xmm4
mov    $0x5,%eax
movapd %xmm5,%xmm1
nopl   0x0(%rax,%rax,1)
movapd %xmm5,%xmm2
addsd  %xmm4,%xmm2
mulsd  %xmm1,%xmm2
lea    -0x3(%rax),%ecx
xorps  %xmm1,%xmm1
cvtsi2sd %rcx,%xmm1
addsd  %xmm4,%xmm1
lea    -0x2(%rax),%ecx
xorps  %xmm3,%xmm3
cvtsi2sd %rcx,%xmm3
mulsd  %xmm2,%xmm1
addsd  %xmm4,%xmm3
mulsd  %xmm1,%xmm3
lea    -0x1(%rax),%ecx
xorps  %xmm2,%xmm2
cvtsi2sd %rcx,%xmm2
addsd  %xmm4,%xmm2
mulsd  %xmm3,%xmm2
mov    %eax,%ecx
xorps  %xmm1,%xmm1
cvtsi2sd %rcx,%xmm1
addsd  %xmm4,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm6,%xmm5
add    $0x5,%eax
cmp    $0x37,%eax
jne    1270 <factorial+0x140>
movsd  0x40(%rsp),%xmm2
mulsd  0x38(%rsp),%xmm2
mulsd  0x30(%rsp),%xmm2
mulsd  %xmm0,%xmm2
divsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
define double @factorial(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
store double %0, double* %2
store double 0.000000e+00, double* %6
store double 1.000000e+00, double* %7
%11 = load double, double* %2
%12 = fadd double 5.000000e+01, %11
store double %12, double* %3
%13 = load double, double* %3
%14 = load double, double* %3
%15 = call double @pow(double %13, double %14)
%16 = load double, double* %3
%17 = fneg double %16
%18 = call double @exp(double %17)
%19 = fmul double %15, %18
%20 = load double, double* %3
%21 = fmul double 0x401921FB54442D18, %20
%22 = fptosi double %21 to i32
%23 = call double @sqrt(i32 %22)
%24 = fmul double %19, %23
store double %24, double* %4
%25 = load double, double* %3
%26 = fmul double 1.200000e+01, %25
%27 = fdiv double 1.000000e+00, %26
%28 = load double, double* %3
%29 = call double @pow(double %28, double 3.000000e+00)
%30 = fmul double 3.600000e+02, %29
%31 = fdiv double 1.000000e+00, %30
%32 = fsub double %27, %31
%33 = load double, double* %3
%34 = call double @pow(double %33, double 5.000000e+00)
%35 = fmul double 1.260000e+03, %34
%36 = fdiv double 1.000000e+00, %35
%37 = fadd double %32, %36
%38 = load double, double* %3
%39 = call double @pow(double %38, double 7.000000e+00)
%40 = fmul double 1.680000e+03, %39
%41 = fdiv double 1.000000e+00, %40
%42 = fsub double %37, %41
%43 = call double @exp(double %42)
store double %43, double* %5
%44 = load double, double* %4
%45 = load double, double* %5
%46 = fmul double %44, %45
store double %46, double* %8
store i32 1, i32* %10
br label %47
47: ; preds = %57, %1
%48 = load i32, i32* %10
%49 = icmp ule i32 %48, 50
br i1 %49, label %50, label %60
50: ; preds = %47
%51 = load double, double* %2
%52 = load i32, i32* %10
%53 = uitofp i32 %52 to double
%54 = fadd double %51, %53
%55 = load double, double* %7
%56 = fmul double %55, %54
store double %56, double* %7
br label %57
57: ; preds = %50
%58 = load i32, i32* %10
%59 = add i32 %58, 1
store i32 %59, i32* %10
br label %47
60: ; preds = %47
%61 = load double, double* %8
%62 = load double, double* %7
%63 = fdiv double %61, %62
store double %63, double* %9
%64 = load double, double* %9
ret double %64
}

LLVM IR (-O2):
define double @factorial(double %0) {
%2 = fadd double %0, 5.000000e+01
%3 = tail call double @pow(double %2, double %2)
%4 = fneg double %2
%5 = tail call double @exp(double %4)
%6 = fmul double %2, 0x401921FB54442D18
%7 = fptosi double %6 to i32
%8 = tail call double @sqrt(i32 %7)
%9 = fmul double %2, 1.200000e+01
%10 = fdiv double 1.000000e+00, %9
%11 = tail call double @pow(double %2, double 3.000000e+00)
%12 = fmul double %11, 3.600000e+02
%13 = fdiv double 1.000000e+00, %12
%14 = fsub double %10, %13
%15 = tail call double @pow(double %2, double 5.000000e+00)
%16 = fmul double %15, 1.260000e+03
%17 = fdiv double 1.000000e+00, %16
%18 = fadd double %14, %17
%19 = tail call double @pow(double %2, double 7.000000e+00)
%20 = fmul double %19, 1.680000e+03
%21 = fdiv double 1.000000e+00, %20
%22 = fsub double %18, %21
%23 = tail call double @exp(double %22)
br label %24
24: ; preds = %24, %1
%25 = phi i32 [ 1, %1 ], [ %46, %24 ]
%26 = phi double [ 1.000000e+00, %1 ], [ %45, %24 ]
%27 = uitofp i32 %25 to double
%28 = fadd double %27, %0
%29 = fmul double %26, %28
%30 = add nuw nsw i32 %25, 1
%31 = uitofp i32 %30 to double
%32 = fadd double %31, %0
%33 = fmul double %29, %32
%34 = add nuw nsw i32 %25, 2
%35 = uitofp i32 %34 to double
%36 = fadd double %35, %0
%37 = fmul double %33, %36
%38 = add nuw nsw i32 %25, 3
%39 = uitofp i32 %38 to double
%40 = fadd double %39, %0
%41 = fmul double %37, %40
%42 = add nuw nsw i32 %25, 4
%43 = uitofp i32 %42 to double
%44 = fadd double %43, %0
%45 = fmul double %41, %44
%46 = add nuw nsw i32 %25, 5
%47 = icmp eq i32 %46, 51
br i1 %47, label %48, label %24
48: ; preds = %24
%49 = fmul double %3, %5
%50 = fmul double %49, %8
%51 = fmul double %50, %23
%52 = fdiv double %51, %45
ret double %52
}