#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 */
typedef int /*<<< orphan*/ data;

/* Variables and functions */
int fibsrch(int *, int, int);
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  int data[] = {1,  4,  5,  7,  9,  11, 13, 16, 18, 20, 25, 27,
                30, 32, 33, 36, 39, 41, 44, 47, 51, 53, 55};
  int i, x, n;
  x = 30;
  n = sizeof(data) / sizeof(int);
  i = fibsrch(data, n, x);
  if (i >= 0)
    printf("%d found at index %d\n", x, i);
  else
    printf("%d was not found\n", x);
  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    $0x5c,%edx
call   1050 <memcpy@plt>
movl   $0x1e,-0x68(%rbp)
movl   $0x17,-0x6c(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x6c(%rbp),%esi
mov    -0x68(%rbp),%edx
call   1030 <fibsrch@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jl     1197 <main+0x67>
mov    -0x68(%rbp),%esi
mov    -0x64(%rbp),%edx
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a8 <main+0x78>
mov    -0x68(%rbp),%esi
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x68,%rsp
movups 0xf21(%rip),%xmm0
movups %xmm0,0x4c(%rsp)
movaps 0xf09(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeed(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xed1(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb5(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe99(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0x17,%esi
mov    $0x1e,%edx
call   1030 <fibsrch@plt>
test   %eax,%eax
js     1198 <main+0x78>
lea    0xed4(%rip),%rdi
mov    $0x1e,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ab <main+0x8b>
lea    0xed3(%rip),%rdi
mov    $0x1e,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
ret

LLVM IR (-O0):
@__const.main.data = [23 x i32] [i32 1, i32 4, i32 5, i32 7, i32 9, i32 11, i32 13, i32 16, i32 18, i32 20, i32 25, i32 27, i32 30, i32 32, i32 33, i32 36, i32 39, i32 41, i32 44, i32 47, i32 51, i32 53, i32 55]
@.str = [22 x i8] c"%d found at index %d\0A\00"
@.str.1 = [18 x i8] c"%d was not found\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [23 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [23 x i32]* %2 to i8*
store i32 30, i32* %4
store i32 23, i32* %5
%7 = getelementptr inbounds [23 x i32], [23 x i32]* %2, i64 0, i64 0
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = call i32 @fibsrch(i32* %7, i32 %8, i32 %9)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %0
%14 = load i32, i32* %4
%15 = load i32, i32* %3
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %15)
br label %20
17: ; preds = %0
%18 = load i32, i32* %4
%19 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %17, %13
ret i32 0
}

LLVM IR (-O2):
@__const.main.data = [23 x i32] [i32 1, i32 4, i32 5, i32 7, i32 9, i32 11, i32 13, i32 16, i32 18, i32 20, i32 25, i32 27, i32 30, i32 32, i32 33, i32 36, i32 39, i32 41, i32 44, i32 47, i32 51, i32 53, i32 55]
@.str = [22 x i8] c"%d found at index %d\0A\00"
@.str.1 = [18 x i8] c"%d was not found\0A\00"
define i32 @main() {
%1 = alloca [23 x i32]
%2 = bitcast [23 x i32]* %1 to i8*
%3 = getelementptr inbounds [23 x i32], [23 x i32]* %1, i64 0, i64 0
%4 = call i32 @fibsrch(i32* %3, i32 23, i32 30)
%5 = icmp sgt i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 30, i32 %4)
br label %10
8: ; preds = %0
%9 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 30)
br label %10
10: ; preds = %8, %6
ret i32 0
}