#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 */
typedef int /*<<< orphan*/ arr;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int lsearch(int *, int, int);
int main(int argc, char **argv) {
  int arr[] = {1, 2, -100, 100, 200, 500};
  assert(lsearch(arr, sizeof(arr) / sizeof(int), 100) == 3);
  assert(lsearch(arr, sizeof(arr) / sizeof(int), 1) == 0);
  assert(lsearch(arr, sizeof(arr) / sizeof(int), 1000) == -1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x6,%esi
mov    $0x64,%edx
call   1040 <lsearch@plt>
cmp    $0x3,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    -0x30(%rbp),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
call   1040 <lsearch@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    -0x30(%rbp),%rdi
mov    $0x6,%esi
mov    $0x3e8,%edx
call   1040 <lsearch@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    0xee4(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x64,%edx
call   1040 <lsearch@plt>
xor    %edi,%edi
cmp    $0x3,%eax
sete   %dil
call   1030 <assert@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x1,%edx
call   1040 <lsearch@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x3e8,%edx
call   1040 <lsearch@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.arr = [6 x i32] [i32 1, i32 2, i32 -100, i32 100, i32 200, i32 500]
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [6 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = bitcast [6 x i32]* %6 to i8*
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 0
%9 = call i32 @lsearch(i32* %8, i32 6, i32 100)
%10 = icmp eq i32 %9, 3
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 0
%14 = call i32 @lsearch(i32* %13, i32 6, i32 1)
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 0
%19 = call i32 @lsearch(i32* %18, i32 6, i32 1000)
%20 = icmp eq i32 %19, -1
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr = [6 x i32] [i32 1, i32 2, i32 -100, i32 100, i32 200, i32 500]
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x i32]
%4 = bitcast [6 x i32]* %3 to i8*
%5 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%6 = call i32 @lsearch(i32* %5, i32 6, i32 100)
%7 = icmp eq i32 %6, 3
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = call i32 @lsearch(i32* %5, i32 6, i32 1)
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = call i32 @lsearch(i32* %5, i32 6, i32 1000)
%15 = icmp eq i32 %14, -1
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
ret i32 0
}