#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 /*<<< orphan*/ puts(char *);
void printFib(int range) {
  int fibNum1 = 1;
  int fibNum2 = 2;
  int sumNum;
  if (range <= 0) {
    puts("There's nothing to show!");
  } else if (range >= 1) {
    printf("%d, ", 1);
  }
  for (int i = 1; i < range; i++) {
    if (i == 1) {
      printf("%d, ", 2);
    } else {
      sumNum = fibNum1 + fibNum2;
      printf("%d, ", sumNum);
      if (sumNum > 4000000) {
        puts("This is over 4 mill.");
      } else if (sumNum == 4000000) {
        puts("This gives you 4 mill");
      } else {
        puts("Under 4 mill");
      }
      fibNum1 = fibNum2;
      fibNum2 = sumNum;
    }
  }
}


x86 assembly (clang, -O0):
<printFib>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     1154 <printFib+0x34>
lea    0xeb6(%rip),%rdi
call   1030 <puts@plt>
jmp    1174 <printFib+0x54>
cmpl   $0x1,-0x4(%rbp)
jl     116f <printFib+0x4f>
lea    0xeb4(%rip),%rdi
mov    $0x1,%esi
call   1040 <printf@plt>
jmp    1174 <printFib+0x54>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    122b <printFib+0x10b>
cmpl   $0x1,-0x14(%rbp)
jne    11a7 <printFib+0x87>
lea    0xe81(%rip),%rdi
mov    $0x2,%esi
call   1040 <printf@plt>
jmp    1218 <printFib+0xf8>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x3d0900,-0x10(%rbp)
jle    11dd <printFib+0xbd>
lea    0xe4b(%rip),%rdi
call   1030 <puts@plt>
jmp    120c <printFib+0xec>
cmpl   $0x3d0900,-0x10(%rbp)
jne    11fb <printFib+0xdb>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
jmp    1207 <printFib+0xe7>
lea    0xe47(%rip),%rdi
call   1030 <puts@plt>
jmp    120c <printFib+0xec>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    121d <printFib+0xfd>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117b <printFib+0x5b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printFib>:
test   %edi,%edi
jle    11d3 <printFib+0xb3>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xedd(%rip),%rdi
mov    $0x1,%esi
call   1040 <printf@plt>
cmp    $0x1,%ebx
je     11c4 <printFib+0xa4>
lea    0xec7(%rip),%rdi
mov    $0x2,%r15d
mov    $0x2,%esi
call   1040 <printf@plt>
cmp    $0x2,%ebx
je     11c4 <printFib+0xa4>
add    $0xfffffffe,%ebx
mov    $0x1,%eax
lea    0xebd(%rip),%r12
lea    0xecc(%rip),%r13
lea    0xe9a(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,%ebp
add    %r15d,%ebp
lea    0xe7d(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
cmp    $0x3d0900,%ebp
mov    %r13,%rdi
cmove  %r12,%rdi
cmovg  %r14,%rdi
call   1030 <puts@plt>
mov    %r15d,%eax
mov    %ebp,%r15d
add    $0xffffffff,%ebx
jne    1190 <printFib+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe26(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"There's nothing to show!\00"
@.str.1 = [5 x i8] c"%d, \00"
@.str.2 = [21 x i8] c"This is over 4 mill.\00"
@.str.3 = [22 x i8] c"This gives you 4 mill\00"
@.str.4 = [13 x i8] c"Under 4 mill\00"
define void @printFib(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
store i32 2, i32* %4
%7 = load i32, i32* %2
%8 = icmp sle i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %17
11: ; preds = %1
%12 = load i32, i32* %2
%13 = icmp sge i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %16
16: ; preds = %14, %11
br label %17
17: ; preds = %16, %9
store i32 1, i32* %6
br label %18
18: ; preds = %49, %17
%19 = load i32, i32* %6
%20 = load i32, i32* %2
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %52
22: ; preds = %18
%23 = load i32, i32* %6
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %48
27: ; preds = %22
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = add nsw i32 %28, %29
store i32 %30, i32* %5
%31 = load i32, i32* %5
%32 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %5
%34 = icmp sgt i32 %33, 4000000
br i1 %34, label %35, label %37
35: ; preds = %27
%36 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %45
37: ; preds = %27
%38 = load i32, i32* %5
%39 = icmp eq i32 %38, 4000000
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %44
42: ; preds = %37
%43 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %44
44: ; preds = %42, %40
br label %45
45: ; preds = %44, %35
%46 = load i32, i32* %4
store i32 %46, i32* %3
%47 = load i32, i32* %5
store i32 %47, i32* %4
br label %48
48: ; preds = %45, %25
br label %49
49: ; preds = %48
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
br label %18
52: ; preds = %18
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"There's nothing to show!\00"
@.str.1 = [5 x i8] c"%d, \00"
@.str.2 = [21 x i8] c"This is over 4 mill.\00"
@.str.3 = [22 x i8] c"This gives you 4 mill\00"
@.str.4 = [13 x i8] c"Under 4 mill\00"
define void @printFib(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %11
5: ; preds = %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 1)
%7 = icmp eq i32 %0, 1
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 2)
%10 = icmp eq i32 %0, 2
br i1 %10, label %11, label %12
11: ; preds = %12, %8, %3, %5
ret void
12: ; preds = %8, %12
%13 = phi i32 [ %23, %12 ], [ 2, %8 ]
%14 = phi i32 [ %15, %12 ], [ 1, %8 ]
%15 = phi i32 [ %16, %12 ], [ 2, %8 ]
%16 = add nsw i32 %14, %15
%17 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = icmp sgt i32 %16, 4000000
%19 = icmp eq i32 %16, 4000000
%20 = select i1 %19, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0)
%21 = select i1 %18, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %20
%22 = tail call i32 @puts(i8* dereferenceable(1) %21)
%23 = add nuw nsw i32 %13, 1
%24 = icmp eq i32 %23, %0
br i1 %24, label %11, label %12
}