#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 */
unsigned long long fib(unsigned int);
int /*<<< orphan*/ printf(char *, int, unsigned int, ...);
int main(int argc, char *argv[]) {
  int i;
  unsigned int n;
  for (n = 0; n < 30; n++) {
    unsigned long long f = fib(n);
    printf("n=%10u f=%30llu\n", n, f);
  }
  for (i = 0, n = 0; i < 1000 && n >= 0; i++, n = 2 * n + 1) {
    unsigned long long f = fib(n);
    printf("i=%4d n=%10u f=%30llu\n", i, n, f);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x1e,-0x18(%rbp)
jae    1178 <main+0x58>
mov    -0x18(%rbp),%edi
call   1040 <fib@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%rax
mov    %eax,%edx
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113d <main+0x1d>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x3e8,-0x14(%rbp)
mov    %al,-0x29(%rbp)
jge    11a2 <main+0x82>
cmpl   $0x0,-0x18(%rbp)
setae  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11b2 <main+0x92>
jmp    11f0 <main+0xd0>
mov    -0x18(%rbp),%edi
call   1040 <fib@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%rcx
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1186 <main+0x66>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xedb(%rip),%rbx
xor    %ebp,%ebp
nopl   (%rax)
mov    %ebp,%edi
call   1040 <fib@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    $0x1e,%ebp
jne    1130 <main+0x10>
lea    0xeac(%rip),%r14
xor    %ebp,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1040 <fib@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
add    %ebx,%ebx
add    $0x1,%ebx
cmp    $0x3e8,%ebp
jne    1160 <main+0x40>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"n=%10u f=%30llu\0A\00"
@.str.1 = [23 x i8] c"i=%4d n=%10u f=%30llu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %10
10: ; preds = %20, %2
%11 = load i32, i32* %7
%12 = icmp ult i32 %11, 30
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i32, i32* %7
%15 = call i64 @fib(i32 %14)
store i64 %15, i64* %8
%16 = load i32, i32* %7
%17 = load i64, i64* %8
%18 = trunc i64 %17 to i32
%19 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %18)
br label %20
20: ; preds = %13
%21 = load i32, i32* %7
%22 = add i32 %21, 1
store i32 %22, i32* %7
br label %10
23: ; preds = %10
store i32 0, i32* %6
store i32 0, i32* %7
br label %24
24: ; preds = %39, %23
%25 = load i32, i32* %6
%26 = icmp slt i32 %25, 1000
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* %7
%29 = icmp uge i32 %28, 0
br label %30
30: ; preds = %27, %24
%31 = phi i1 [ false, %24 ], [ %29, %27 ]
br i1 %31, label %32, label %45
32: ; preds = %30
%33 = load i32, i32* %7
%34 = call i64 @fib(i32 %33)
store i64 %34, i64* %9
%35 = load i32, i32* %6
%36 = load i32, i32* %7
%37 = load i64, i64* %9
%38 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %36, i64 %37)
br label %39
39: ; preds = %32
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
%42 = load i32, i32* %7
%43 = mul i32 2, %42
%44 = add i32 %43, 1
store i32 %44, i32* %7
br label %24
45: ; preds = %30
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"n=%10u f=%30llu\0A\00"
@.str.1 = [23 x i8] c"i=%4d n=%10u f=%30llu\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 0, %2 ], [ %8, %3 ]
%5 = tail call i64 @fib(i32 %4)
%6 = trunc i64 %5 to i32
%7 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %6)
%8 = add nuw nsw i32 %4, 1
%9 = icmp eq i32 %8, 30
br i1 %9, label %10, label %3
10: ; preds = %3, %10
%11 = phi i32 [ %15, %10 ], [ 0, %3 ]
%12 = phi i32 [ %17, %10 ], [ 0, %3 ]
%13 = tail call i64 @fib(i32 %12)
%14 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12, i64 %13)
%15 = add nuw nsw i32 %11, 1
%16 = shl i32 %12, 1
%17 = or i32 %16, 1
%18 = icmp eq i32 %15, 1000
br i1 %18, label %19, label %10
19: ; preds = %10
ret i32 0
}