#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 atoi(char *);
int fib(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("usage: %s <positive integer>\n", argv[0]);
    return 0;
  } else {
    int seq_length;
    int current_elem;
    current_elem = -1;
    seq_length = atoi(argv[1]);
    while (seq_length > ++current_elem) {
      printf("Fibonacci Number %d is %d\n", current_elem + 1,
             fib(current_elem));
    }
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1171 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11cc <main+0x9c>
movl   $0xffffffff,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
cmp    %ecx,%eax
jle    11c5 <main+0x95>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <fib@plt>
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1188 <main+0x58>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x2,%edi
jne    117e <main+0x4e>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
test   %eax,%eax
jle    118f <main+0x5f>
mov    %eax,%ebx
lea    0xecf(%rip),%r14
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x1(%rdi),%ebp
call   1040 <fib@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%edi
cmp    %ebp,%ebx
jne    1160 <main+0x30>
jmp    118f <main+0x5f>
mov    (%rsi),%rsi
lea    0xe78(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"usage: %s <positive integer>\0A\00"
@.str.1 = [27 x i8] c"Fibonacci Number %d is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 0, i32* %3
br label %32
15: ; preds = %2
store i32 -1, i32* %7
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %6
br label %20
20: ; preds = %25, %15
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = add nsw i32 %22, 1
store i32 %23, i32* %7
%24 = icmp sgt i32 %21, %23
br i1 %24, label %25, label %31
25: ; preds = %20
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
%28 = load i32, i32* %7
%29 = call i32 @fib(i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 %29)
br label %20
31: ; preds = %20
store i32 0, i32* %3
br label %32
32: ; preds = %31, %10
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [30 x i8] c"usage: %s <positive integer>\0A\00"
@.str.1 = [27 x i8] c"Fibonacci Number %d is %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %20
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %7, %12
%13 = phi i32 [ %18, %12 ], [ 0, %7 ]
%14 = phi i32 [ %13, %12 ], [ -1, %7 ]
%15 = add nsw i32 %14, 2
%16 = tail call i32 @fib(i32 %13)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %16)
%18 = add nuw nsw i32 %13, 1
%19 = icmp eq i32 %18, %10
br i1 %19, label %20, label %12
20: ; preds = %12, %7, %4
ret i32 0
}