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


x86 assembly (clang, -O0):
<test_one_element>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0xee2(%rip),%eax
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
mov    $0x1,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <search@plt>
mov    %eax,%edx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %edx,%ecx
mov    %al,-0x5(%rbp)
jne    118b <test_one_element+0x7b>
lea    -0x4(%rbp),%rdi
mov    $0x2,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <search@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0xffffffff,%ecx
cmp    %edx,%ecx
mov    %al,-0x5(%rbp)
jne    118b <test_one_element+0x7b>
lea    -0x4(%rbp),%rdi
mov    $0xffffffff,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <search@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
sete   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

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