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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int linear_search(int *, int, int);
int /*<<< orphan*/ printf(char *, int);
void linear_search_test() {
  int empty[] = {};
  int empty_size = sizeof(empty) / sizeof(int);
  int a[] = {1, 3, 4, 8, 6};
  int a_size = sizeof(a) / sizeof(int);
  assert(linear_search(empty, empty_size, 3) == -1);
  assert(linear_search(a, a_size, 3) == 1);
  printf("Should return -1 = %d\n", linear_search(empty, empty_size, 3));
  printf("Should return 1 = %d\n", linear_search(a, a_size, 3));
}


x86 assembly (clang, -O0):
<linear_search_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x8(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb5(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0x5,-0x24(%rbp)
lea    -0x4(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    $0x3,%edx
call   1030 <linear_search@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    $0x3,%edx
call   1030 <linear_search@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x4(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    $0x3,%edx
call   1030 <linear_search@plt>
mov    %eax,%esi
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    $0x3,%edx
call   1030 <linear_search@plt>
mov    %eax,%esi
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<linear_search_test>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    0xed3(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xc(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1030 <linear_search@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1050 <assert@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x3,%edx
call   1030 <linear_search@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1050 <assert@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1030 <linear_search@plt>
lea    0xe6a(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x3,%edx
call   1030 <linear_search@plt>
lea    0xe61(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.linear_search_test.a = [5 x i32] [i32 1, i32 3, i32 4, i32 8, i32 6]
@.str = [23 x i8] c"Should return -1 = %d\0A\00"
@.str.1 = [22 x i8] c"Should return 1 = %d\0A\00"
define void @linear_search_test() {
%1 = alloca [0 x i32]
%2 = alloca i32
%3 = alloca [5 x i32]
%4 = alloca i32
%5 = bitcast [0 x i32]* %1 to i8*
store i32 0, i32* %2
%6 = bitcast [5 x i32]* %3 to i8*
store i32 5, i32* %4
%7 = getelementptr inbounds [0 x i32], [0 x i32]* %1, i64 0, i64 0
%8 = load i32, i32* %2
%9 = call i32 @linear_search(i32* %7, i32 %8, i32 3)
%10 = icmp eq i32 %9, -1
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%14 = load i32, i32* %4
%15 = call i32 @linear_search(i32* %13, i32 %14, i32 3)
%16 = icmp eq i32 %15, 1
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = getelementptr inbounds [0 x i32], [0 x i32]* %1, i64 0, i64 0
%20 = load i32, i32* %2
%21 = call i32 @linear_search(i32* %19, i32 %20, i32 3)
%22 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%24 = load i32, i32* %4
%25 = call i32 @linear_search(i32* %23, i32 %24, i32 3)
%26 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %25)
ret void
}

LLVM IR (-O2):
@__const.linear_search_test.a = [5 x i32] [i32 1, i32 3, i32 4, i32 8, i32 6]
@.str = [23 x i8] c"Should return -1 = %d\0A\00"
@.str.1 = [22 x i8] c"Should return 1 = %d\0A\00"
define void @linear_search_test() {
%1 = alloca [0 x i32]
%2 = alloca [5 x i32]
%3 = bitcast [0 x i32]* %1 to i8*
%4 = bitcast [5 x i32]* %2 to i8*
%5 = getelementptr inbounds [0 x i32], [0 x i32]* %1, i64 0, i64 0
%6 = call i32 @linear_search(i32* %5, i32 0, i32 3)
%7 = icmp eq i32 %6, -1
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%11 = call i32 @linear_search(i32* %10, i32 5, i32 3)
%12 = icmp eq i32 %11, 1
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = call i32 @linear_search(i32* %5, i32 0, i32 3)
%16 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = call i32 @linear_search(i32* %10, i32 5, i32 3)
%18 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %17)
ret void
}