#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int prec1 = 1;
  int prec2 = 0;
  int r, i, howmanyt = 0;
  printf("How many times do I have to do the Fibonacci?\n");
  scanf("%d", &howmanyt);
  if (howmanyt < 1) {
    printf("You can`t set 0 or a negative number, please write a new number: ");
    scanf("%d", &howmanyt);
  } else if (howmanyt > 45) {
    printf("For now Fibonaccis doesn`t support more than 45 times, please "
           "write a new number: ");
    scanf("%d", &howmanyt);
  }
  for (i = 0; i <= howmanyt; i++) {
    r = prec1 + prec2;
    printf("\n"
           "%d",
           r);
    prec1 = prec2;
    prec2 = r;
  }
  printf("\n Fibonaccis ran %d times,", howmanyt);
  printf(" the last number of the sequence was %d \n", r);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf6c(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x18(%rbp)
jge    118f <main+0x6f>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf44(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
jmp    11bc <main+0x9c>
cmpl   $0x2d,-0x18(%rbp)
jle    11b7 <main+0x97>
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf17(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
jmp    11bc <main+0x9c>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1203 <main+0xe3>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c3 <main+0xa3>
mov    -0x18(%rbp),%esi
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xf98(%rip),%rdi
call   1030 <puts@plt>
lea    0xf44(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    1172 <main+0x42>
cmp    $0x2e,%eax
jb     1199 <main+0x69>
lea    0xed2(%rip),%rdi
jmp    1179 <main+0x49>
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf0f(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
js     11d4 <main+0xa4>
mov    $0x1,%eax
mov    $0xffffffff,%ebp
lea    0xeeb(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %ebx,%r15d
mov    %eax,%ebx
add    %r15d,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
add    $0x1,%ebp
mov    %r15d,%eax
cmp    %esi,%ebp
jl     11b0 <main+0x80>
jmp    11d4 <main+0xa4>
lea    0xebe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecb(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"How many times do I have to do the Fibonacci?\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [66 x i8] c"You can`t set 0 or a negative number, please write a new number: \00"
@.str.3 = [83 x i8] c"For now Fibonaccis doesn`t support more than 45 times, please write a new number: \00"
@.str.4 = [4 x i8] c"\0A%d\00"
@.str.5 = [27 x i8] c"\0A Fibonaccis ran %d times,\00"
@.str.6 = [42 x i8] c" the last number of the sequence was %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 0, i32* %3
store i32 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
br label %21
14: ; preds = %0
%15 = load i32, i32* %6
%16 = icmp sgt i32 %15, 45
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
br label %20
20: ; preds = %17, %14
br label %21
21: ; preds = %20, %11
store i32 0, i32* %5
br label %22
22: ; preds = %34, %21
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %37
26: ; preds = %22
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = add nsw i32 %27, %28
store i32 %29, i32* %4
%30 = load i32, i32* %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %3
store i32 %32, i32* %2
%33 = load i32, i32* %4
store i32 %33, i32* %3
br label %34
34: ; preds = %26
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %22
37: ; preds = %22
%38 = load i32, i32* %6
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %4
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [66 x i8] c"You can`t set 0 or a negative number, please write a new number: \00"
@.str.3 = [83 x i8] c"For now Fibonaccis doesn`t support more than 45 times, please write a new number: \00"
@.str.4 = [4 x i8] c"\0A%d\00"
@.str.5 = [27 x i8] c"\0A Fibonaccis ran %d times,\00"
@.str.6 = [42 x i8] c" the last number of the sequence was %d \0A\00"
@str = [46 x i8] c"How many times do I have to do the Fibonacci?\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 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 = load i32, i32* %1
%6 = icmp slt i32 %5, 1
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = icmp ugt i32 %5, 45
br i1 %8, label %9, label %15
9: ; preds = %7, %0
%10 = phi i8* [ getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0), %0 ], [ getelementptr inbounds ([83 x i8], [83 x i8]* @.str.3, i64 0, i64 0), %7 ]
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %10)
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
%14 = icmp slt i32 %13, 0
br i1 %14, label %25, label %15
15: ; preds = %7, %9
br label %16
16: ; preds = %15, %16
%17 = phi i32 [ %22, %16 ], [ 0, %15 ]
%18 = phi i32 [ %20, %16 ], [ 0, %15 ]
%19 = phi i32 [ %18, %16 ], [ 1, %15 ]
%20 = add nsw i32 %18, %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %20)
%22 = add nuw nsw i32 %17, 1
%23 = load i32, i32* %1
%24 = icmp slt i32 %17, %23
br i1 %24, label %16, label %25
25: ; preds = %16, %9
%26 = phi i32 [ undef, %9 ], [ %20, %16 ]
%27 = phi i32 [ %13, %9 ], [ %23, %16 ]
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0), i32 %26)
ret i32 0
}