#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\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 Ricci:\n\n");
  printf("Termo 0: %d\n", primeiro);
  printf("Termo 1: %d\n", segundo);
  a = primeiro;
  b = segundo;
  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    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf75(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xf32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf53(%rip),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xf42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xf49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xf45(%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   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cmp    -0x8(%rbp),%eax
jge    120c <main+0xdc>
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    0xf07(%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    0xf54(%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    0xf5e(%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   $0x2,0x14(%rsp)
jl     1201 <main+0xc1>
mov    0xc(%rsp),%eax
mov    $0x1,%ebx
mov    0x10(%rsp),%ebp
lea    0xe47(%rip),%r14
nopl   0x0(%rax,%rax,1)
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    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 = [152 x i8] c"Uma serie muito famosa na matematica e a serie de FIBONACCI\0A\0AUma serie parecida e a serie de RICCI\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 = [24 x i8] c"\0A\0ASua Serie de Ricci:\0A\0A\00"
@.str.5 = [13 x i8] c"Termo 0: %d\0A\00"
@.str.6 = [13 x i8] c"Termo 1: %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 ([152 x i8], [152 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 ([24 x i8], [24 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 2, i32* %3
br label %21
21: ; preds = %35, %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 %38
26: ; preds = %21
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = add nsw i32 %27, %28
store i32 %29, i32* %7
%30 = load i32, i32* %6
store i32 %30, i32* %5
%31 = load i32, i32* %7
store i32 %31, i32* %6
%32 = load i32, i32* %3
%33 = load i32, i32* %7
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %32, i32 %33)
br label %35
35: ; preds = %26
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %21
38: ; preds = %21
%39 = 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 0: %d\0A\00"
@.str.6 = [13 x i8] c"Termo 1: %d\0A\00"
@.str.7 = [14 x i8] c"Termo %d: %d\0A\00"
@str = [151 x i8] c"Uma serie muito famosa na matematica e a serie de FIBONACCI\0A\0AUma serie parecida e a serie de RICCI\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 = [23 x i8] c"\0A\0ASua Serie de 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 ([151 x i8], [151 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 ([23 x i8], [23 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, 2
br i1 %17, label %30, 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 [ %27, %21 ], [ 2, %18 ]
%23 = phi i32 [ %25, %21 ], [ %19, %18 ]
%24 = phi i32 [ %23, %21 ], [ %20, %18 ]
%25 = add nsw i32 %23, %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %22, i32 %25)
%27 = add nuw nsw i32 %22, 1
%28 = load i32, i32* %1
%29 = icmp slt i32 %22, %28
br i1 %29, label %21, label %30
30: ; preds = %21, %0
%31 = call i32 (...) @getch()
ret i32 0
}