#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 EXIT_SUCCESS;
int /*<<< orphan*/ fill_with_random_integers(int *, int);
int get_random_int(int, int);
int /*<<< orphan*/ print_int_vector(int *, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ search(int, int *, int);
int main(int argc, char **argv) {
  int haystack[32];
  fill_with_random_integers(haystack, 32);
  int needle = get_random_int(100, 0);
  int position = get_random_int(32, 0);
  haystack[position] = needle;
  printf("%i[%i]::%s\n", needle, position,
         search(needle, haystack, 32) ? "True" : "False");
  print_int_vector(haystack, 32);
  printf("\n");
  needle = get_random_int(100, 32 + 1);
  for (int i = 0; i < 32; i++)
    haystack[i] = i;
  printf("%i[%i]::%s\n", needle, position,
         search(needle, haystack, 32) ? "True" : "False");
  print_int_vector(haystack, 32);
  printf("\n");
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
mov    $0x20,%esi
call   1030 <fill_with_random_integers@plt>
mov    $0x64,%edi
xor    %esi,%esi
call   1040 <get_random_int@plt>
mov    %eax,-0x94(%rbp)
mov    $0x20,%edi
xor    %esi,%esi
call   1040 <get_random_int@plt>
mov    %eax,-0x98(%rbp)
mov    -0x94(%rbp),%ecx
movslq -0x98(%rbp),%rax
mov    %ecx,-0x90(%rbp,%rax,4)
mov    -0x94(%rbp),%eax
mov    %eax,-0xa4(%rbp)
mov    -0x98(%rbp),%eax
mov    %eax,-0xa0(%rbp)
mov    -0x94(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0x20,%edx
call   1070 <search@plt>
mov    -0xa4(%rbp),%esi
mov    -0xa0(%rbp),%edx
mov    %rax,%rdi
lea    0xe1a(%rip),%rcx
lea    0xe0e(%rip),%rax
cmp    $0x0,%rdi
cmovne %rax,%rcx
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    $0x20,%esi
call   1060 <print_int_vector@plt>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x64,%edi
mov    $0x21,%esi
call   1040 <get_random_int@plt>
mov    %eax,-0x94(%rbp)
movl   $0x0,-0x9c(%rbp)
cmpl   $0x20,-0x9c(%rbp)
jge    1287 <main+0x137>
mov    -0x9c(%rbp),%ecx
movslq -0x9c(%rbp),%rax
mov    %ecx,-0x90(%rbp,%rax,4)
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
jmp    1252 <main+0x102>
mov    -0x94(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0x98(%rbp),%eax
mov    %eax,-0xa8(%rbp)
mov    -0x94(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0x20,%edx
call   1070 <search@plt>
mov    -0xac(%rbp),%esi
mov    -0xa8(%rbp),%edx
mov    %rax,%rdi
lea    0xd45(%rip),%rcx
lea    0xd39(%rip),%rax
cmp    $0x0,%rdi
cmovne %rax,%rcx
lea    0xd1e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    $0x20,%esi
call   1060 <print_int_vector@plt>
lea    0xd09(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2cd1(%rip),%rax
mov    (%rax),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x20,%esi
call   1030 <fill_with_random_integers@plt>
mov    $0x64,%edi
xor    %esi,%esi
call   1050 <get_random_int@plt>
mov    %eax,%ebp
mov    $0x20,%edi
xor    %esi,%esi
call   1050 <get_random_int@plt>
movslq %eax,%r15
mov    %ebp,(%rsp,%r15,4)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x20,%edx
call   1080 <search@plt>
test   %rax,%rax
lea    0xed6(%rip),%r13
lea    0xeca(%rip),%rbx
mov    %rbx,%rcx
cmove  %r13,%rcx
lea    0xeb0(%rip),%r12
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x20,%esi
call   1070 <print_int_vector@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    $0x64,%edi
mov    $0x21,%esi
call   1050 <get_random_int@plt>
mov    %eax,%ebp
movaps 0xdf2(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xdf7(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xdfb(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xdff(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe03(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe07(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe0b(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe0f(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x20,%edx
call   1080 <search@plt>
test   %rax,%rax
cmove  %r13,%rbx
mov    %r12,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x20,%esi
call   1070 <print_int_vector@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x2d34(%rip),%rax
mov    (%rax),%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%i[%i]::%s\0A\00"
@.str.1 = [5 x i8] c"True\00"
@.str.2 = [6 x i8] c"False\00"
@.str.3 = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [32 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%11 = call i32 @fill_with_random_integers(i32* %10, i32 32)
%12 = call i32 @get_random_int(i32 100, i32 0)
store i32 %12, i32* %7
%13 = call i32 @get_random_int(i32 32, i32 0)
store i32 %13, i32* %8
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 %16
store i32 %14, i32* %17
%18 = load i32, i32* %7
%19 = load i32, i32* %8
%20 = load i32, i32* %7
%21 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%22 = call i64 @search(i32 %20, i32* %21, i32 32)
%23 = icmp ne i64 %22, 0
%24 = zext i1 %23 to i64
%25 = select i1 %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19, i8* %25)
%27 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%28 = call i32 @print_int_vector(i32* %27, i32 32)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 @get_random_int(i32 100, i32 33)
store i32 %30, i32* %7
store i32 0, i32* %9
br label %31
31: ; preds = %39, %2
%32 = load i32, i32* %9
%33 = icmp slt i32 %32, 32
br i1 %33, label %34, label %42
34: ; preds = %31
%35 = load i32, i32* %9
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 %37
store i32 %35, i32* %38
br label %39
39: ; preds = %34
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %31
42: ; preds = %31
%43 = load i32, i32* %7
%44 = load i32, i32* %8
%45 = load i32, i32* %7
%46 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%47 = call i64 @search(i32 %45, i32* %46, i32 32)
%48 = icmp ne i64 %47, 0
%49 = zext i1 %48 to i64
%50 = select i1 %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %43, i32 %44, i8* %50)
%52 = getelementptr inbounds [32 x i32], [32 x i32]* %6, i64 0, i64 0
%53 = call i32 @print_int_vector(i32* %52, i32 32)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%55 = load i32, i32* @EXIT_SUCCESS
ret i32 %55
}

LLVM IR (-O2):
@.str = [12 x i8] c"%i[%i]::%s\0A\00"
@.str.1 = [5 x i8] c"True\00"
@.str.2 = [6 x i8] c"False\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [32 x i32]
%4 = bitcast [32 x i32]* %3 to i8*
%5 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 0
%6 = call i32 @fill_with_random_integers(i32* %5, i32 32)
%7 = call i32 @get_random_int(i32 100, i32 0)
%8 = call i32 @get_random_int(i32 32, i32 0)
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 %9
store i32 %7, i32* %10
%11 = call i64 @search(i32 %7, i32* %5, i32 32)
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8, i8* %13)
%15 = call i32 @print_int_vector(i32* %5, i32 32)
%16 = call i32 @putchar(i32 10)
%17 = call i32 @get_random_int(i32 100, i32 33)
%18 = bitcast [32 x i32]* %3 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %18
%19 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 4
%20 = bitcast i32* %19 to <4 x i32>*
store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32>* %20
%21 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 8
%22 = bitcast i32* %21 to <4 x i32>*
store <4 x i32> <i32 8, i32 9, i32 10, i32 11>, <4 x i32>* %22
%23 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 12
%24 = bitcast i32* %23 to <4 x i32>*
store <4 x i32> <i32 12, i32 13, i32 14, i32 15>, <4 x i32>* %24
%25 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 16
%26 = bitcast i32* %25 to <4 x i32>*
store <4 x i32> <i32 16, i32 17, i32 18, i32 19>, <4 x i32>* %26
%27 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 20
%28 = bitcast i32* %27 to <4 x i32>*
store <4 x i32> <i32 20, i32 21, i32 22, i32 23>, <4 x i32>* %28
%29 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 24
%30 = bitcast i32* %29 to <4 x i32>*
store <4 x i32> <i32 24, i32 25, i32 26, i32 27>, <4 x i32>* %30
%31 = getelementptr inbounds [32 x i32], [32 x i32]* %3, i64 0, i64 28
%32 = bitcast i32* %31 to <4 x i32>*
store <4 x i32> <i32 28, i32 29, i32 30, i32 31>, <4 x i32>* %32
%33 = call i64 @search(i32 %17, i32* %5, i32 32)
%34 = icmp eq i64 %33, 0
%35 = select i1 %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %8, i8* %35)
%37 = call i32 @print_int_vector(i32* %5, i32 32)
%38 = call i32 @putchar(i32 10)
%39 = load i32, i32* @EXIT_SUCCESS
ret i32 %39
}