#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*/ assert(int);
int linear_search(int *, int, int /*<<< orphan*/, int);
int main() {
  int test_array[10] = {9, 2, 3, 5, 8, 7, 13, 17, 23, 48};
  for (int i = 0; i < 10; i++) {
    assert(i == linear_search(test_array, test_array[i], 0, 10));
  }
  assert(-1 == linear_search(test_array, 81, 0, 10));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    11a5 <main+0x75>
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
xor    %edx,%edx
mov    $0xa,%ecx
call   1030 <linear_search@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    115b <main+0x2b>
lea    -0x30(%rbp),%rdi
mov    $0x51,%esi
xor    %edx,%edx
mov    $0xa,%ecx
call   1030 <linear_search@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    0xef4(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xed8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xebc(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %edx,%edx
mov    $0xa,%ecx
call   1030 <linear_search@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %edx,%edx
mov    $0xa,%ecx
call   1030 <linear_search@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1040 <assert@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %edx,%edx
mov    $0xa,%ecx
call   1030 <linear_search@plt>
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1040 <assert@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %edx,%edx
mov    $0xa,%ecx
call   1030 <linear_search@plt>
xor    %edi,%edi
cmp    $0x3,%eax
sete   %dil
call   1040 <assert@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %edx,%edx
mov    $0xa,%ecx
call   1030 <linear_search@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1040 <assert@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %edx,%edx
mov    $0xa,%ecx
call   1030 <linear_search@plt>
xor    %edi,%edi
cmp    $0x5,%eax
sete   %dil
call   1040 <assert@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %edx,%edx
mov    $0xa,%ecx
call   1030 <linear_search@plt>
xor    %edi,%edi
cmp    $0x6,%eax
sete   %dil
call   1040 <assert@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %edx,%edx
mov    $0xa,%ecx
call   1030 <linear_search@plt>
xor    %edi,%edi
cmp    $0x7,%eax
sete   %dil
call   1040 <assert@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %edx,%edx
mov    $0xa,%ecx
call   1030 <linear_search@plt>
xor    %edi,%edi
cmp    $0x8,%eax
sete   %dil
call   1040 <assert@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %edx,%edx
mov    $0xa,%ecx
call   1030 <linear_search@plt>
xor    %edi,%edi
cmp    $0x9,%eax
sete   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    $0x51,%esi
xor    %edx,%edx
mov    $0xa,%ecx
call   1030 <linear_search@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.test_array = [10 x i32] [i32 9, i32 2, i32 3, i32 5, i32 8, i32 7, i32 13, i32 17, i32 23, i32 48]
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [10 x i32]* %2 to i8*
store i32 0, i32* %3
br label %5
5: ; preds = %19, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 10
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = load i32, i32* %3
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = call i32 @linear_search(i32* %10, i32 %14, i32 0, i32 10)
%16 = icmp eq i32 %9, %15
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
br label %19
19: ; preds = %8
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %5
22: ; preds = %5
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%24 = call i32 @linear_search(i32* %23, i32 81, i32 0, i32 10)
%25 = icmp eq i32 -1, %24
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
ret i32 0
}

LLVM IR (-O2):
@__const.main.test_array = [10 x i32] [i32 9, i32 2, i32 3, i32 5, i32 8, i32 7, i32 13, i32 17, i32 23, i32 48]
define i32 @main() {
%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 @linear_search(i32* %3, i32 9, i32 0, i32 10)
%5 = icmp eq i32 %4, 0
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%9 = load i32, i32* %8
%10 = call i32 @linear_search(i32* %3, i32 %9, i32 0, i32 10)
%11 = icmp eq i32 %10, 1
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%15 = load i32, i32* %14
%16 = call i32 @linear_search(i32* %3, i32 %15, i32 0, i32 10)
%17 = icmp eq i32 %16, 2
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%21 = load i32, i32* %20
%22 = call i32 @linear_search(i32* %3, i32 %21, i32 0, i32 10)
%23 = icmp eq i32 %22, 3
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%27 = load i32, i32* %26
%28 = call i32 @linear_search(i32* %3, i32 %27, i32 0, i32 10)
%29 = icmp eq i32 %28, 4
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%33 = load i32, i32* %32
%34 = call i32 @linear_search(i32* %3, i32 %33, i32 0, i32 10)
%35 = icmp eq i32 %34, 5
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%39 = load i32, i32* %38
%40 = call i32 @linear_search(i32* %3, i32 %39, i32 0, i32 10)
%41 = icmp eq i32 %40, 6
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%45 = load i32, i32* %44
%46 = call i32 @linear_search(i32* %3, i32 %45, i32 0, i32 10)
%47 = icmp eq i32 %46, 7
%48 = zext i1 %47 to i32
%49 = call i32 @assert(i32 %48)
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%51 = load i32, i32* %50
%52 = call i32 @linear_search(i32* %3, i32 %51, i32 0, i32 10)
%53 = icmp eq i32 %52, 8
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
%56 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
%57 = load i32, i32* %56
%58 = call i32 @linear_search(i32* %3, i32 %57, i32 0, i32 10)
%59 = icmp eq i32 %58, 9
%60 = zext i1 %59 to i32
%61 = call i32 @assert(i32 %60)
%62 = call i32 @linear_search(i32* %3, i32 81, i32 0, i32 10)
%63 = icmp eq i32 %62, -1
%64 = zext i1 %63 to i32
%65 = call i32 @assert(i32 %64)
ret i32 0
}