#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 int atoi(char *);
int /*<<< orphan*/ fibo_array(unsigned int *, unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int);
int main(int argc, char **argv) {
  unsigned int limit = atoi(argv[1]);
  unsigned int results[limit];
  fibo_array(results, limit);
  for (unsigned int n = 0; n < limit; n++)
    printf("%d: %d\n", n + 1, results[n]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
call   1050 <fibo_array@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11c2 <main+0x92>
mov    -0x38(%rbp),%rax
mov    -0x2c(%rbp),%esi
add    $0x1,%esi
mov    -0x2c(%rbp),%ecx
mov    (%rax,%rcx,4),%edx
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    118c <main+0x5c>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
mov    %eax,%ebx
mov    %eax,%r12d
mov    %rsp,%r14
lea    0xf(,%r12,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <fibo_array@plt>
test   %ebx,%ebx
je     1197 <main+0x67>
xor    %ebx,%ebx
lea    0xe8b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14,%rbx,4),%edx
add    $0x1,%rbx
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
cmp    %rbx,%r12
jne    1180 <main+0x50>
xor    %eax,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%d: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %7
%17 = alloca i32, i64 %15
store i64 %15, i64* %8
%18 = load i32, i32* %6
%19 = call i32 @fibo_array(i32* %17, i32 %18)
store i32 0, i32* %9
br label %20
20: ; preds = %32, %2
%21 = load i32, i32* %9
%22 = load i32, i32* %6
%23 = icmp ult i32 %21, %22
br i1 %23, label %24, label %35
24: ; preds = %20
%25 = load i32, i32* %9
%26 = add i32 %25, 1
%27 = load i32, i32* %9
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %17, i64 %28
%30 = load i32, i32* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %30)
br label %32
32: ; preds = %24
%33 = load i32, i32* %9
%34 = add i32 %33, 1
store i32 %34, i32* %9
br label %20
35: ; preds = %20
%36 = load i8*, i8** %7
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [8 x i8] c"%d: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = zext i32 %5 to i64
%7 = alloca i32, i64 %6
%8 = call i32 @fibo_array(i32* %7, i32 %5)
%9 = icmp eq i32 %5, 0
br i1 %9, label %10, label %11
10: ; preds = %11, %2
ret i32 0
11: ; preds = %2, %11
%12 = phi i64 [ %13, %11 ], [ 0, %2 ]
%13 = add nuw nsw i64 %12, 1
%14 = getelementptr inbounds i32, i32* %7, i64 %12
%15 = load i32, i32* %14
%16 = trunc i64 %13 to i32
%17 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %15)
%18 = icmp eq i64 %13, %6
br i1 %18, label %10, label %11
}