#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 fib(int x, int y) {
  int first = 0, second = 1;
  int new_second = first + second;
  while (new_second <= y) {
    new_second = first + second;
    first = second;
    second = new_second;
    if (new_second >= x)
      printf("%d\n", new_second);
  }
}


x86 assembly (clang, -O0):
<fib>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1176 <fib+0x66>
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),%eax
cmp    -0x4(%rbp),%eax
jl     1171 <fib+0x61>
mov    -0x14(%rbp),%esi
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
jmp    1135 <fib+0x25>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fib>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    115e <fib+0x4e>
mov    %esi,%r12d
mov    %edi,%r15d
xor    %ebx,%ebx
mov    $0x1,%ebp
lea    0xed0(%rip),%r14
jmp    1145 <fib+0x35>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %r12d,%ebp
jg     115e <fib+0x4e>
mov    %ebx,%eax
mov    %ebp,%ebx
mov    %eax,%ebp
add    %ebx,%ebp
cmp    %r15d,%ebp
jl     1140 <fib+0x30>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
jmp    1140 <fib+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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