#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);
void fibo(int count) {
  int a = 0, b = 1;
  count -= 2;
  printf("%d\n", a);
  printf("%d\n", b);
  while (count--)
    printf("%d\n", (b > a) ? (a += b) : (b += a));
}


x86 assembly (clang, -O0):
<fibo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%esi
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
je     11a1 <fibo+0x91>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1181 <fibo+0x71>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    %eax,-0x10(%rbp)
jmp    118d <fibo+0x7d>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
jmp    1150 <fibo+0x40>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fibo>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
lea    0xedf(%rip),%r14
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    %r14,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
add    $0xfffffffe,%r15d
je     1169 <fibo+0x59>
lea    0xeb4(%rip),%r14
nopl   0x0(%rax)
lea    (%rbx,%rbp,1),%esi
cmp    %ebx,%ebp
cmovg  %esi,%ebx
cmovle %esi,%ebp
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0xffffffff,%r15d
jne    1150 <fibo+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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