#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 main() {
  int termo, base, serie, a, b, c, n;
  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\nVeja "
         "abaixo:\n\n");
  printf("\n\nSerie de Fibonacci:\n\n");
  printf("Termo 0: 1\n");
  printf("Termo 1: 1\n");
  for (termo = 3; termo <= 10; termo++) {
    a = 1;
    b = 1;
    for (base = 2; base < 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    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x3,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jg     11de <main+0xbe>
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11bc <main+0x9c>
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),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118d <main+0x6d>
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116e <main+0x4e>
mov    $0x0,%al
call   1040 <getch@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
lea    0xf51(%rip),%rdi
call   1030 <puts@plt>
lea    0xf5c(%rip),%rdi
call   1030 <puts@plt>
lea    0xf5b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe98(%rip),%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x8,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
mov    $0xd,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x15,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x22,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    $0x37,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getch@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [136 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\0AVeja abaixo:\0A\0A\00"
@.str.1 = [24 x i8] c"\0A\0ASerie de Fibonacci:\0A\0A\00"
@.str.2 = [12 x i8] c"Termo 0: 1\0A\00"
@.str.3 = [12 x i8] c"Termo 1: 1\0A\00"
@.str.4 = [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
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
store i32 3, i32* %2
br label %13
13: ; preds = %34, %0
%14 = load i32, i32* %2
%15 = icmp sle i32 %14, 10
br i1 %15, label %16, label %37
16: ; preds = %13
store i32 1, i32* %5
store i32 1, i32* %6
store i32 2, i32* %3
br label %17
17: ; preds = %27, %16
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %30
21: ; preds = %17
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = add nsw i32 %22, %23
store i32 %24, i32* %7
%25 = load i32, i32* %6
store i32 %25, i32* %5
%26 = load i32, i32* %7
store i32 %26, i32* %6
br label %27
27: ; preds = %21
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %17
30: ; preds = %17
%31 = load i32, i32* %3
%32 = load i32, i32* %7
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %31, i32 %32)
br label %34
34: ; preds = %30
%35 = load i32, i32* %2
%36 = add nsw i32 %35, 1
store i32 %36, i32* %2
br label %13
37: ; preds = %13
%38 = call i32 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
@.str.4 = [14 x i8] c"Termo %d: %d\0A\00"
@str = [135 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\0AVeja abaixo:\0A\00"
@str.5 = [23 x i8] c"\0A\0ASerie de Fibonacci:\0A\00"
@str.6 = [11 x i8] c"Termo 0: 1\00"
@str.7 = [11 x i8] c"Termo 1: 1\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([135 x i8], [135 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.5, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.6, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.7, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 3, i32 2)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 4, i32 3)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 5, i32 5)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 6, i32 8)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 7, i32 13)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 8, i32 21)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 9, i32 34)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 10, i32 55)
%13 = tail call i32 (...) @getch()
ret i32 0
}