#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_1(int n) {
  int i, first = 0, second = 1, next;
  for (i = 0; i < n; i++) {
    if (i <= 1)
      next = i;
    else {
      next = first + second;
      first = second;
      second = next;
    }
    printf("%d\n", next);
  }
}


x86 assembly (clang, -O0):
<fibo_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1183 <fibo_1+0x73>
cmpl   $0x1,-0x8(%rbp)
jg     1151 <fibo_1+0x41>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1166 <fibo_1+0x56>
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    0xe90(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1130 <fibo_1+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fibo_1>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edi,%edi
jle    1151 <fibo_1+0x41>
mov    %edi,%r15d
xor    %r12d,%r12d
mov    $0x1,%ebp
lea    0xed2(%rip),%r14
xor    %ebx,%ebx
lea    (%r12,%rbp,1),%esi
cmp    $0x2,%ebx
cmovae %ebp,%r12d
cmovae %esi,%ebp
cmovb  %ebx,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    %ebx,%r15d
jne    1130 <fibo_1+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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