#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 *, unsigned int *);
int main() {
  unsigned i, num;
  unsigned long long fib, prev1, prev2;
  printf("Enter a number: ");
  scanf("%u", &num);
  prev1 = 1;
  prev2 = 1;
  printf("0 -> %I64u\n", prev1);
  printf("1 -> %I64u\n", prev2);
  for (i = 2; i <= num; ++i) {
    fib = prev1 + prev2;
    prev2 = prev1;
    prev1 = fib;
    printf("%d -> %I64u\n", i, fib);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movq   $0x1,-0x20(%rbp)
movq   $0x1,-0x28(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
ja     11d3 <main+0xb3>
mov    -0x20(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%rdx
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1188 <main+0x68>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
lea    0xec1(%rip),%rdi
mov    $0x1,%r12d
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb4(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x2,0xc(%rsp)
jb     11c4 <main+0xa4>
mov    $0x2,%ebx
lea    0xea1(%rip),%r14
mov    $0x1,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%r15
add    %r13,%r15
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebx
mov    %r13,%r12
mov    %r15,%r13
cmp    0xc(%rsp),%ebx
jbe    11a0 <main+0x80>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Enter a number: \00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [12 x i8] c"0 -> %I64u\0A\00"
@.str.3 = [12 x i8] c"1 -> %I64u\0A\00"
@.str.4 = [13 x i8] c"%d -> %I64u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 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* %3)
store i64 1, i64* %5
store i64 1, i64* %6
%9 = load i64, i64* %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 %9)
%11 = load i64, i64* %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i64 %11)
store i32 2, i32* %2
br label %13
13: ; preds = %26, %0
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = icmp ule i32 %14, %15
br i1 %16, label %17, label %29
17: ; preds = %13
%18 = load i64, i64* %5
%19 = load i64, i64* %6
%20 = add i64 %18, %19
store i64 %20, i64* %4
%21 = load i64, i64* %5
store i64 %21, i64* %6
%22 = load i64, i64* %4
store i64 %22, i64* %5
%23 = load i32, i32* %2
%24 = load i64, i64* %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %23, i64 %24)
br label %26
26: ; preds = %17
%27 = load i32, i32* %2
%28 = add i32 %27, 1
store i32 %28, i32* %2
br label %13
29: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Enter a number: \00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [12 x i8] c"0 -> %I64u\0A\00"
@.str.3 = [12 x i8] c"1 -> %I64u\0A\00"
@.str.4 = [13 x i8] c"%d -> %I64u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 1)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i64 1)
%7 = load i32, i32* %1
%8 = icmp ult i32 %7, 2
br i1 %8, label %18, label %9
9: ; preds = %0, %9
%10 = phi i64 [ %11, %9 ], [ 1, %0 ]
%11 = phi i64 [ %13, %9 ], [ 1, %0 ]
%12 = phi i32 [ %15, %9 ], [ 2, %0 ]
%13 = add i64 %10, %11
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %12, i64 %13)
%15 = add i32 %12, 1
%16 = load i32, i32* %1
%17 = icmp ugt i32 %15, %16
br i1 %17, label %18, label %9
18: ; preds = %9, %0
ret i32 0
}