#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*/ clrscr();
int fib(int);
int /*<<< orphan*/ getch();
int /*<<< orphan*/ printf(char *, ...);
int rfibsearch(int *, int, int, int, int, int);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int n, a[50], i, key, loc, p, q, r, m, fk;
  clrscr();
  printf("\nenter number elements to be entered");
  scanf("%d", &n);
  printf("enter elements");
  for (i = 1; i <= n; i++)
    scanf("%d", &a[i]);
  printf("enter the key element");
  scanf("%d", &key);
  fk = fib(n + 1);
  p = fib(fk);
  q = fib(p);
  r = fib(q);
  m = (n + 1) - (p + q);
  if (key > a[p])
    p = p + m;
  loc = rfibsearch(a, n, p, q, r, key);
  if (loc == 0)
    printf("key is not found");
  else
    printf("%d is found at location %d", key, loc);
  getch();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    $0x0,%al
call   1030 <clrscr@plt>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeec(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0xd4(%rbp)
mov    -0xd4(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11ec <main+0x8c>
movslq -0xd4(%rbp),%rax
lea    -0xd0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xea0(%rip),%rdi
call   1060 <scanf@plt>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    11a8 <main+0x48>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe72(%rip),%rdi
lea    -0xd8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x4(%rbp),%edi
add    $0x1,%edi
call   1080 <fib@plt>
mov    %eax,-0xf0(%rbp)
mov    -0xf0(%rbp),%edi
call   1080 <fib@plt>
mov    %eax,-0xe0(%rbp)
mov    -0xe0(%rbp),%edi
call   1080 <fib@plt>
mov    %eax,-0xe4(%rbp)
mov    -0xe4(%rbp),%edi
call   1080 <fib@plt>
mov    %eax,-0xe8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    -0xe0(%rbp),%ecx
add    -0xe4(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0xec(%rbp)
mov    -0xd8(%rbp),%eax
movslq -0xe0(%rbp),%rcx
cmp    -0xd0(%rbp,%rcx,4),%eax
jle    1297 <main+0x137>
mov    -0xe0(%rbp),%eax
add    -0xec(%rbp),%eax
mov    %eax,-0xe0(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0xe0(%rbp),%edx
mov    -0xe4(%rbp),%ecx
mov    -0xe8(%rbp),%r8d
mov    -0xd8(%rbp),%r9d
call   1050 <rfibsearch@plt>
mov    %eax,-0xdc(%rbp)
cmpl   $0x0,-0xdc(%rbp)
jne    12e6 <main+0x186>
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1300 <main+0x1a0>
mov    -0xd8(%rbp),%esi
mov    -0xdc(%rbp),%edx
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <getch@plt>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xe0,%rsp
xor    %eax,%eax
call   1030 <clrscr@plt>
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeec(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
lea    0xe8d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11dd <main+0x7d>
lea    0x14(%rsp),%rbx
xor    %ebp,%ebp
lea    0xebf(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
movslq 0x8(%rsp),%rax
add    $0x1,%rbp
add    $0x4,%rbx
cmp    %rax,%rbp
jl     11c0 <main+0x60>
lea    0xe50(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe81(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x8(%rsp),%edi
add    $0x1,%edi
call   1080 <fib@plt>
mov    %eax,%edi
call   1080 <fib@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1080 <fib@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1080 <fib@plt>
mov    0xc(%rsp),%r9d
movslq %ebx,%rdx
mov    0x8(%rsp),%esi
mov    %esi,%ecx
sub    %ebp,%ecx
add    $0x1,%ecx
cmp    0x10(%rsp,%rdx,4),%r9d
cmovg  %ecx,%edx
lea    0x10(%rsp),%rdi
mov    %ebp,%ecx
mov    %eax,%r8d
call   1050 <rfibsearch@plt>
test   %eax,%eax
je     1265 <main+0x105>
mov    0xc(%rsp),%esi
lea    0xe01(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1273 <main+0x113>
lea    0xdde(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <getch@plt>
add    $0xe0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"\0Aenter number elements to be entered\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"enter elements\00"
@.str.3 = [22 x i8] c"enter the key element\00"
@.str.4 = [17 x i8] c"key is not found\00"
@.str.5 = [27 x i8] c"%d is found at location %d\00"
define void @main() {
%1 = alloca i32
%2 = alloca [50 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = call i32 (...) @clrscr()
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %15
15: ; preds = %24, %0
%16 = load i32, i32* %3
%17 = load i32, i32* %1
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %22)
br label %24
24: ; preds = %19
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %15
27: ; preds = %15
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%30 = load i32, i32* %1
%31 = add nsw i32 %30, 1
%32 = call i32 @fib(i32 %31)
store i32 %32, i32* %10
%33 = load i32, i32* %10
%34 = call i32 @fib(i32 %33)
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = call i32 @fib(i32 %35)
store i32 %36, i32* %7
%37 = load i32, i32* %7
%38 = call i32 @fib(i32 %37)
store i32 %38, i32* %8
%39 = load i32, i32* %1
%40 = add nsw i32 %39, 1
%41 = load i32, i32* %6
%42 = load i32, i32* %7
%43 = add nsw i32 %41, %42
%44 = sub nsw i32 %40, %43
store i32 %44, i32* %9
%45 = load i32, i32* %4
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = icmp sgt i32 %45, %49
br i1 %50, label %51, label %55
51: ; preds = %27
%52 = load i32, i32* %6
%53 = load i32, i32* %9
%54 = add nsw i32 %52, %53
store i32 %54, i32* %6
br label %55
55: ; preds = %51, %27
%56 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%57 = load i32, i32* %1
%58 = load i32, i32* %6
%59 = load i32, i32* %7
%60 = load i32, i32* %8
%61 = load i32, i32* %4
%62 = call i32 @rfibsearch(i32* %56, i32 %57, i32 %58, i32 %59, i32 %60, i32 %61)
store i32 %62, i32* %5
%63 = load i32, i32* %5
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %55
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %71
67: ; preds = %55
%68 = load i32, i32* %4
%69 = load i32, i32* %5
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %68, i32 %69)
br label %71
71: ; preds = %67, %65
%72 = call i32 (...) @getch()
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"\0Aenter number elements to be entered\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"enter elements\00"
@.str.3 = [22 x i8] c"enter the key element\00"
@.str.4 = [17 x i8] c"key is not found\00"
@.str.5 = [27 x i8] c"%d is found at location %d\00"
define void @main() {
%1 = alloca i32
%2 = alloca [50 x i32]
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast [50 x i32]* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (...) @clrscr()
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 1
br i1 %12, label %21, label %13
13: ; preds = %0, %13
%14 = phi i64 [ %17, %13 ], [ 1, %0 ]
%15 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %15)
%17 = add nuw nsw i64 %14, 1
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %14, %19
br i1 %20, label %13, label %21
21: ; preds = %13, %0
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%24 = load i32, i32* %1
%25 = add nsw i32 %24, 1
%26 = call i32 @fib(i32 %25)
%27 = call i32 @fib(i32 %26)
%28 = call i32 @fib(i32 %27)
%29 = call i32 @fib(i32 %28)
%30 = load i32, i32* %3
%31 = sext i32 %27 to i64
%32 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = icmp sgt i32 %30, %33
%35 = load i32, i32* %1
%36 = sub i32 1, %28
%37 = add i32 %36, %35
%38 = select i1 %34, i32 %37, i32 %27
%39 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%40 = call i32 @rfibsearch(i32* %39, i32 %35, i32 %38, i32 %28, i32 %29, i32 %30)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %21
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %47
44: ; preds = %21
%45 = load i32, i32* %3
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 %45, i32 %40)
br label %47
47: ; preds = %44, %42
%48 = call i32 (...) @getch()
ret void
}