#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 search(int *, int, int /*<<< orphan*/, int);
int test_small_array() {
  int array[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
  return 2 == search(array, 3, 0, 13) && 9 == search(array, 10, 0, 13) &&
         0 == search(array, 1, 0, 13) && 13 == search(array, 14, 0, 13) &&
         -1 == search(array, 15, 0, 13) && -1 == search(array, 0, 0, 13);
}


x86 assembly (clang, -O0):
<test_small_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x40(%rbp),%rdi
lea    0xecd(%rip),%rsi
mov    $0x38,%edx
call   1040 <memcpy@plt>
lea    -0x40(%rbp),%rdi
mov    $0x3,%esi
xor    %edx,%edx
mov    $0xd,%ecx
call   1030 <search@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x2,%ecx
cmp    %edx,%ecx
mov    %al,-0x41(%rbp)
jne    1228 <test_small_array+0x108>
lea    -0x40(%rbp),%rdi
mov    $0xa,%esi
xor    %edx,%edx
mov    $0xd,%ecx
call   1030 <search@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x9,%ecx
cmp    %edx,%ecx
mov    %al,-0x41(%rbp)
jne    1228 <test_small_array+0x108>
lea    -0x40(%rbp),%rdi
mov    $0x1,%esi
xor    %edx,%edx
mov    $0xd,%ecx
call   1030 <search@plt>
mov    %eax,%edx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %edx,%ecx
mov    %al,-0x41(%rbp)
jne    1228 <test_small_array+0x108>
lea    -0x40(%rbp),%rdi
mov    $0xe,%esi
xor    %edx,%edx
mov    $0xd,%ecx
call   1030 <search@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0xd,%ecx
cmp    %edx,%ecx
mov    %al,-0x41(%rbp)
jne    1228 <test_small_array+0x108>
lea    -0x40(%rbp),%rdi
mov    $0xf,%esi
xor    %edx,%edx
mov    $0xd,%ecx
call   1030 <search@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0xffffffff,%ecx
cmp    %edx,%ecx
mov    %al,-0x41(%rbp)
jne    1228 <test_small_array+0x108>
lea    -0x40(%rbp),%rdi
xor    %edx,%edx
mov    $0xd,%ecx
mov    %edx,%esi
call   1030 <search@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_small_array>:
push   %rbx
sub    $0x40,%rsp
mov    0xf14(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xef8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xedc(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xec0(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
xor    %ebx,%ebx
mov    $0x3,%esi
xor    %edx,%edx
mov    $0xd,%ecx
call   1030 <search@plt>
cmp    $0x2,%eax
jne    11e7 <test_small_array+0xd7>
mov    %rsp,%rdi
xor    %ebx,%ebx
mov    $0xa,%esi
xor    %edx,%edx
mov    $0xd,%ecx
call   1030 <search@plt>
cmp    $0x9,%eax
jne    11e7 <test_small_array+0xd7>
mov    %rsp,%rdi
xor    %ebx,%ebx
mov    $0x1,%esi
xor    %edx,%edx
mov    $0xd,%ecx
call   1030 <search@plt>
test   %eax,%eax
jne    11e7 <test_small_array+0xd7>
mov    %rsp,%rdi
xor    %ebx,%ebx
mov    $0xe,%esi
xor    %edx,%edx
mov    $0xd,%ecx
call   1030 <search@plt>
cmp    $0xd,%eax
jne    11e7 <test_small_array+0xd7>
mov    %rsp,%rdi
xor    %ebx,%ebx
mov    $0xf,%esi
xor    %edx,%edx
mov    $0xd,%ecx
call   1030 <search@plt>
cmp    $0xffffffff,%eax
jne    11e7 <test_small_array+0xd7>
mov    %rsp,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    $0xd,%ecx
call   1030 <search@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
sete   %bl
mov    %ebx,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.test_small_array.array = [14 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14]
define i32 @test_small_array() {
%1 = alloca [14 x i32]
%2 = bitcast [14 x i32]* %1 to i8*
%3 = getelementptr inbounds [14 x i32], [14 x i32]* %1, i64 0, i64 0
%4 = call i32 @search(i32* %3, i32 3, i32 0, i32 13)
%5 = icmp eq i32 2, %4
br i1 %5, label %6, label %26
6: ; preds = %0
%7 = getelementptr inbounds [14 x i32], [14 x i32]* %1, i64 0, i64 0
%8 = call i32 @search(i32* %7, i32 10, i32 0, i32 13)
%9 = icmp eq i32 9, %8
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = getelementptr inbounds [14 x i32], [14 x i32]* %1, i64 0, i64 0
%12 = call i32 @search(i32* %11, i32 1, i32 0, i32 13)
%13 = icmp eq i32 0, %12
br i1 %13, label %14, label %26
14: ; preds = %10
%15 = getelementptr inbounds [14 x i32], [14 x i32]* %1, i64 0, i64 0
%16 = call i32 @search(i32* %15, i32 14, i32 0, i32 13)
%17 = icmp eq i32 13, %16
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = getelementptr inbounds [14 x i32], [14 x i32]* %1, i64 0, i64 0
%20 = call i32 @search(i32* %19, i32 15, i32 0, i32 13)
%21 = icmp eq i32 -1, %20
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = getelementptr inbounds [14 x i32], [14 x i32]* %1, i64 0, i64 0
%24 = call i32 @search(i32* %23, i32 0, i32 0, i32 13)
%25 = icmp eq i32 -1, %24
br label %26
26: ; preds = %22, %18, %14, %10, %6, %0
%27 = phi i1 [ false, %18 ], [ false, %14 ], [ false, %10 ], [ false, %6 ], [ false, %0 ], [ %25, %22 ]
%28 = zext i1 %27 to i32
ret i32 %28
}

LLVM IR (-O2):
@__const.test_small_array.array = [14 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14]
define i32 @test_small_array() {
%1 = alloca [14 x i32]
%2 = bitcast [14 x i32]* %1 to i8*
%3 = getelementptr inbounds [14 x i32], [14 x i32]* %1, i64 0, i64 0
%4 = call i32 @search(i32* %3, i32 3, i32 0, i32 13)
%5 = icmp eq i32 %4, 2
br i1 %5, label %6, label %22
6: ; preds = %0
%7 = call i32 @search(i32* %3, i32 10, i32 0, i32 13)
%8 = icmp eq i32 %7, 9
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = call i32 @search(i32* %3, i32 1, i32 0, i32 13)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = call i32 @search(i32* %3, i32 14, i32 0, i32 13)
%14 = icmp eq i32 %13, 13
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = call i32 @search(i32* %3, i32 15, i32 0, i32 13)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = call i32 @search(i32* %3, i32 0, i32 0, i32 13)
%20 = icmp eq i32 %19, -1
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %18, %15, %12, %9, %6, %0
%23 = phi i32 [ 0, %15 ], [ 0, %12 ], [ 0, %9 ], [ 0, %6 ], [ 0, %0 ], [ %21, %18 ]
ret i32 %23
}