#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 argc, char **argv) {
  int A[11] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  int B[9] = {5, 6, 7, 8, 0, 1, 2, 3, 4};
  int C[7] = {3, 4, 5, 6, 0, 1, 2};
  printf("Index is %d\n", search(B, 9, 4));
  printf("Index is %d\n", search(C, 7, 3));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeac(%rip),%rsi
mov    $0x2c,%edx
call   1050 <memcpy@plt>
lea    -0x70(%rbp),%rdi
lea    0xec7(%rip),%rsi
mov    $0x24,%edx
call   1050 <memcpy@plt>
mov    0xee6(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0xee0(%rip),%rax
mov    %rax,-0x88(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xed8(%rip),%eax
mov    %eax,-0x78(%rbp)
lea    -0x70(%rbp),%rdi
mov    $0x9,%esi
mov    $0x4,%edx
call   1040 <search@plt>
mov    %eax,%esi
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    $0x7,%esi
mov    $0x3,%edx
call   1040 <search@plt>
mov    %eax,%esi
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
mov    0xef5(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xeef(%rip),%xmm0
movups %xmm0,0x3c(%rsp)
movaps 0xed7(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
mov    %rsp,%rdi
mov    $0x9,%esi
mov    $0x4,%edx
call   1040 <search@plt>
lea    0xed5(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0x30(%rsp),%rdi
mov    $0x7,%esi
mov    $0x3,%edx
call   1040 <search@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.A = [11 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10]
@__const.main.B = [9 x i32] [i32 5, i32 6, i32 7, i32 8, i32 0, i32 1, i32 2, i32 3, i32 4]
@__const.main.C = [7 x i32] [i32 3, i32 4, i32 5, i32 6, i32 0, i32 1, i32 2]
@.str = [13 x i8] c"Index is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [11 x i32]
%7 = alloca [9 x i32]
%8 = alloca [7 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [11 x i32]* %6 to i8*
%10 = bitcast [9 x i32]* %7 to i8*
%11 = bitcast [7 x i32]* %8 to i8*
%12 = getelementptr inbounds [9 x i32], [9 x i32]* %7, i64 0, i64 0
%13 = call i32 @search(i32* %12, i32 9, i32 4)
%14 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [7 x i32], [7 x i32]* %8, i64 0, i64 0
%16 = call i32 @search(i32* %15, i32 7, i32 3)
%17 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %16)
ret i32 0
}

LLVM IR (-O2):
@__const.main.B = [9 x i32] [i32 5, i32 6, i32 7, i32 8, i32 0, i32 1, i32 2, i32 3, i32 4]
@__const.main.C = [7 x i32] [i32 3, i32 4, i32 5, i32 6, i32 0, i32 1, i32 2]
@.str = [13 x i8] c"Index is %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [9 x i32]
%4 = alloca [7 x i32]
%5 = bitcast [9 x i32]* %3 to i8*
%6 = bitcast [7 x i32]* %4 to i8*
%7 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 0
%8 = call i32 @search(i32* %7, i32 9, i32 4)
%9 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 0
%11 = call i32 @search(i32* %10, i32 7, i32 3)
%12 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %11)
ret i32 0
}