#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*/ getch();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int termo, base, serie, a, b, c;
  printf("Uma serie muito famosa na matematica e a serie de FIBONACCI\n\nAqui "
         "vamos te mostrar o n-esimo termo da serie de FIBONACCI\nDigite o "
         "termo que voce quer encontrar:\n\n");
  scanf("%d", &termo);
  printf("\n\nSerie de Fibonacci:\n\n");
  printf("Termo 0: 0\n");
  printf("Termo 1: 1\n");
  a = 0;
  b = 1;
  for (base = 2; (base - 1) < termo; base++) {
    c = a + b;
    a = b;
    b = c;
    printf("Termo %d: %d\n", base, c);
  }
  getch();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf4f(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xf42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cmp    -0x8(%rbp),%eax
jge    11e2 <main+0xb2>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xf09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119c <main+0x6c>
mov    $0x0,%al
call   1050 <getch@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
lea    0xea6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xf48(%rip),%rdi
call   1030 <puts@plt>
lea    0xf53(%rip),%rdi
call   1030 <puts@plt>
lea    0xf52(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x2,0x4(%rsp)
jl     11d1 <main+0x91>
mov    $0x1,%ebx
lea    0xe68(%rip),%r14
mov    $0x1,%eax
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%r15d
add    $0x1,%ebx
add    %eax,%ebp
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
mov    %r15d,%ebp
cmp    0x4(%rsp),%ebx
jl     11b0 <main+0x70>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [163 x i8] c"Uma serie muito famosa na matematica e a serie de FIBONACCI\0A\0AAqui vamos te mostrar o n-esimo termo da serie de FIBONACCI\0ADigite o termo que voce quer encontrar:\0A\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [24 x i8] c"\0A\0ASerie de Fibonacci:\0A\0A\00"
@.str.3 = [12 x i8] c"Termo 0: 0\0A\00"
@.str.4 = [12 x i8] c"Termo 1: 1\0A\00"
@.str.5 = [14 x i8] c"Termo %d: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([163 x i8], [163 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %5
store i32 1, i32* %6
store i32 2, i32* %3
br label %13
13: ; preds = %27, %0
%14 = load i32, i32* %3
%15 = sub nsw i32 %14, 1
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %30
18: ; preds = %13
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = add nsw i32 %19, %20
store i32 %21, i32* %7
%22 = load i32, i32* %6
store i32 %22, i32* %5
%23 = load i32, i32* %7
store i32 %23, i32* %6
%24 = load i32, i32* %3
%25 = load i32, i32* %7
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %24, i32 %25)
br label %27
27: ; preds = %18
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %13
30: ; preds = %13
%31 = call i32 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.5 = [14 x i8] c"Termo %d: %d\0A\00"
@str = [162 x i8] c"Uma serie muito famosa na matematica e a serie de FIBONACCI\0A\0AAqui vamos te mostrar o n-esimo termo da serie de FIBONACCI\0ADigite o termo que voce quer encontrar:\0A\00"
@str.6 = [23 x i8] c"\0A\0ASerie de Fibonacci:\0A\00"
@str.7 = [11 x i8] c"Termo 0: 0\00"
@str.8 = [11 x i8] c"Termo 1: 1\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([162 x i8], [162 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 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.7, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.8, i64 0, i64 0))
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 2
br i1 %9, label %19, label %10
10: ; preds = %0, %10
%11 = phi i32 [ %16, %10 ], [ 2, %0 ]
%12 = phi i32 [ %14, %10 ], [ 1, %0 ]
%13 = phi i32 [ %12, %10 ], [ 0, %0 ]
%14 = add nsw i32 %12, %13
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %11, i32 %14)
%16 = add nuw nsw i32 %11, 1
%17 = load i32, i32* %1
%18 = icmp slt i32 %11, %17
br i1 %18, label %10, label %19
19: ; preds = %10, %0
%20 = call i32 (...) @getch()
ret i32 0
}