#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 fibonnaci(int n) {
  int n1 = 0, n2 = 1, aux = 1, cont;
  for (cont = 0; cont <= n; cont++) {
    printf("%d\n", n1);
    aux = n1;
    n1 = n2;
    n2 = aux + n2;
  }
  return n1;
}


x86 assembly (clang, -O0):
<fibonnaci>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1175 <fibonnaci+0x65>
mov    -0x8(%rbp),%esi
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <fibonnaci+0x27>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fibonnaci>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
js     114c <fibonnaci+0x3c>
mov    %edi,%ebx
add    $0x1,%ebx
xor    %ebp,%ebp
mov    $0x1,%eax
lea    0xed2(%rip),%r14
xchg   %ax,%ax
mov    %eax,%r15d
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    %r15d,%ebp
mov    %ebp,%eax
mov    %r15d,%ebp
add    $0xffffffff,%ebx
jne    1130 <fibonnaci+0x20>
jmp    114f <fibonnaci+0x3f>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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