#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
main() {
  int N;
  int fat = 1;
  do {
    printf("Insira um numero inteiro: ");
    scanf("%d", &N);
    system("cls");
  } while (N < 0);
  printf("%d! = ", N);
  for (int i = 1; i <= N; i++) {
    fat = fat * i;
  }
  printf("%d", fat);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xeb3(%rip),%rdi
call   1030 <system@plt>
cmpl   $0x0,-0x8(%rbp)
jl     1146 <main+0x16>
mov    -0x8(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11b6 <main+0x86>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1192 <main+0x62>
mov    -0xc(%rbp),%esi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xf61(%rip),%r14
lea    0xf75(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xf6c(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
js     1160 <main+0x30>
lea    0xf36(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    11e1 <main+0xb1>
mov    $0x1,%ecx
mov    $0x1,%esi
cmp    $0x8,%eax
jb     13e0 <main+0x2b0>
mov    %eax,%ecx
and    $0xfffffff8,%ecx
lea    -0x8(%rcx),%edi
mov    %edi,%esi
shr    $0x3,%esi
add    $0x1,%esi
mov    %esi,%edx
and    $0x3,%edx
cmp    $0x18,%edi
jae    11eb <main+0xbb>
movdqa 0xe30(%rip),%xmm1
movdqa 0xe38(%rip),%xmm0
movdqa %xmm1,%xmm4
jmp    1331 <main+0x201>
mov    $0x1,%esi
jmp    13fa <main+0x2ca>
and    $0xfffffffc,%esi
movdqa 0xe0a(%rip),%xmm1
movdqa 0xe12(%rip),%xmm0
movdqa 0xe29(%rip),%xmm9
movdqa 0xe30(%rip),%xmm10
movdqa 0xe37(%rip),%xmm11
movdqa 0xe3e(%rip),%xmm12
movdqa 0xe45(%rip),%xmm13
movdqa 0xe4c(%rip),%xmm14
movdqa 0xe53(%rip),%xmm15
movdqa %xmm1,%xmm4
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm5
paddd  0xdc4(%rip),%xmm5
pshufd $0xf5,%xmm1,%xmm6
pshufd $0xf5,%xmm0,%xmm7
pmuludq %xmm6,%xmm7
pmuludq %xmm0,%xmm1
pshufd $0xf5,%xmm4,%xmm6
pshufd $0xf5,%xmm5,%xmm2
pmuludq %xmm6,%xmm2
pmuludq %xmm4,%xmm5
movdqa %xmm0,%xmm4
paddd  %xmm9,%xmm4
movdqa %xmm0,%xmm6
paddd  %xmm10,%xmm6
pmuludq %xmm4,%xmm1
pshufd $0xf5,%xmm4,%xmm4
pmuludq %xmm7,%xmm4
pmuludq %xmm6,%xmm5
pshufd $0xf5,%xmm6,%xmm6
pmuludq %xmm2,%xmm6
movdqa %xmm0,%xmm2
paddd  %xmm11,%xmm2
movdqa %xmm0,%xmm7
paddd  %xmm12,%xmm7
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm4,%xmm3
pmuludq %xmm1,%xmm2
pshufd $0xf5,%xmm7,%xmm8
pmuludq %xmm6,%xmm8
pmuludq %xmm5,%xmm7
movdqa %xmm0,%xmm4
paddd  %xmm13,%xmm4
movdqa %xmm0,%xmm5
paddd  %xmm14,%xmm5
pmuludq %xmm4,%xmm2
pshufd $0xe8,%xmm2,%xmm1
pshufd $0xf5,%xmm4,%xmm2
pmuludq %xmm3,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm1
pmuludq %xmm5,%xmm7
pshufd $0xe8,%xmm7,%xmm4
pshufd $0xf5,%xmm5,%xmm2
pmuludq %xmm8,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm4
paddd  %xmm15,%xmm0
add    $0xfffffffc,%esi
jne    1250 <main+0x120>
movdqa %xmm1,%xmm5
movdqa %xmm4,%xmm6
test   %edx,%edx
je     13ad <main+0x27d>
movdqa 0xcdb(%rip),%xmm2
movdqa 0xce3(%rip),%xmm3
nopl   (%rax)
movdqa %xmm0,%xmm6
paddd  %xmm2,%xmm6
movdqa %xmm0,%xmm5
pmuludq %xmm1,%xmm5
pshufd $0xe8,%xmm5,%xmm5
pshufd $0xf5,%xmm1,%xmm1
pshufd $0xf5,%xmm0,%xmm7
pmuludq %xmm1,%xmm7
pshufd $0xe8,%xmm7,%xmm1
punpckldq %xmm1,%xmm5
pshufd $0xf5,%xmm6,%xmm1
pmuludq %xmm4,%xmm6
pshufd $0xe8,%xmm6,%xmm6
pshufd $0xf5,%xmm4,%xmm4
pmuludq %xmm1,%xmm4
pshufd $0xe8,%xmm4,%xmm1
punpckldq %xmm1,%xmm6
paddd  %xmm3,%xmm0
movdqa %xmm5,%xmm1
movdqa %xmm6,%xmm4
add    $0xffffffff,%edx
jne    1350 <main+0x220>
pshufd $0xf5,%xmm5,%xmm0
pshufd $0xf5,%xmm6,%xmm1
pmuludq %xmm0,%xmm1
pmuludq %xmm5,%xmm6
pshufd $0xee,%xmm6,%xmm0
pmuludq %xmm6,%xmm0
pshufd $0xaa,%xmm1,%xmm2
pmuludq %xmm1,%xmm2
pmuludq %xmm0,%xmm2
movd   %xmm2,%esi
cmp    %ecx,%eax
je     13fa <main+0x2ca>
or     $0x1,%ecx
add    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
imul   %ecx,%esi
add    $0x1,%ecx
cmp    %ecx,%eax
jne    13f0 <main+0x2c0>
lea    0xcba(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Insira um numero inteiro: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"cls\00"
@.str.3 = [7 x i8] c"%d! = \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %3
br label %5
5: ; preds = %9, %0
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %5
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 0
br i1 %11, label %5, label %12
12: ; preds = %9
%13 = load i32, i32* %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %13)
store i32 1, i32* %4
br label %15
15: ; preds = %23, %12
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %26
19: ; preds = %15
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = mul nsw i32 %20, %21
store i32 %22, i32* %3
br label %23
23: ; preds = %19
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %15
26: ; preds = %15
%27 = load i32, i32* %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str = [27 x i8] c"Insira um numero inteiro: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"cls\00"
@.str.3 = [7 x i8] c"%d! = \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 0
br i1 %8, label %3, label %9
9: ; preds = %3
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 1
br i1 %12, label %75, label %13
13: ; preds = %9
%14 = icmp ult i32 %11, 8
br i1 %14, label %72, label %15
15: ; preds = %13
%16 = and i32 %11, -8
%17 = or i32 %16, 1
%18 = add i32 %16, -8
%19 = lshr exact i32 %18, 3
%20 = add nuw nsw i32 %19, 1
%21 = and i32 %20, 3
%22 = icmp ult i32 %18, 24
br i1 %22, label %48, label %23
23: ; preds = %15
%24 = and i32 %20, 1073741820
br label %25
25: ; preds = %25, %23
%26 = phi <4 x i32> [ <i32 1, i32 2, i32 3, i32 4>, %23 ], [ %45, %25 ]
%27 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %23 ], [ %43, %25 ]
%28 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %23 ], [ %44, %25 ]
%29 = phi i32 [ 0, %23 ], [ %46, %25 ]
%30 = add <4 x i32> %26, <i32 4, i32 4, i32 4, i32 4>
%31 = mul <4 x i32> %26, %27
%32 = mul <4 x i32> %30, %28
%33 = add <4 x i32> %26, <i32 8, i32 8, i32 8, i32 8>
%34 = add <4 x i32> %26, <i32 12, i32 12, i32 12, i32 12>
%35 = mul <4 x i32> %33, %31
%36 = mul <4 x i32> %34, %32
%37 = add <4 x i32> %26, <i32 16, i32 16, i32 16, i32 16>
%38 = add <4 x i32> %26, <i32 20, i32 20, i32 20, i32 20>
%39 = mul <4 x i32> %37, %35
%40 = mul <4 x i32> %38, %36
%41 = add <4 x i32> %26, <i32 24, i32 24, i32 24, i32 24>
%42 = add <4 x i32> %26, <i32 28, i32 28, i32 28, i32 28>
%43 = mul <4 x i32> %41, %39
%44 = mul <4 x i32> %42, %40
%45 = add <4 x i32> %26, <i32 32, i32 32, i32 32, i32 32>
%46 = add i32 %29, 4
%47 = icmp eq i32 %46, %24
br i1 %47, label %48, label %25
48: ; preds = %25, %15
%49 = phi <4 x i32> [ undef, %15 ], [ %43, %25 ]
%50 = phi <4 x i32> [ undef, %15 ], [ %44, %25 ]
%51 = phi <4 x i32> [ <i32 1, i32 2, i32 3, i32 4>, %15 ], [ %45, %25 ]
%52 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %15 ], [ %43, %25 ]
%53 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %15 ], [ %44, %25 ]
%54 = icmp eq i32 %21, 0
br i1 %54, label %66, label %55
55: ; preds = %48, %55
%56 = phi <4 x i32> [ %63, %55 ], [ %51, %48 ]
%57 = phi <4 x i32> [ %61, %55 ], [ %52, %48 ]
%58 = phi <4 x i32> [ %62, %55 ], [ %53, %48 ]
%59 = phi i32 [ %64, %55 ], [ 0, %48 ]
%60 = add <4 x i32> %56, <i32 4, i32 4, i32 4, i32 4>
%61 = mul <4 x i32> %56, %57
%62 = mul <4 x i32> %60, %58
%63 = add <4 x i32> %56, <i32 8, i32 8, i32 8, i32 8>
%64 = add i32 %59, 1
%65 = icmp eq i32 %64, %21
br i1 %65, label %66, label %55
66: ; preds = %55, %48
%67 = phi <4 x i32> [ %49, %48 ], [ %61, %55 ]
%68 = phi <4 x i32> [ %50, %48 ], [ %62, %55 ]
%69 = mul <4 x i32> %68, %67
%70 = call i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> %69)
%71 = icmp eq i32 %11, %16
br i1 %71, label %75, label %72
72: ; preds = %13, %66
%73 = phi i32 [ 1, %13 ], [ %17, %66 ]
%74 = phi i32 [ 1, %13 ], [ %70, %66 ]
br label %78
75: ; preds = %78, %66, %9
%76 = phi i32 [ 1, %9 ], [ %70, %66 ], [ %81, %78 ]
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %76)
ret i32 0
78: ; preds = %72, %78
%79 = phi i32 [ %82, %78 ], [ %73, %72 ]
%80 = phi i32 [ %81, %78 ], [ %74, %72 ]
%81 = mul nsw i32 %79, %80
%82 = add nuw i32 %79, 1
%83 = icmp eq i32 %79, %11
br i1 %83, label %75, label %78
}