#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, primeiro, segundo;
  printf("Uma serie muito famosa na matematica e a serie de FIBONACCI\n\nUma "
         "serie parecida e a serie de RICCI\nAqui vamos te mostrar o n-esimo "
         "termo da serie de FETUCCINE\nDigite o termo que voce quer encontrar "
         "dessa serie:\n");
  scanf("%d", &termo);
  printf("Digite tambem os dois primeiros termos dela:\n\n");
  scanf("%d"
        "%d",
        &primeiro, &segundo);
  printf("\n\nSua Serie de Fetuccine [Base Ricci]:\n\n");
  printf("Termo 1: %d\n", primeiro);
  printf("Termo 2: %d\n", segundo);
  a = primeiro;
  b = segundo;
  for (base = 3; (base - 1) < 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    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfb1(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xf6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf8f(%rip),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xf7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xf96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xf92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x3,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cmp    -0x8(%rbp),%eax
jge    123a <main+0x10a>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1203 <main+0xd3>
mov    -0x18(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1218 <main+0xe8>
mov    -0x18(%rbp),%eax
add    -0x14(%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    0xf26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c6 <main+0x96>
mov    $0x0,%al
call   1050 <getch@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xedc(%rip),%rdi
call   1030 <puts@plt>
lea    0xea5(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf90(%rip),%rdi
call   1030 <puts@plt>
lea    0xe84(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf9a(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rsp),%esi
lea    0xe61(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x3,0x14(%rsp)
jl     120a <main+0xca>
mov    0xc(%rsp),%ebp
mov    $0x2,%ebx
mov    0x10(%rsp),%eax
lea    0xe47(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %ebp,%r15d
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
cmp    0x14(%rsp),%ebx
jl     11e0 <main+0xa0>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [212 x i8] c"Uma serie muito famosa na matematica e a serie de FIBONACCI\0A\0AUma serie parecida e a serie de RICCI\0AAqui vamos te mostrar o n-esimo termo da serie de FETUCCINE\0ADigite o termo que voce quer encontrar dessa serie:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [47 x i8] c"Digite tambem os dois primeiros termos dela:\0A\0A\00"
@.str.3 = [5 x i8] c"%d%d\00"
@.str.4 = [41 x i8] c"\0A\0ASua Serie de Fetuccine [Base Ricci]:\0A\0A\00"
@.str.5 = [13 x i8] c"Termo 1: %d\0A\00"
@.str.6 = [13 x i8] c"Termo 2: %d\0A\00"
@.str.7 = [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
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([212 x i8], [212 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %8, i32* %9)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
%15 = load i32, i32* %8
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %9
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %8
store i32 %19, i32* %5
%20 = load i32, i32* %9
store i32 %20, i32* %6
store i32 3, i32* %3
br label %21
21: ; preds = %46, %0
%22 = load i32, i32* %3
%23 = sub nsw i32 %22, 1
%24 = load i32, i32* %2
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %49
26: ; preds = %21
%27 = load i32, i32* %3
%28 = srem i32 %27, 2
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %26
%31 = load i32, i32* %6
%32 = load i32, i32* %5
%33 = sub nsw i32 %31, %32
store i32 %33, i32* %7
%34 = load i32, i32* %6
store i32 %34, i32* %5
%35 = load i32, i32* %7
store i32 %35, i32* %6
br label %42
36: ; preds = %26
%37 = load i32, i32* %6
%38 = load i32, i32* %5
%39 = add nsw i32 %37, %38
store i32 %39, i32* %7
%40 = load i32, i32* %6
store i32 %40, i32* %5
%41 = load i32, i32* %7
store i32 %41, i32* %6
br label %42
42: ; preds = %36, %30
%43 = load i32, i32* %3
%44 = load i32, i32* %7
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %43, i32 %44)
br label %46
46: ; preds = %42
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
br label %21
49: ; preds = %21
%50 = call i32 (...) @getch()
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [5 x i8] c"%d%d\00"
@.str.5 = [13 x i8] c"Termo 1: %d\0A\00"
@.str.6 = [13 x i8] c"Termo 2: %d\0A\00"
@.str.7 = [14 x i8] c"Termo %d: %d\0A\00"
@str = [211 x i8] c"Uma serie muito famosa na matematica e a serie de FIBONACCI\0A\0AUma serie parecida e a serie de RICCI\0AAqui vamos te mostrar o n-esimo termo da serie de FETUCCINE\0ADigite o termo que voce quer encontrar dessa serie:\00"
@str.8 = [46 x i8] c"Digite tambem os dois primeiros termos dela:\0A\00"
@str.9 = [40 x i8] c"\0A\0ASua Serie de Fetuccine [Base Ricci]:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([211 x i8], [211 x i8]* @str, i64 0, i64 0))
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.8, i64 0, i64 0))
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %2, i32* %3)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.9, i64 0, i64 0))
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %3
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %1
%17 = icmp slt i32 %16, 3
br i1 %17, label %34, label %18
18: ; preds = %0
%19 = load i32, i32* %3
%20 = load i32, i32* %2
br label %21
21: ; preds = %18, %21
%22 = phi i32 [ %29, %21 ], [ %19, %18 ]
%23 = phi i32 [ %22, %21 ], [ %20, %18 ]
%24 = phi i32 [ %31, %21 ], [ 3, %18 ]
%25 = and i32 %24, 1
%26 = icmp eq i32 %25, 0
%27 = sub i32 0, %23
%28 = select i1 %26, i32 %27, i32 %23
%29 = add i32 %28, %22
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %24, i32 %29)
%31 = add nuw nsw i32 %24, 1
%32 = load i32, i32* %1
%33 = icmp slt i32 %24, %32
br i1 %33, label %21, label %34
34: ; preds = %21, %0
%35 = call i32 (...) @getch()
ret i32 0
}