#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);
int fibonacci(int n) {
  int fib[n];
  int i = 2;
  fib[0] = 1;
  fib[1] = 1;
  while (i < n) {
    fib[i] = fib[i - 1] + fib[i - 2];
    printf("%d, ", fib[i]);
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<fibonacci>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x10(%rbp)
lea    0xf(,%rcx,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x28(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
movl   $0x1,(%rax)
movl   $0x1,0x4(%rax)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a8 <fibonacci+0x98>
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x1c(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
add    (%rax,%rcx,4),%edx
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1158 <fibonacci+0x48>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fibonacci>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r15d
mov    %rsp,%rax
lea    0xf(,%r15,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rax,%r12
sub    %rcx,%r12
mov    %r12,%rsp
neg    %rcx
movabs $0x100000001,%rdx
mov    %rdx,(%rax,%rcx,1)
cmp    $0x3,%edi
jl     11ad <fibonacci+0x9d>
mov    %edi,%r14d
movl   $0x2,0x8(%r12)
lea    0xe9e(%rip),%rdi
mov    $0x2,%r13d
mov    $0x2,%esi
call   1030 <printf@plt>
cmp    $0x3,%r14d
je     11ad <fibonacci+0x9d>
mov    $0x3,%ebx
lea    0xe7c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    -0x8(%r12,%rbx,4),%r13d
mov    %r13d,(%r12,%rbx,4)
mov    %r14,%rdi
mov    %r13d,%esi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1190 <fibonacci+0x80>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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