#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*/ fflush(int /*<<< orphan*/);
int fibonacci(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int main() {
  int resultado, numero;
  printf("\n Calculo de Fibonacci");
  printf("\n ====================\n");
  printf("\n Entre com o numero: ");
  fflush(stdin);
  scanf("%d", &numero);
  resultado = fibonacci(numero);
  if (resultado < 0) {
    printf("\n Nao existe F(%d)\n", numero);
  } else {
    printf("\n F(%d) = %d\n", numero, resultado);
  }
  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>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
lea    0xeb8(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0xc(%rbp),%edi
call   1050 <fibonacci@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11c2 <main+0x82>
mov    -0xc(%rbp),%esi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d6 <main+0x96>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
lea    0xea0(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%edi
call   1060 <fibonacci@plt>
mov    0x4(%rsp),%esi
test   %eax,%eax
js     11bb <main+0x6b>
lea    0xe95(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c9 <main+0x79>
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\0A Calculo de Fibonacci\00"
@.str.1 = [24 x i8] c"\0A ====================\0A\00"
@.str.2 = [23 x i8] c"\0A Entre com o numero: \00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [20 x i8] c"\0A Nao existe F(%d)\0A\00"
@.str.5 = [14 x i8] c"\0A F(%d) = %d\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 ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fflush(i32 %7)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = call i32 @fibonacci(i32 %10)
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = load i32, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %15)
br label %21
17: ; preds = %0
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %18, i32 %19)
br label %21
21: ; preds = %17, %14
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"\0A Calculo de Fibonacci\00"
@.str.2 = [23 x i8] c"\0A Entre com o numero: \00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [20 x i8] c"\0A Nao existe F(%d)\0A\00"
@.str.5 = [14 x i8] c"\0A F(%d) = %d\0A\00"
@str = [23 x i8] c"\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 ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = tail call i32 @fflush(i32 %6)
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = call i32 @fibonacci(i32 %9)
%11 = icmp slt i32 %10, 0
%12 = load i32, i32* %1
br i1 %11, label %13, label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %12)
br label %17
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %12, i32 %10)
br label %17
17: ; preds = %15, %13
ret i32 0
}