#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, serie, base, c, b, a;
  printf("Uma serie muito famosa na matematica e a serie de FIBONACCI\n\nAqui "
         "vamos te mostrar o n-esimo termo da serie de FETUCCINE\nQue ao "
         "contrario de somar igual a FIBONACCI, ela subtrai nos termos "
         "pares\nDigite o termo que voce quer encontrar:\n\n");
  scanf("%d", &termo);
  printf("\n\nSerie de Fetuccine [Fibonacci]:\n\n");
  printf("Termo 1: 1\n");
  printf("Termo 2: 1\n");
  a = 1;
  b = 1;
  for (base = 3; base <= termo; base++) {
    if (base % 2 == 0) {
      c = b - a;
      a = b;
      b = c;
    } else {
      c = b + a;
      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    0xf99(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xf8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfa2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfa0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x3,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     120d <main+0xdd>
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d6 <main+0xa6>
mov    -0x18(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11eb <main+0xbb>
mov    -0x18(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xf34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%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    0xf92(%rip),%rdi
call   1030 <puts@plt>
lea    0xfa9(%rip),%rdi
call   1030 <puts@plt>
lea    0xfa8(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x3,0x4(%rsp)
jl     11da <main+0x9a>
mov    $0x1,%eax
mov    $0x2,%ebx
lea    0xe63(%rip),%r14
mov    $0x1,%r15d
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebx
mov    %eax,%ebp
neg    %ebp
test   $0x1,%bl
cmovne %eax,%ebp
add    %r15d,%ebp
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15d,%eax
mov    %ebp,%r15d
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 = [237 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 FETUCCINE\0AQue ao contrario de somar igual a FIBONACCI, ela subtrai nos termos pares\0ADigite o termo que voce quer encontrar:\0A\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"\0A\0ASerie de Fetuccine [Fibonacci]:\0A\0A\00"
@.str.3 = [12 x i8] c"Termo 1: 1\0A\00"
@.str.4 = [12 x i8] c"Termo 2: 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 ([237 x i8], [237 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 ([36 x i8], [36 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 1, i32* %7
store i32 1, i32* %6
store i32 3, i32* %4
br label %13
13: ; preds = %37, %0
%14 = load i32, i32* %4
%15 = load i32, i32* %2
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %40
17: ; preds = %13
%18 = load i32, i32* %4
%19 = srem i32 %18, 2
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = sub nsw i32 %22, %23
store i32 %24, i32* %5
%25 = load i32, i32* %6
store i32 %25, i32* %7
%26 = load i32, i32* %5
store i32 %26, i32* %6
br label %33
27: ; preds = %17
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = add nsw i32 %28, %29
store i32 %30, i32* %5
%31 = load i32, i32* %6
store i32 %31, i32* %7
%32 = load i32, i32* %5
store i32 %32, i32* %6
br label %33
33: ; preds = %27, %21
%34 = load i32, i32* %4
%35 = load i32, i32* %5
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %34, i32 %35)
br label %37
37: ; preds = %33
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %13
40: ; preds = %13
%41 = 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 = [236 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 FETUCCINE\0AQue ao contrario de somar igual a FIBONACCI, ela subtrai nos termos pares\0ADigite o termo que voce quer encontrar:\0A\00"
@str.6 = [35 x i8] c"\0A\0ASerie de Fetuccine [Fibonacci]:\0A\00"
@str.7 = [11 x i8] c"Termo 1: 1\00"
@str.8 = [11 x i8] c"Termo 2: 1\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([236 x i8], [236 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 ([35 x i8], [35 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, 3
br i1 %9, label %23, label %10
10: ; preds = %0, %10
%11 = phi i32 [ %12, %10 ], [ 1, %0 ]
%12 = phi i32 [ %18, %10 ], [ 1, %0 ]
%13 = phi i32 [ %20, %10 ], [ 3, %0 ]
%14 = and i32 %13, 1
%15 = icmp eq i32 %14, 0
%16 = sub i32 0, %11
%17 = select i1 %15, i32 %16, i32 %11
%18 = add i32 %17, %12
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %13, i32 %18)
%20 = add nuw nsw i32 %13, 1
%21 = load i32, i32* %1
%22 = icmp slt i32 %13, %21
br i1 %22, label %10, label %23
23: ; preds = %10, %0
%24 = call i32 (...) @getch()
ret i32 0
}