#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 *);
void solveFibonacci() {
  int n, i = 0;
  float a = 1, b = 0, fibonacci_number = 0;
  printf("Insert the index of Fibonacci element\n");
  scanf("%d", &n);
  if (n != 0) {
    while (i < n) {
      b = fibonacci_number;
      fibonacci_number = a + b;
      a = b;
      i++;
    }
  } else {
    fibonacci_number = 1;
  }
  printf("Fibonacci(%d) = %f\n", n, fibonacci_number);
}


x86 assembly (clang, -O0):
<solveFibonacci>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x8(%rbp)
movss  0xec9(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeca(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x4(%rbp)
je     11bb <solveFibonacci+0x9b>
jmp    1179 <solveFibonacci+0x59>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b6 <solveFibonacci+0x96>
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1179 <solveFibonacci+0x59>
jmp    11c8 <solveFibonacci+0xa8>
movss  0xe3d(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x4(%rbp),%esi
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe53(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solveFibonacci>:
push   %rax
lea    0xeeb(%rip),%rdi
call   1030 <puts@plt>
lea    0xec8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
je     1172 <solveFibonacci+0x42>
jle    117c <solveFibonacci+0x4c>
lea    -0x1(%rsi),%ecx
mov    %esi,%eax
and    $0x7,%eax
cmp    $0x7,%ecx
jae    1181 <solveFibonacci+0x51>
movss  0xe9b(%rip),%xmm1
xorps  %xmm0,%xmm0
jmp    11c5 <solveFibonacci+0x95>
movsd  0xe86(%rip),%xmm0
jmp    11e6 <solveFibonacci+0xb6>
xorps  %xmm0,%xmm0
jmp    11e6 <solveFibonacci+0xb6>
mov    %esi,%ecx
and    $0xfffffff8,%ecx
movss  0xe7a(%rip),%xmm1
xorps  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
addss  %xmm0,%xmm1
addss  %xmm1,%xmm0
addss  %xmm0,%xmm1
addss  %xmm1,%xmm0
addss  %xmm0,%xmm1
addss  %xmm1,%xmm0
addss  %xmm0,%xmm1
addss  %xmm1,%xmm0
add    $0xfffffff8,%ecx
jne    11a0 <solveFibonacci+0x70>
test   %eax,%eax
je     11e2 <solveFibonacci+0xb2>
nopl   0x0(%rax)
movaps %xmm0,%xmm2
movaps %xmm1,%xmm0
addss  %xmm2,%xmm0
movaps %xmm2,%xmm1
add    $0xffffffff,%eax
jne    11d0 <solveFibonacci+0xa0>
cvtss2sd %xmm0,%xmm0
lea    0xe22(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Insert the index of Fibonacci element\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Fibonacci(%d) = %f\0A\00"
define void @solveFibonacci() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 0, i32* %2
store float 1.000000e+00, float* %3
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 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* %1)
%8 = load i32, i32* %1
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %0
br label %11
11: ; preds = %15, %10
%12 = load i32, i32* %2
%13 = load i32, i32* %1
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load float, float* %5
store float %16, float* %4
%17 = load float, float* %3
%18 = load float, float* %4
%19 = fadd float %17, %18
store float %19, float* %5
%20 = load float, float* %4
store float %20, float* %3
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %11
23: ; preds = %11
br label %25
24: ; preds = %0
store float 1.000000e+00, float* %5
br label %25
25: ; preds = %24, %23
%26 = load i32, i32* %1
%27 = load float, float* %5
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %26, double %28)
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"Fibonacci(%d) = %f\0A\00"
@str = [38 x i8] c"Insert the index of Fibonacci element\00"
define void @solveFibonacci() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 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 eq i32 %5, 0
br i1 %6, label %44, label %7
7: ; preds = %0
%8 = icmp sgt i32 %5, 0
br i1 %8, label %9, label %44
9: ; preds = %7
%10 = add i32 %5, -1
%11 = and i32 %5, 7
%12 = icmp ult i32 %10, 7
br i1 %12, label %29, label %13
13: ; preds = %9
%14 = and i32 %5, -8
br label %15
15: ; preds = %15, %13
%16 = phi float [ 0.000000e+00, %13 ], [ %26, %15 ]
%17 = phi float [ 1.000000e+00, %13 ], [ %25, %15 ]
%18 = phi i32 [ 0, %13 ], [ %27, %15 ]
%19 = fadd float %17, %16
%20 = fadd float %16, %19
%21 = fadd float %19, %20
%22 = fadd float %20, %21
%23 = fadd float %21, %22
%24 = fadd float %22, %23
%25 = fadd float %23, %24
%26 = fadd float %24, %25
%27 = add i32 %18, 8
%28 = icmp eq i32 %27, %14
br i1 %28, label %29, label %15
29: ; preds = %15, %9
%30 = phi float [ undef, %9 ], [ %26, %15 ]
%31 = phi float [ 0.000000e+00, %9 ], [ %26, %15 ]
%32 = phi float [ 1.000000e+00, %9 ], [ %25, %15 ]
%33 = icmp eq i32 %11, 0
br i1 %33, label %41, label %34
34: ; preds = %29, %34
%35 = phi float [ %38, %34 ], [ %31, %29 ]
%36 = phi float [ %35, %34 ], [ %32, %29 ]
%37 = phi i32 [ %39, %34 ], [ 0, %29 ]
%38 = fadd float %36, %35
%39 = add i32 %37, 1
%40 = icmp eq i32 %39, %11
br i1 %40, label %41, label %34
41: ; preds = %34, %29
%42 = phi float [ %30, %29 ], [ %38, %34 ]
%43 = fpext float %42 to double
br label %44
44: ; preds = %41, %7, %0
%45 = phi double [ 1.000000e+00, %0 ], [ 0.000000e+00, %7 ], [ %43, %41 ]
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %5, double %45)
ret void
}