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


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

x86 assembly (clang, -O2):
<test_two_elements>:
push   %rbx
sub    $0x10,%rsp
movabs $0x200000001,%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
xor    %ebx,%ebx
mov    $0x1,%esi
xor    %edx,%edx
mov    $0x1,%ecx
call   1030 <search@plt>
test   %eax,%eax
jne    1198 <test_two_elements+0x88>
lea    0x8(%rsp),%rdi
xor    %ebx,%ebx
mov    $0x2,%esi
xor    %edx,%edx
mov    $0x1,%ecx
call   1030 <search@plt>
cmp    $0x1,%eax
jne    1198 <test_two_elements+0x88>
lea    0x8(%rsp),%rdi
xor    %ebx,%ebx
mov    $0x3,%esi
xor    %edx,%edx
mov    $0x1,%ecx
call   1030 <search@plt>
cmp    $0xffffffff,%eax
jne    1198 <test_two_elements+0x88>
lea    0x8(%rsp),%rdi
mov    $0xffffffff,%esi
xor    %edx,%edx
mov    $0x1,%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_two_elements.array = [2 x i32] [i32 1, i32 2]
define i32 @test_two_elements() {
%1 = alloca [2 x i32]
%2 = bitcast [2 x i32]* %1 to i8*
%3 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%4 = call i32 @search(i32* %3, i32 1, i32 0, i32 1)
%5 = icmp eq i32 0, %4
br i1 %5, label %6, label %18
6: ; preds = %0
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%8 = call i32 @search(i32* %7, i32 2, i32 0, i32 1)
%9 = icmp eq i32 1, %8
br i1 %9, label %10, label %18
10: ; preds = %6
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%12 = call i32 @search(i32* %11, i32 3, i32 0, i32 1)
%13 = icmp eq i32 -1, %12
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%16 = call i32 @search(i32* %15, i32 -1, i32 0, i32 1)
%17 = icmp eq i32 -1, %16
br label %18
18: ; preds = %14, %10, %6, %0
%19 = phi i1 [ false, %10 ], [ false, %6 ], [ false, %0 ], [ %17, %14 ]
%20 = zext i1 %19 to i32
ret i32 %20
}

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