#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 fatorial(int);
int fibonacci(int);
int /*<<< orphan*/ hanoi(int, int, int, int, int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int jogada;
  int i;
  printf("Chamadas na função fatorial(4):\n");
  i = fatorial(4);
  printf("Fim da chamada: %d\n", i);
  printf("\n\n\nTeste com fibonacci(5):\n");
  i = fibonacci(5);
  printf("Fim da chamada: %d\n", i);
  printf("\n\n\nProblema das Torres de Hanoi para N=3:\n");
  jogada = 0;
  hanoi(1, 2, 3, 3, &jogada);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x4,%edi
call   1050 <fatorial@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x5,%edi
call   1040 <fibonacci@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    $0x1,%edi
mov    $0x2,%esi
mov    $0x3,%ecx
lea    -0x8(%rbp),%r8
mov    %ecx,%edx
call   1060 <hanoi@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x4,%edi
call   1060 <fatorial@plt>
lea    0xe8e(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
mov    $0x5,%edi
call   1050 <fibonacci@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%r8
mov    $0x1,%edi
mov    $0x2,%esi
mov    $0x3,%edx
mov    $0x3,%ecx
call   1070 <hanoi@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Chamadas na fun\C3\A7\C3\A3o fatorial(4):\0A\00"
@.str.1 = [20 x i8] c"Fim da chamada: %d\0A\00"
@.str.2 = [28 x i8] c"\0A\0A\0ATeste com fibonacci(5):\0A\00"
@.str.3 = [43 x i8] c"\0A\0A\0AProblema das Torres de Hanoi para N=3:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @fatorial(i32 4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @fibonacci(i32 5)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %2
%13 = call i32 @hanoi(i32 1, i32 2, i32 3, i32 3, i32* %2)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [20 x i8] c"Fim da chamada: %d\0A\00"
@str = [34 x i8] c"Chamadas na fun\C3\A7\C3\A3o fatorial(4):\00"
@str.4 = [27 x i8] c"\0A\0A\0ATeste com fibonacci(5):\00"
@str.5 = [42 x i8] c"\0A\0A\0AProblema das Torres de Hanoi para N=3:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @fatorial(i32 4)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.4, i64 0, i64 0))
%7 = tail call i32 @fibonacci(i32 5)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.5, i64 0, i64 0))
store i32 0, i32* %1
%10 = call i32 @hanoi(i32 1, i32 2, i32 3, i32 3, i32* %1)
ret i32 0
}