#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 argc, const char *argv[]) {
  int number;
  printf("===== Exercise 8 =====\n");
  printf("FIBONACCI NUMBERS!\n");
  printf("Enter the first number. : ");
  scanf("%i", &number);
  printf("How many numbers will be shown?: ");
  int TheNumberOfNumber;
  scanf("%i", &TheNumberOfNumber);
  int fibonacci[TheNumberOfNumber];
  fibonacci[0] = number;
  fibonacci[1] = number;
  for (int i = 2; i < TheNumberOfNumber; i++) {
    fibonacci[i] = fibonacci[i - 2] + fibonacci[i - 1];
  }
  printf("--> %i First Fibonacci Numbers\n", number);
  for (int j = 0; j < TheNumberOfNumber; j++) {
    printf("%i\n", fibonacci[j]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x41(%rbp)
call   1030 <printf@plt>
mov    -0x41(%rbp),%al
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x41(%rbp),%al
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
mov    %rdi,-0x40(%rbp)
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x41(%rbp),%al
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x20(%rbp)
lea    0xf(,%rcx,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x38(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x28(%rbp)
mov    -0x14(%rbp),%ecx
mov    %ecx,(%rax)
mov    -0x14(%rbp),%ecx
mov    %ecx,0x4(%rax)
movl   $0x2,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    120d <main+0xed>
mov    -0x38(%rbp),%rax
mov    -0x2c(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
add    (%rax,%rcx,4),%edx
movslq -0x2c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d0 <main+0xb0>
mov    -0x14(%rbp),%esi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1258 <main+0x138>
mov    -0x38(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1225 <main+0x105>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xf1e(%rip),%rdi
call   1030 <puts@plt>
lea    0xf29(%rip),%rdi
call   1030 <puts@plt>
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeaf(%rip),%rbx
lea    -0x28(%rbp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x24(%rbp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    %rsp,%r14
mov    -0x24(%rbp),%eax
mov    %rsp,%rcx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
mov    %rcx,%r12
sub    %rax,%r12
mov    %r12,%rsp
neg    %rax
mov    -0x28(%rbp),%r15d
mov    %r15d,(%rcx,%rax,1)
mov    %r15d,0x4(%r12)
mov    -0x24(%rbp),%ebx
cmp    $0x3,%ebx
jl     1254 <main+0x124>
lea    -0x2(%rbx),%rsi
add    $0xfffffffffffffffd,%rbx
mov    %esi,%eax
and    $0x3,%eax
mov    $0x2,%edi
mov    %r15d,%edx
mov    %r15d,%ecx
cmp    $0x3,%rbx
jb     122d <main+0xfd>
and    $0xfffffffffffffffc,%rsi
neg    %rsi
mov    $0x2,%edi
mov    %r15d,%edx
mov    %r15d,%ecx
nopl   0x0(%rax)
add    %edx,%ecx
mov    %ecx,(%r12,%rdi,4)
add    %ecx,%edx
mov    %edx,0x4(%r12,%rdi,4)
add    %edx,%ecx
mov    %ecx,0x8(%r12,%rdi,4)
add    %ecx,%edx
mov    %edx,0xc(%r12,%rdi,4)
lea    (%rsi,%rdi,1),%rbx
add    $0x4,%rbx
add    $0x4,%rdi
cmp    $0x2,%rbx
jne    1200 <main+0xd0>
test   %rax,%rax
je     1254 <main+0x124>
lea    (%r12,%rdi,4),%rsi
xor    %edi,%edi
nopl   0x0(%rax,%rax,1)
mov    %edx,%ebx
add    %edx,%ecx
mov    %ecx,(%rsi,%rdi,4)
add    $0x1,%rdi
mov    %ecx,%edx
mov    %ebx,%ecx
cmp    %rdi,%rax
jne    1240 <main+0x110>
lea    0xde5(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,-0x24(%rbp)
jle    12ab <main+0x17b>
lea    0xdee(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x2,-0x24(%rbp)
jl     12ab <main+0x17b>
mov    $0x1,%ebx
lea    0xdd2(%rip),%r15
xchg   %ax,%ax
mov    (%r12,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq -0x24(%rbp),%rax
cmp    %rax,%rbx
jl     1290 <main+0x160>
mov    %r14,%rsp
xor    %eax,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"===== Exercise 8 =====\0A\00"
@.str.1 = [20 x i8] c"FIBONACCI NUMBERS!\0A\00"
@.str.2 = [27 x i8] c"Enter the first number. : \00"
@.str.3 = [3 x i8] c"%i\00"
@.str.4 = [34 x i8] c"How many numbers will be shown?: \00"
@.str.5 = [32 x i8] c"--> %i First Fibonacci Numbers\0A\00"
@.str.6 = [4 x i8] c"%i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%18 = load i32, i32* %7
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %8
%21 = alloca i32, i64 %19
store i64 %19, i64* %9
%22 = load i32, i32* %6
%23 = getelementptr inbounds i32, i32* %21, i64 0
store i32 %22, i32* %23
%24 = load i32, i32* %6
%25 = getelementptr inbounds i32, i32* %21, i64 1
store i32 %24, i32* %25
store i32 2, i32* %10
br label %26
26: ; preds = %45, %2
%27 = load i32, i32* %10
%28 = load i32, i32* %7
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %48
30: ; preds = %26
%31 = load i32, i32* %10
%32 = sub nsw i32 %31, 2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %21, i64 %33
%35 = load i32, i32* %34
%36 = load i32, i32* %10
%37 = sub nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %21, i64 %38
%40 = load i32, i32* %39
%41 = add nsw i32 %35, %40
%42 = load i32, i32* %10
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %21, i64 %43
store i32 %41, i32* %44
br label %45
45: ; preds = %30
%46 = load i32, i32* %10
%47 = add nsw i32 %46, 1
store i32 %47, i32* %10
br label %26
48: ; preds = %26
%49 = load i32, i32* %6
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %49)
store i32 0, i32* %11
br label %51
51: ; preds = %61, %48
%52 = load i32, i32* %11
%53 = load i32, i32* %7
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %64
55: ; preds = %51
%56 = load i32, i32* %11
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32, i32* %21, i64 %57
%59 = load i32, i32* %58
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %59)
br label %61
61: ; preds = %55
%62 = load i32, i32* %11
%63 = add nsw i32 %62, 1
store i32 %63, i32* %11
br label %51
64: ; preds = %51
store i32 0, i32* %3
%65 = load i8*, i8** %8
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@.str.2 = [27 x i8] c"Enter the first number. : \00"
@.str.3 = [3 x i8] c"%i\00"
@.str.4 = [34 x i8] c"How many numbers will be shown?: \00"
@.str.5 = [32 x i8] c"--> %i First Fibonacci Numbers\0A\00"
@.str.6 = [4 x i8] c"%i\0A\00"
@str = [23 x i8] c"===== Exercise 8 =====\00"
@str.7 = [19 x i8] c"FIBONACCI NUMBERS!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%11 = bitcast i32* %4 to i8*
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%13 = load i32, i32* %4
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
%16 = alloca i32, i64 %14
%17 = load i32, i32* %3
store i32 %17, i32* %16
%18 = getelementptr inbounds i32, i32* %16, i64 1
store i32 %17, i32* %18
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 2
br i1 %20, label %21, label %44
21: ; preds = %2
%22 = zext i32 %19 to i64
%23 = add nsw i64 %22, -2
%24 = add nsw i64 %22, -3
%25 = and i64 %23, 3
%26 = icmp ult i64 %24, 3
br i1 %26, label %29, label %27
27: ; preds = %21
%28 = and i64 %23, -4
br label %52
29: ; preds = %52, %21
%30 = phi i32 [ %17, %21 ], [ %66, %52 ]
%31 = phi i32 [ %17, %21 ], [ %63, %52 ]
%32 = phi i64 [ 2, %21 ], [ %68, %52 ]
%33 = icmp eq i64 %25, 0
br i1 %33, label %44, label %34
34: ; preds = %29, %34
%35 = phi i32 [ %39, %34 ], [ %30, %29 ]
%36 = phi i32 [ %35, %34 ], [ %31, %29 ]
%37 = phi i64 [ %41, %34 ], [ %32, %29 ]
%38 = phi i64 [ %42, %34 ], [ 0, %29 ]
%39 = add nsw i32 %35, %36
%40 = getelementptr inbounds i32, i32* %16, i64 %37
store i32 %39, i32* %40
%41 = add nuw nsw i64 %37, 1
%42 = add i64 %38, 1
%43 = icmp eq i64 %42, %25
br i1 %43, label %44, label %34
44: ; preds = %29, %34, %2
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i32 %17)
%46 = load i32, i32* %4
%47 = icmp sgt i32 %46, 0
br i1 %47, label %48, label %71
48: ; preds = %44
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %17)
%50 = load i32, i32* %4
%51 = icmp sgt i32 %50, 1
br i1 %51, label %72, label %71
52: ; preds = %52, %27
%53 = phi i32 [ %17, %27 ], [ %66, %52 ]
%54 = phi i32 [ %17, %27 ], [ %63, %52 ]
%55 = phi i64 [ 2, %27 ], [ %68, %52 ]
%56 = phi i64 [ 0, %27 ], [ %69, %52 ]
%57 = add nsw i32 %53, %54
%58 = getelementptr inbounds i32, i32* %16, i64 %55
store i32 %57, i32* %58
%59 = or i64 %55, 1
%60 = add nsw i32 %57, %53
%61 = getelementptr inbounds i32, i32* %16, i64 %59
store i32 %60, i32* %61
%62 = add nuw nsw i64 %55, 2
%63 = add nsw i32 %60, %57
%64 = getelementptr inbounds i32, i32* %16, i64 %62
store i32 %63, i32* %64
%65 = add nuw nsw i64 %55, 3
%66 = add nsw i32 %63, %60
%67 = getelementptr inbounds i32, i32* %16, i64 %65
store i32 %66, i32* %67
%68 = add nuw nsw i64 %55, 4
%69 = add i64 %56, 4
%70 = icmp eq i64 %69, %28
br i1 %70, label %29, label %52
71: ; preds = %72, %48, %44
ret i32 0
72: ; preds = %48, %72
%73 = phi i64 [ %77, %72 ], [ 1, %48 ]
%74 = getelementptr inbounds i32, i32* %16, i64 %73
%75 = load i32, i32* %74
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %75)
%77 = add nuw nsw i64 %73, 1
%78 = load i32, i32* %4
%79 = sext i32 %78 to i64
%80 = icmp slt i64 %77, %79
br i1 %80, label %72, label %71
}