#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 linear_search(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int a[100];
  a[0] = 15;
  a[1] = 2;
  a[2] = 8;
  a[3] = 7;
  a[4] = 3;
  a[5] = 6;
  a[6] = 9;
  a[7] = 17;
  int n = 8;
  printf("%d\n", linear_search(a, n, 10));
  printf("%d\n", linear_search(a, n, 8));
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
movl   $0xf,-0x190(%rbp)
movl   $0x2,-0x18c(%rbp)
movl   $0x8,-0x188(%rbp)
movl   $0x7,-0x184(%rbp)
movl   $0x3,-0x180(%rbp)
movl   $0x6,-0x17c(%rbp)
movl   $0x9,-0x178(%rbp)
movl   $0x11,-0x174(%rbp)
movl   $0x8,-0x194(%rbp)
lea    -0x190(%rbp),%rdi
mov    -0x194(%rbp),%esi
mov    $0xa,%edx
call   1030 <linear_search@plt>
mov    %eax,%esi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x190(%rbp),%rdi
mov    -0x194(%rbp),%esi
mov    $0x8,%edx
call   1030 <linear_search@plt>
mov    %eax,%esi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x198,%rsp
movaps 0xebf(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0xa,%edx
call   1040 <linear_search@plt>
lea    0xeb3(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0x8,%edx
call   1040 <linear_search@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
%3 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%4 = bitcast [100 x i32]* %1 to <4 x i32>*
store <4 x i32> <i32 15, i32 2, i32 8, i32 7>, <4 x i32>* %4
%5 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 4
%6 = bitcast i32* %5 to <4 x i32>*
store <4 x i32> <i32 3, i32 6, i32 9, i32 17>, <4 x i32>* %6
%7 = call i32 @linear_search(i32* %3, i32 8, i32 10)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @linear_search(i32* %3, i32 8, i32 8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @putchar(i32 10)
ret i32 0
}