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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%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>
lea    -0xa0(%rbp),%rdi
lea    0xedf(%rip),%rsi
mov    $0x30,%edx
call   1050 <memcpy@plt>
lea    -0x70(%rbp),%rdi
mov    $0x9,%esi
mov    $0x7,%edx
call   1040 <search@plt>
mov    %eax,%esi
lea    0xee9(%rip),%rdi
call   1030 <printf@plt>
lea    -0xa0(%rbp),%rdi
mov    $0xc,%esi
mov    $0x3,%edx
call   1040 <search@plt>
mov    %eax,%esi
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
lea    -0xa0(%rbp),%rdi
mov    $0xc,%esi
mov    $0x7,%edx
call   1040 <search@plt>
mov    %eax,%esi
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    0xef3(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xed8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xebc(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xf01(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xee5(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
mov    %rsp,%rdi
mov    $0x9,%esi
mov    $0x7,%edx
call   1040 <search@plt>
lea    0xedb(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0x30(%rsp),%r14
mov    %r14,%rdi
mov    $0xc,%esi
mov    $0x3,%edx
call   1040 <search@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0xc,%esi
mov    $0x7,%edx
call   1040 <search@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.A = [11 x i32] [i32 1, i32 1, i32 1, i32 2, i32 3, i32 4, i32 4, i32 4, i32 5, i32 6, i32 1]
@__const.main.B = [9 x i32] [i32 5, i32 6, i32 6, i32 8, i32 0, i32 1, i32 2, i32 3, i32 4]
@__const.main.C = [12 x i32] [i32 3, i32 3, i32 4, i32 5, i32 6, i32 0, i32 0, i32 1, i32 1, i32 1, 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 [12 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 [12 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 7)
%14 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [12 x i32], [12 x i32]* %8, i64 0, i64 0
%16 = call i32 @search(i32* %15, i32 12, i32 3)
%17 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [12 x i32], [12 x i32]* %8, i64 0, i64 0
%19 = call i32 @search(i32* %18, i32 12, i32 7)
%20 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %19)
ret i32 0
}

LLVM IR (-O2):
@__const.main.B = [9 x i32] [i32 5, i32 6, i32 6, i32 8, i32 0, i32 1, i32 2, i32 3, i32 4]
@__const.main.C = [12 x i32] [i32 3, i32 3, i32 4, i32 5, i32 6, i32 0, i32 0, i32 1, i32 1, i32 1, 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 [12 x i32]
%5 = bitcast [9 x i32]* %3 to i8*
%6 = bitcast [12 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 7)
%9 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [12 x i32], [12 x i32]* %4, i64 0, i64 0
%11 = call i32 @search(i32* %10, i32 12, i32 3)
%12 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 @search(i32* %10, i32 12, i32 7)
%14 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %13)
ret i32 0
}