#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 interpolationSearch(int *, int, int);
int /*<<< orphan*/ printf(char *, int, int);
void interpolationSearch_test() {
  int n, data, A[10] = {3, 6, 9, 12, 15, 18, 21, 24, 27, 30};
  n = 10;
  data = 20;
  printf("\nElement %d is at location: %d (-1 indicates not present in array)",
         data, interpolationSearch(A, n, data));
  data = 30;
  printf("\nElement %d is at location: %d (-1 indicates not present in array)",
         data, interpolationSearch(A, n, data));
}


x86 assembly (clang, -O0):
<interpolationSearch_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,-0x4(%rbp)
movl   $0x14,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1050 <interpolationSearch@plt>
mov    -0x38(%rbp),%esi
mov    %eax,%edx
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1e,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1050 <interpolationSearch@plt>
mov    -0x34(%rbp),%esi
mov    %eax,%edx
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<interpolationSearch_test>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    0xef2(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeba(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xa,%esi
mov    $0x14,%edx
call   1040 <interpolationSearch@plt>
lea    0xec2(%rip),%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
mov    %eax,%edx
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
mov    $0x1e,%edx
call   1040 <interpolationSearch@plt>
mov    %rbx,%rdi
mov    $0x1e,%esi
mov    %eax,%edx
call   1030 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.interpolationSearch_test.A = [10 x i32] [i32 3, i32 6, i32 9, i32 12, i32 15, i32 18, i32 21, i32 24, i32 27, i32 30]
@.str = [67 x i8] c"\0AElement %d is at location: %d (-1 indicates not present in array)\00"
define void @interpolationSearch_test() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i32]
%4 = bitcast [10 x i32]* %3 to i8*
store i32 10, i32* %1
store i32 20, i32* %2
%5 = load i32, i32* %2
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = call i32 @interpolationSearch(i32* %6, i32 %7, i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %9)
store i32 30, i32* %2
%11 = load i32, i32* %2
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = call i32 @interpolationSearch(i32* %12, i32 %13, i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %15)
ret void
}

LLVM IR (-O2):
@__const.interpolationSearch_test.A = [10 x i32] [i32 3, i32 6, i32 9, i32 12, i32 15, i32 18, i32 21, i32 24, i32 27, i32 30]
@.str = [67 x i8] c"\0AElement %d is at location: %d (-1 indicates not present in array)\00"
define void @interpolationSearch_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 20)
%5 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i32 20, i32 %4)
%6 = call i32 @interpolationSearch(i32* %3, i32 10, i32 30)
%7 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i32 30, i32 %6)
ret void
}