#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*/ printf(char *, int, int);
int unorderedLinearSearch(int *, int, int);
void unorderedLinearSearch_test() {
  int n, data, A[10] = {3, 6, 19, 25, 33, 39, 55, 78, 99, 100};
  n = 10;
  data = 20;
  printf("\nElement %d is at location: %d (-1 indicates not present in array)",
         data, unorderedLinearSearch(A, n, data));
  data = 39;
  printf("\nElement %d is at location: %d (-1 indicates not present in array)",
         data, unorderedLinearSearch(A, n, data));
}


x86 assembly (clang, -O0):
<unorderedLinearSearch_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x30(%rbp),%rdi
lea    0xebd(%rip),%rsi
mov    $0x28,%edx
call   1050 <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   1030 <unorderedLinearSearch@plt>
mov    -0x38(%rbp),%esi
mov    %eax,%edx
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
movl   $0x27,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1030 <unorderedLinearSearch@plt>
mov    -0x34(%rbp),%esi
mov    %eax,%edx
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unorderedLinearSearch_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   1030 <unorderedLinearSearch@plt>
lea    0xec2(%rip),%rbx
mov    %rbx,%rdi
mov    $0x14,%esi
mov    %eax,%edx
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
mov    $0x27,%edx
call   1030 <unorderedLinearSearch@plt>
mov    %rbx,%rdi
mov    $0x27,%esi
mov    %eax,%edx
call   1040 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.unorderedLinearSearch_test.A = [10 x i32] [i32 3, i32 6, i32 19, i32 25, i32 33, i32 39, i32 55, i32 78, i32 99, i32 100]
@.str = [67 x i8] c"\0AElement %d is at location: %d (-1 indicates not present in array)\00"
define void @unorderedLinearSearch_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 @unorderedLinearSearch(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 39, 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 @unorderedLinearSearch(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.unorderedLinearSearch_test.A = [10 x i32] [i32 3, i32 6, i32 19, i32 25, i32 33, i32 39, i32 55, i32 78, i32 99, i32 100]
@.str = [67 x i8] c"\0AElement %d is at location: %d (-1 indicates not present in array)\00"
define void @unorderedLinearSearch_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 @unorderedLinearSearch(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 @unorderedLinearSearch(i32* %3, i32 10, i32 39)
%7 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i32 39, i32 %6)
ret void
}