#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 fib(int);
int /*<<< orphan*/ printf(char *, int, int, ...);
int main(int argc, char *argv[]) {
  int i;
  int n;
  for (n = 0; n < 30; n++) {
    int f = fib(n);
    printf("n=%10d f=%10d\n", n, f);
  }
  for (i = 0, n = 0; i < 1000 && n >= 0; i++, n = 2 * n + 1) {
    int f = fib(n);
    printf("i=%4d n=%10d f=%10d\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)
jge    1174 <main+0x54>
mov    -0x18(%rbp),%edi
call   1040 <fib@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xea7(%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,-0x21(%rbp)
jge    119e <main+0x7e>
cmpl   $0x0,-0x18(%rbp)
setge  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11ae <main+0x8e>
jmp    11ea <main+0xca>
mov    -0x18(%rbp),%edi
call   1040 <fib@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe37(%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    1182 <main+0x62>
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    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
add    %ebx,%ebx
add    $0x1,%ebx
cmp    $0x20,%ebp
jne    1160 <main+0x40>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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