#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_three_elements() {
  int array[] = {1, 2, 3};
  return 0 == search(array, 1, 0, 2) && 1 == search(array, 2, 0, 2) &&
         2 == search(array, 3, 0, 2) && -1 == search(array, 4, 0, 2) &&
         -1 == search(array, -1, 0, 2);
}


x86 assembly (clang, -O0):
<test_three_elements>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xedf(%rip),%eax
mov    %eax,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
mov    $0x1,%esi
xor    %edx,%edx
mov    $0x2,%ecx
call   1030 <search@plt>
mov    %eax,%edx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %edx,%ecx
mov    %al,-0xd(%rbp)
jne    11ee <test_three_elements+0xde>
lea    -0xc(%rbp),%rdi
mov    $0x2,%ecx
xor    %edx,%edx
mov    %ecx,%esi
call   1030 <search@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %edx,%ecx
mov    %al,-0xd(%rbp)
jne    11ee <test_three_elements+0xde>
lea    -0xc(%rbp),%rdi
mov    $0x3,%esi
xor    %edx,%edx
mov    $0x2,%ecx
call   1030 <search@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x2,%ecx
cmp    %edx,%ecx
mov    %al,-0xd(%rbp)
jne    11ee <test_three_elements+0xde>
lea    -0xc(%rbp),%rdi
mov    $0x4,%esi
xor    %edx,%edx
mov    $0x2,%ecx
call   1030 <search@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0xffffffff,%ecx
cmp    %edx,%ecx
mov    %al,-0xd(%rbp)
jne    11ee <test_three_elements+0xde>
lea    -0xc(%rbp),%rdi
mov    $0xffffffff,%esi
xor    %edx,%edx
mov    $0x2,%ecx
call   1030 <search@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_three_elements>:
push   %rbx
sub    $0x10,%rsp
mov    0xeed(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xeda(%rip),%rax
mov    %rax,(%rsp)
mov    %rsp,%rdi
xor    %ebx,%ebx
mov    $0x1,%esi
xor    %edx,%edx
mov    $0x2,%ecx
call   1030 <search@plt>
test   %eax,%eax
jne    11b1 <test_three_elements+0xa1>
mov    %rsp,%rdi
xor    %ebx,%ebx
mov    $0x2,%esi
xor    %edx,%edx
mov    $0x2,%ecx
call   1030 <search@plt>
cmp    $0x1,%eax
jne    11b1 <test_three_elements+0xa1>
mov    %rsp,%rdi
xor    %ebx,%ebx
mov    $0x3,%esi
xor    %edx,%edx
mov    $0x2,%ecx
call   1030 <search@plt>
cmp    $0x2,%eax
jne    11b1 <test_three_elements+0xa1>
mov    %rsp,%rdi
xor    %ebx,%ebx
mov    $0x4,%esi
xor    %edx,%edx
mov    $0x2,%ecx
call   1030 <search@plt>
cmp    $0xffffffff,%eax
jne    11b1 <test_three_elements+0xa1>
mov    %rsp,%rdi
mov    $0xffffffff,%esi
xor    %edx,%edx
mov    $0x2,%ecx
call   1030 <search@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
sete   %bl
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

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