#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 factorial(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
main() {
  system("title 34_Cascallar_Autrán_Manuel");
  system("color 1F");
  system("cls");
  printf("FUNCION QUE CALCULA O FACTORIAL DE UN NUMERO\n");
  printf("============================================\n");
  int num;
  printf("Introduce o n\243mero \242 que lle queres calcular o factorial:\n");
  scanf("%d", &num);
  printf("\n");
  printf("O resultado \202:\n");
  printf("%d\n", factorial(num));
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1040 <system@plt>
lea    0xec7(%rip),%rdi
call   1040 <system@plt>
lea    0xec4(%rip),%rdi
call   1040 <system@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xefc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xf29(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xf17(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xf0e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,%esi
lea    0xf06(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xefc(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xe98(%rip),%rdi
call   1060 <system@plt>
lea    0xeae(%rip),%rdi
call   1060 <system@plt>
lea    0xeab(%rip),%rdi
call   1060 <system@plt>
lea    0xeb0(%rip),%rdi
call   1040 <puts@plt>
lea    0xed1(%rip),%rdi
call   1040 <puts@plt>
lea    0xef2(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7f(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xf05(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%edi
call   1050 <factorial@plt>
lea    0xe52(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe46(%rip),%rdi
call   1060 <system@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [34 x i8] c"title 34_Cascallar_Autr\C3\A1n_Manuel\00"
@.str.1 = [9 x i8] c"color 1F\00"
@.str.2 = [4 x i8] c"cls\00"
@.str.3 = [46 x i8] c"FUNCION QUE CALCULA O FACTORIAL DE UN NUMERO\0A\00"
@.str.4 = [46 x i8] c"============================================\0A\00"
@.str.5 = [59 x i8] c"Introduce o n\A3mero \A2 que lle queres calcular o factorial:\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [16 x i8] c"O resultado \82:\0A\00"
@.str.9 = [4 x i8] c"%d\0A\00"
@.str.10 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = call i32 @system(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.5, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%11 = load i32, i32* %1
%12 = call i32 @factorial(i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %12)
%14 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"title 34_Cascallar_Autr\C3\A1n_Manuel\00"
@.str.1 = [9 x i8] c"color 1F\00"
@.str.2 = [4 x i8] c"cls\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.9 = [4 x i8] c"%d\0A\00"
@.str.10 = [6 x i8] c"pause\00"
@str = [45 x i8] c"FUNCION QUE CALCULA O FACTORIAL DE UN NUMERO\00"
@str.11 = [45 x i8] c"============================================\00"
@str.12 = [58 x i8] c"Introduce o n\A3mero \A2 que lle queres calcular o factorial:\00"
@str.13 = [15 x i8] c"O resultado \82:\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @system(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.11, i64 0, i64 0))
%7 = bitcast i32* %1 to i8*
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.12, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%10 = call i32 @putchar(i32 10)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.13, i64 0, i64 0))
%12 = load i32, i32* %1
%13 = call i32 @factorial(i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %13)
%15 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
ret i32 0
}