#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int terms = 0, i = 0, num1 = 1, num2 = 0;
  printf("Enter number of terms: ");
  scanf("%d", &terms);
  if (terms < 0 || terms > 47)
    printf("ERROR: Out of bounds");
  else {
    for (i = 0; i < terms; i++) {
      if (i % 2) {
        printf("%d ", num1);
        num2 += num1;
      } else {
        printf("%d ", num2);
        num1 += num2;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     117d <main+0x5d>
cmpl   $0x2f,-0x8(%rbp)
jle    1190 <main+0x70>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1208 <main+0xe8>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1203 <main+0xe3>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11d6 <main+0xb6>
mov    -0x10(%rbp),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11f0 <main+0xd0>
mov    -0x14(%rbp),%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11f5 <main+0xd5>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1197 <main+0x77>
jmp    1208 <main+0xe8>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x2f,%eax
jbe    1167 <main+0x47>
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11ac <main+0x8c>
test   %eax,%eax
je     11ac <main+0x8c>
mov    $0x1,%r15d
lea    0xeb8(%rip),%r14
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1195 <main+0x75>
xchg   %ax,%ax
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    %ebp,%r15d
add    $0x1,%ebx
cmp    0x4(%rsp),%ebx
jge    11ac <main+0x8c>
mov    %r14,%rdi
test   $0x1,%bl
je     1180 <main+0x60>
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    %r15d,%ebp
jmp    118c <main+0x6c>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Enter number of terms: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"ERROR: Out of bounds\00"
@.str.3 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 1, i32* %4
store i32 0, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %0
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 47
br i1 %12, label %13, label %15
13: ; preds = %10, %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %41
15: ; preds = %10
store i32 0, i32* %3
br label %16
16: ; preds = %37, %15
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %40
20: ; preds = %16
%21 = load i32, i32* %3
%22 = srem i32 %21, 2
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = load i32, i32* %4
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = add nsw i32 %28, %27
store i32 %29, i32* %5
br label %36
30: ; preds = %20
%31 = load i32, i32* %5
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %5
%34 = load i32, i32* %4
%35 = add nsw i32 %34, %33
store i32 %35, i32* %4
br label %36
36: ; preds = %30, %24
br label %37
37: ; preds = %36
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %16
40: ; preds = %16
br label %41
41: ; preds = %40, %13
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"Enter number of terms: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [21 x i8] c"ERROR: Out of bounds\00"
@.str.3 = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp ugt i32 %5, 47
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = icmp eq i32 %5, 0
br i1 %8, label %29, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %29
11: ; preds = %7, %23
%12 = phi i32 [ %25, %23 ], [ 0, %7 ]
%13 = phi i32 [ %24, %23 ], [ 1, %7 ]
%14 = phi i32 [ %26, %23 ], [ 0, %7 ]
%15 = and i32 %14, 1
%16 = icmp eq i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %11
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%19 = add nsw i32 %12, %13
br label %23
20: ; preds = %11
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%22 = add nsw i32 %12, %13
br label %23
23: ; preds = %17, %20
%24 = phi i32 [ %13, %17 ], [ %22, %20 ]
%25 = phi i32 [ %19, %17 ], [ %12, %20 ]
%26 = add nuw nsw i32 %14, 1
%27 = load i32, i32* %1
%28 = icmp slt i32 %26, %27
br i1 %28, label %11, label %29
29: ; preds = %23, %7, %9
ret i32 0
}