#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 fibonacci_search(int *, int, int);
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  int a[20] = {5, 15, 19, 20, 25, 31, 38, 41, 45, 49, 52, 55, 57};
  int k = 41;
  int pos = fibonacci_search(a, k, 13);
  if (pos != -1)
    printf("element %d is found in the %d location\n", k, pos + 1);
  else
    printf("Element was not found in the array:%d\n", k);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x50,%edx
call   1050 <memcpy@plt>
movl   $0x29,-0x64(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x64(%rbp),%esi
mov    $0xd,%edx
call   1040 <fibonacci_search@plt>
mov    %eax,-0x68(%rbp)
cmpl   $0xffffffff,-0x68(%rbp)
je     1195 <main+0x65>
mov    -0x64(%rbp),%esi
mov    -0x68(%rbp),%edx
add    $0x1,%edx
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a6 <main+0x76>
mov    -0x64(%rbp),%esi
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x58,%rsp
movaps 0xf15(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xef9(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xedd(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xec1(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea5(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x29,%esi
mov    $0xd,%edx
call   1040 <fibonacci_search@plt>
cmp    $0xffffffff,%eax
je     1190 <main+0x70>
add    $0x1,%eax
lea    0xed0(%rip),%rdi
mov    $0x29,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11a3 <main+0x83>
lea    0xee1(%rip),%rdi
mov    $0x29,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
ret

LLVM IR (-O0):
@__const.main.a = [20 x i32] [i32 5, i32 15, i32 19, i32 20, i32 25, i32 31, i32 38, i32 41, i32 45, i32 49, i32 52, i32 55, i32 57, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0]
@.str = [40 x i8] c"element %d is found in the %d location\0A\00"
@.str.1 = [39 x i8] c"Element was not found in the array:%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [20 x i32]* %2 to i8*
store i32 41, i32* %3
%6 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%7 = load i32, i32* %3
%8 = call i32 @fibonacci_search(i32* %6, i32 %7, i32 13)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, -1
br i1 %10, label %11, label %16
11: ; preds = %0
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 1
%15 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %14)
br label %19
16: ; preds = %0
%17 = load i32, i32* %3
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %16, %11
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [20 x i32] [i32 5, i32 15, i32 19, i32 20, i32 25, i32 31, i32 38, i32 41, i32 45, i32 49, i32 52, i32 55, i32 57, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0]
@.str = [40 x i8] c"element %d is found in the %d location\0A\00"
@.str.1 = [39 x i8] c"Element was not found in the array:%d\0A\00"
define i32 @main() {
%1 = alloca [20 x i32]
%2 = bitcast [20 x i32]* %1 to i8*
%3 = getelementptr inbounds [20 x i32], [20 x i32]* %1, i64 0, i64 0
%4 = call i32 @fibonacci_search(i32* %3, i32 41, i32 13)
%5 = icmp eq i32 %4, -1
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = add nuw nsw i32 %4, 1
%8 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 41, i32 %7)
br label %11
9: ; preds = %0
%10 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 41)
br label %11
11: ; preds = %9, %6
ret i32 0
}