#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*/ array;

/* Variables and functions */
int interpolationSearch(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
void test() {
  int array[10] = {1, 5, 9, 12, 16, 18, 25, 56, 76, 78};
  int n = sizeof(array) / sizeof(array[0]);
  int key = 25;
  int index = interpolationSearch(array, n, key);
  if (index != -1)
    printf("Element found at index %d\n", index);
  else
    printf("EElement not found.\n");
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x30(%rbp),%rdi
lea    0xebd(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
movl   $0xa,-0x34(%rbp)
movl   $0x19,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
call   1050 <interpolationSearch@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
je     118d <test+0x5d>
mov    -0x3c(%rbp),%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119b <test+0x6b>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
sub    $0x28,%rsp
mov    0xee5(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xead(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0xa,%esi
mov    $0x19,%edx
call   1050 <interpolationSearch@plt>
cmp    $0xffffffff,%eax
je     1183 <test+0x53>
lea    0xeb3(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x28,%rsp
ret
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
@__const.test.array = [10 x i32] [i32 1, i32 5, i32 9, i32 12, i32 16, i32 18, i32 25, i32 56, i32 76, i32 78]
@.str = [27 x i8] c"Element found at index %d\0A\00"
@.str.1 = [21 x i8] c"EElement not found.\0A\00"
define void @test() {
%1 = alloca [10 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [10 x i32]* %1 to i8*
store i32 10, i32* %2
store i32 25, i32* %3
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = call i32 @interpolationSearch(i32* %6, i32 %7, i32 %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = load i32, i32* %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %17
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
ret void
}

LLVM IR (-O2):
@__const.test.array = [10 x i32] [i32 1, i32 5, i32 9, i32 12, i32 16, i32 18, i32 25, i32 56, i32 76, i32 78]
@.str = [27 x i8] c"Element found at index %d\0A\00"
@str = [20 x i8] c"EElement not found.\00"
define void @test() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%4 = call i32 @interpolationSearch(i32* %3, i32 10, i32 25)
%5 = icmp eq i32 %4, -1
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %4)
br label %10
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
ret void
}