#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 */
int EXIT_SUCCESS;
int /*<<< orphan*/ LC_ALL;
float pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
float sqrt(int);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  setlocale(LC_ALL, "Portuguese");
  int n = 0;
  int i = 0;
  int fatorial = 1;
  float stirling = 0;
  printf("Digite um número inteiro: ");
  scanf("%d", &n);
  setbuf(stdin, NULL);
  for (i = 1; i < n; i++) {
    fatorial += fatorial * i;
  }
  printf("%d! = %d\n", n, fatorial);
  stirling = sqrt(2 * 3.1415926535897932384626433832795 * n) *
             pow((n / 2.7182818284590452353602874713527), n);
  printf("%d! ~ %f\n", n, stirling);
  printf("%d! ~ %e\n", n, stirling);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
call   1050 <setlocale@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe7a(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <scanf@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <setbuf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1206 <main+0xa6>
mov    -0x1c(%rbp),%eax
imul   -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11df <main+0x7f>
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xde1(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1080 <sqrt@plt>
movss  %xmm0,-0x24(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xdba(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    -0x14(%rbp),%esi
call   1070 <pow@plt>
movaps %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%esi
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdca(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdba(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2d36(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xe9c(%rip),%rsi
call   1050 <setlocale@plt>
movl   $0x0,0xc(%rsp)
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1030 <setbuf@plt>
mov    0xc(%rsp),%esi
mov    $0x1,%edx
cmp    $0x2,%esi
jl     126f <main+0x10f>
lea    -0x1(%rsi),%r8d
lea    -0x2(%rsi),%ecx
mov    %r8d,%eax
and    $0x7,%eax
cmp    $0x7,%ecx
jae    11eb <main+0x8b>
mov    $0x1,%edx
mov    $0x1,%ecx
test   %eax,%eax
jne    1260 <main+0x100>
jmp    126f <main+0x10f>
and    $0xfffffff8,%r8d
neg    %r8d
mov    $0x1,%edx
mov    $0x8,%ecx
nopl   0x0(%rax)
lea    -0x7(%rcx),%edi
imul   %edx,%edi
add    %edx,%edi
lea    -0x6(%rcx),%edx
imul   %edi,%edx
add    %edi,%edx
lea    -0x5(%rcx),%edi
imul   %edx,%edi
add    %edx,%edi
lea    -0x4(%rcx),%edx
imul   %edi,%edx
add    %edi,%edx
lea    -0x3(%rcx),%edi
imul   %edx,%edi
add    %edx,%edi
lea    -0x2(%rcx),%edx
imul   %edi,%edx
add    %edi,%edx
lea    -0x1(%rcx),%edi
imul   %edx,%edi
add    %edx,%edi
mov    %edi,%edx
imul   %ecx,%edx
add    %edi,%edx
mov    %ecx,%edi
add    $0x8,%ecx
add    %r8d,%edi
add    $0x8,%edi
cmp    $0x8,%edi
jne    1200 <main+0xa0>
add    $0xfffffff9,%ecx
test   %eax,%eax
je     126f <main+0x10f>
cs nopw 0x0(%rax,%rax,1)
mov    %edx,%edi
imul   %ecx,%edi
add    %edi,%edx
add    $0x1,%ecx
add    $0xffffffff,%eax
jne    1260 <main+0x100>
lea    0xdc4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cvtsi2sdl 0xc(%rsp),%xmm0
mulsd  0xd75(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1080 <sqrt@plt>
movss  %xmm0,0x10(%rsp)
mov    0xc(%rsp),%esi
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
divsd  0xd5b(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1070 <pow@plt>
mulss  0x10(%rsp),%xmm0
mov    0xc(%rsp),%esi
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0xd73(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xd6b(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2ce1(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [11 x i8] c"Portuguese\00"
@.str.1 = [28 x i8] c"Digite um n\C3\BAmero inteiro: \00"
@.str.2 = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.3 = [10 x i8] c"%d! = %d\0A\00"
@.str.4 = [10 x i8] c"%d! ~ %f\0A\00"
@.str.5 = [10 x i8] c"%d! ~ %e\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* @LC_ALL
%11 = call i32 @setlocale(i32 %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
store i32 0, i32* %7
store i32 1, i32* %8
store float 0.000000e+00, float* %9
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%14 = load i32, i32* @stdin
%15 = call i32 @setbuf(i32 %14, i32* null)
store i32 1, i32* %7
br label %16
16: ; preds = %26, %2
%17 = load i32, i32* %7
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %29
20: ; preds = %16
%21 = load i32, i32* %8
%22 = load i32, i32* %7
%23 = mul nsw i32 %21, %22
%24 = load i32, i32* %8
%25 = add nsw i32 %24, %23
store i32 %25, i32* %8
br label %26
26: ; preds = %20
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %16
29: ; preds = %16
%30 = load i32, i32* %6
%31 = load i32, i32* %8
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %30, i32 %31)
%33 = load i32, i32* %6
%34 = sitofp i32 %33 to double
%35 = fmul double 0x401921FB54442D18, %34
%36 = fptosi double %35 to i32
%37 = call float @sqrt(i32 %36)
%38 = load i32, i32* %6
%39 = sitofp i32 %38 to double
%40 = fdiv double %39, 0x4005BF0A8B145769
%41 = fptosi double %40 to i32
%42 = load i32, i32* %6
%43 = call float @pow(i32 %41, i32 %42)
%44 = fmul float %37, %43
store float %44, float* %9
%45 = load i32, i32* %6
%46 = load float, float* %9
%47 = fpext float %46 to double
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %45, double %47)
%49 = load i32, i32* %6
%50 = load float, float* %9
%51 = fpext float %50 to double
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %49, double %51)
%53 = load i32, i32* @EXIT_SUCCESS
ret i32 %53
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [11 x i8] c"Portuguese\00"
@.str.1 = [28 x i8] c"Digite um n\C3\BAmero inteiro: \00"
@.str.2 = [3 x i8] c"%d\00"
@stdin = global i32 0
@.str.3 = [10 x i8] c"%d! = %d\0A\00"
@.str.4 = [10 x i8] c"%d! ~ %f\0A\00"
@.str.5 = [10 x i8] c"%d! ~ %e\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = load i32, i32* @LC_ALL
%5 = tail call i32 @setlocale(i32 %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%9 = load i32, i32* @stdin
%10 = call i32 @setbuf(i32 %9, i32* null)
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %64
13: ; preds = %2
%14 = add i32 %11, -1
%15 = add i32 %11, -2
%16 = and i32 %14, 7
%17 = icmp ult i32 %15, 7
br i1 %17, label %50, label %18
18: ; preds = %13
%19 = and i32 %14, -8
br label %20
20: ; preds = %20, %18
%21 = phi i32 [ 1, %18 ], [ %46, %20 ]
%22 = phi i32 [ 1, %18 ], [ %47, %20 ]
%23 = phi i32 [ 0, %18 ], [ %48, %20 ]
%24 = mul nsw i32 %21, %22
%25 = add nsw i32 %24, %21
%26 = add nuw nsw i32 %22, 1
%27 = mul nsw i32 %25, %26
%28 = add nsw i32 %27, %25
%29 = add nuw nsw i32 %22, 2
%30 = mul nsw i32 %28, %29
%31 = add nsw i32 %30, %28
%32 = add nuw nsw i32 %22, 3
%33 = mul nsw i32 %31, %32
%34 = add nsw i32 %33, %31
%35 = add nuw nsw i32 %22, 4
%36 = mul nsw i32 %34, %35
%37 = add nsw i32 %36, %34
%38 = add nuw nsw i32 %22, 5
%39 = mul nsw i32 %37, %38
%40 = add nsw i32 %39, %37
%41 = add nuw nsw i32 %22, 6
%42 = mul nsw i32 %40, %41
%43 = add nsw i32 %42, %40
%44 = add nuw nsw i32 %22, 7
%45 = mul nsw i32 %43, %44
%46 = add nsw i32 %45, %43
%47 = add nuw nsw i32 %22, 8
%48 = add i32 %23, 8
%49 = icmp eq i32 %48, %19
br i1 %49, label %50, label %20
50: ; preds = %20, %13
%51 = phi i32 [ undef, %13 ], [ %46, %20 ]
%52 = phi i32 [ 1, %13 ], [ %46, %20 ]
%53 = phi i32 [ 1, %13 ], [ %47, %20 ]
%54 = icmp eq i32 %16, 0
br i1 %54, label %64, label %55
55: ; preds = %50, %55
%56 = phi i32 [ %60, %55 ], [ %52, %50 ]
%57 = phi i32 [ %61, %55 ], [ %53, %50 ]
%58 = phi i32 [ %62, %55 ], [ 0, %50 ]
%59 = mul nsw i32 %56, %57
%60 = add nsw i32 %59, %56
%61 = add nuw nsw i32 %57, 1
%62 = add i32 %58, 1
%63 = icmp eq i32 %62, %16
br i1 %63, label %64, label %55
64: ; preds = %50, %55, %2
%65 = phi i32 [ 1, %2 ], [ %51, %50 ], [ %60, %55 ]
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %11, i32 %65)
%67 = load i32, i32* %3
%68 = sitofp i32 %67 to double
%69 = fmul double %68, 0x401921FB54442D18
%70 = fptosi double %69 to i32
%71 = call float @sqrt(i32 %70)
%72 = load i32, i32* %3
%73 = sitofp i32 %72 to double
%74 = fdiv double %73, 0x4005BF0A8B145769
%75 = fptosi double %74 to i32
%76 = call float @pow(i32 %75, i32 %72)
%77 = fmul float %71, %76
%78 = load i32, i32* %3
%79 = fpext float %77 to double
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %78, double %79)
%81 = load i32, i32* %3
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %81, double %79)
%83 = load i32, i32* @EXIT_SUCCESS
ret i32 %83
}