#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(void) {
  int n;
  int i;
  int current;
  int next;
  int twoaway;
  printf("How many Fibonacci numbers do you want to compute? ");
  scanf("%d", &n);
  if (n <= 0)
    printf("The number should be positive.\n");
  else {
    printf("\n\n\tI \t Fibonacci(I) \n\t=====================\n");
    next = current = 1;
    for (i = 1; i <= n; i++) {
      printf("\t%d \t   %d\n", i, current);
      twoaway = current + next;
      current = next;
      next = twoaway;
    }
  }
}


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    0xef0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jg     116a <main+0x4a>
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d5 <main+0xb5>
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11d0 <main+0xb0>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118d <main+0x6d>
jmp    11d5 <main+0xb5>
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
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11b4 <main+0x84>
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x4(%rsp)
jle    11c0 <main+0x90>
mov    $0x1,%eax
lea    0xebb(%rip),%r14
xor    %ebp,%ebp
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %eax,%r15d
add    $0x1,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    %r15d,%ebx
mov    %ebx,%eax
mov    %r15d,%ebx
cmp    0x4(%rsp),%ebp
jl     1190 <main+0x60>
jmp    11c0 <main+0x90>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [52 x i8] c"How many Fibonacci numbers do you want to compute? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"The number should be positive.\0A\00"
@.str.3 = [45 x i8] c"\0A\0A\09I \09 Fibonacci(I) \0A\09=====================\0A\00"
@.str.4 = [12 x i8] c"\09%d \09 %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
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 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* %2)
%9 = load i32, i32* %2
%10 = icmp sle i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %32
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %4
store i32 1, i32* %5
store i32 1, i32* %3
br label %15
15: ; preds = %28, %13
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %31
19: ; preds = %15
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %20, i32 %21)
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = add nsw i32 %23, %24
store i32 %25, i32* %6
%26 = load i32, i32* %5
store i32 %26, i32* %4
%27 = load i32, i32* %6
store i32 %27, i32* %5
br label %28
28: ; preds = %19
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %15
31: ; preds = %15
br label %32
32: ; preds = %31, %11
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [52 x i8] c"How many Fibonacci numbers do you want to compute? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [12 x i8] c"\09%d \09 %d\0A\00"
@str = [44 x i8] c"\0A\0A\09I \09 Fibonacci(I) \0A\09=====================\00"
@str.5 = [31 x i8] c"The number should be positive.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 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 %7, label %9
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.5, i64 0, i64 0))
br label %22
9: ; preds = %0
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 1
br i1 %12, label %22, label %13
13: ; preds = %9, %13
%14 = phi i32 [ %19, %13 ], [ 1, %9 ]
%15 = phi i32 [ %18, %13 ], [ 1, %9 ]
%16 = phi i32 [ %15, %13 ], [ 1, %9 ]
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %14, i32 %16)
%18 = add nsw i32 %15, %16
%19 = add nuw nsw i32 %14, 1
%20 = load i32, i32* %1
%21 = icmp slt i32 %14, %20
br i1 %21, label %13, label %22
22: ; preds = %13, %9, %7
ret i32 0
}