#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 primo(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int i, n, fat_p = 1;
  bool a;
  printf("Informe o número: ");
  scanf("%d", &n);
  for (i = n; i >= 1; i--) {
    a = primo(i);
    if (a == true)
      fat_p = fat_p * i;
  }
  printf("Resultado = %d\n", fat_p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jl     11a6 <main+0x76>
mov    -0x8(%rbp),%edi
call   1050 <primo@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1193 <main+0x63>
mov    -0x10(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1198 <main+0x68>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    116a <main+0x3a>
mov    -0x10(%rbp),%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ebx
mov    $0x1,%ebp
test   %ebx,%ebx
jle    117f <main+0x4f>
nop
mov    %ebx,%edi
call   1050 <primo@plt>
cmp    $0x1,%eax
mov    $0x1,%eax
cmove  %ebx,%eax
imul   %eax,%ebp
lea    -0x1(%rbx),%eax
cmp    $0x1,%ebx
mov    %eax,%ebx
ja     1160 <main+0x30>
lea    0xe91(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Informe o n\C3\BAmero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"Resultado = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 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* %3)
%8 = load i32, i32* %3
store i32 %8, i32* %2
br label %9
9: ; preds = %22, %0
%10 = load i32, i32* %2
%11 = icmp sge i32 %10, 1
br i1 %11, label %12, label %25
12: ; preds = %9
%13 = load i32, i32* %2
%14 = call i32 @primo(i32 %13)
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i32, i32* %4
%19 = load i32, i32* %2
%20 = mul nsw i32 %18, %19
store i32 %20, i32* %4
br label %21
21: ; preds = %17, %12
br label %22
22: ; preds = %21
%23 = load i32, i32* %2
%24 = add nsw i32 %23, -1
store i32 %24, i32* %2
br label %9
25: ; preds = %9
%26 = load i32, i32* %4
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Informe o n\C3\BAmero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"Resultado = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %0, %7
%8 = phi i32 [ %14, %7 ], [ %5, %0 ]
%9 = phi i32 [ %13, %7 ], [ 1, %0 ]
%10 = call i32 @primo(i32 %8)
%11 = icmp eq i32 %10, 1
%12 = select i1 %11, i32 %8, i32 1
%13 = mul nsw i32 %12, %9
%14 = add nsw i32 %8, -1
%15 = icmp ugt i32 %8, 1
br i1 %15, label %7, label %16
16: ; preds = %7, %0
%17 = phi i32 [ 1, %0 ], [ %13, %7 ]
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %17)
ret i32 0
}