#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 *, ...);
void *fibonnaci(void *i) {
  int fi, fj, fk, k, n;
  n = *(int *)i;
  fi = 0;
  fj = 1;
  printf("0 1");
  for (k = 1; k <= n; k++) {
    fk = fi + fj;
    fi = fj;
    fj = fk;
    printf(" %d", fk);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<fibonnaci>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     1188 <fibonnaci+0x78>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1148 <fibonnaci+0x38>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fibonnaci>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%r15d
lea    0xecf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r15d,%r15d
jle    116a <fibonnaci+0x4a>
mov    $0x1,%ebx
lea    0xebb(%rip),%r14
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
mov    %ebp,%ebx
add    $0xffffffff,%r15d
jne    1150 <fibonnaci+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"0 1\00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [2 x i8] c"\0A\00"
define i8* @fibonnaci(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
store i32 %10, i32* %7
store i32 0, i32* %3
store i32 1, i32* %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %6
br label %12
12: ; preds = %24, %1
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = add nsw i32 %17, %18
store i32 %19, i32* %5
%20 = load i32, i32* %4
store i32 %20, i32* %3
%21 = load i32, i32* %5
store i32 %21, i32* %4
%22 = load i32, i32* %5
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %16
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %12
27: ; preds = %12
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i8* null
}

LLVM IR (-O2):
@.str = [4 x i8] c"0 1\00"
@.str.1 = [4 x i8] c" %d\00"
define noalias i8* @fibonnaci(i8* nocapture %0) {
%2 = bitcast i8* %0 to i32*
%3 = load i32, i32* %2
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = icmp slt i32 %3, 1
br i1 %5, label %14, label %6
6: ; preds = %1, %6
%7 = phi i32 [ %9, %6 ], [ 0, %1 ]
%8 = phi i32 [ %12, %6 ], [ 1, %1 ]
%9 = phi i32 [ %10, %6 ], [ 1, %1 ]
%10 = add nsw i32 %7, %9
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = add nuw i32 %8, 1
%13 = icmp eq i32 %8, %3
br i1 %13, label %14, label %6
14: ; preds = %6, %1
%15 = tail call i32 @putchar(i32 10)
ret i8* null
}