#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 /*<<< orphan*/ printf(char *, int);
int search(int *, int, int);
int main() {
  int i, a[] = {-10, -7, 0, 2, 11, 14, 38};
  for (i = 0; i < 7; i++)
    printf("%d\n", search(a, 7, a[i]));
  printf("%d\n", search(a, 7, -100));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec2(%rip),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x7,-0x8(%rbp)
jge    119c <main+0x7c>
lea    -0x30(%rbp),%rdi
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
mov    $0x7,%esi
call   1040 <search@plt>
mov    %eax,%esi
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1160 <main+0x40>
lea    -0x30(%rbp),%rdi
mov    $0x7,%esi
mov    $0xffffff9c,%edx
call   1040 <search@plt>
mov    %eax,%esi
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movups 0xede(%rip),%xmm0
movups %xmm0,0xc(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x7,%esi
mov    $0xfffffff6,%edx
call   1040 <search@plt>
lea    0xec2(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    $0x7,%esi
call   1040 <search@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x8(%rsp),%edx
mov    %r14,%rdi
mov    $0x7,%esi
call   1040 <search@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0xc(%rsp),%edx
mov    %r14,%rdi
mov    $0x7,%esi
call   1040 <search@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x10(%rsp),%edx
mov    %r14,%rdi
mov    $0x7,%esi
call   1040 <search@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x14(%rsp),%edx
mov    %r14,%rdi
mov    $0x7,%esi
call   1040 <search@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x18(%rsp),%edx
mov    %r14,%rdi
mov    $0x7,%esi
call   1040 <search@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x7,%esi
mov    $0xffffff9c,%edx
call   1040 <search@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.a = [7 x i32] [i32 -10, i32 -7, i32 0, i32 2, i32 11, i32 14, i32 38]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [7 x i32]
store i32 0, i32* %1
%4 = bitcast [7 x i32]* %3 to i8*
store i32 0, i32* %2
br label %5
5: ; preds = %16, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 7
br i1 %7, label %8, label %19
8: ; preds = %5
%9 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 0
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = call i32 @search(i32* %9, i32 7, i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %8
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %5
19: ; preds = %5
%20 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 0
%21 = call i32 @search(i32* %20, i32 7, i32 -100)
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [7 x i32] [i32 -10, i32 -7, i32 0, i32 2, i32 11, i32 14, i32 38]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [7 x i32]
%2 = bitcast [7 x i32]* %1 to i8*
%3 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%4 = call i32 @search(i32* %3, i32 7, i32 -10)
%5 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 1
%7 = load i32, i32* %6
%8 = call i32 @search(i32* %3, i32 7, i32 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 2
%11 = load i32, i32* %10
%12 = call i32 @search(i32* %3, i32 7, i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 3
%15 = load i32, i32* %14
%16 = call i32 @search(i32* %3, i32 7, i32 %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 4
%19 = load i32, i32* %18
%20 = call i32 @search(i32* %3, i32 7, i32 %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 5
%23 = load i32, i32* %22
%24 = call i32 @search(i32* %3, i32 7, i32 %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 6
%27 = load i32, i32* %26
%28 = call i32 @search(i32* %3, i32 7, i32 %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = call i32 @search(i32* %3, i32 7, i32 -100)
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %30)
ret i32 0
}