#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 */
typedef int /*<<< orphan*/ result;
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ linearSearch(int *, int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int a[] = {8, 12, 3, 4, 4, 7, 2, 3, 13, 17, 3};
  int n = sizeof(a) / sizeof(a[0]);
  int result[n];
  linearSearch(a, result, n, 3);
  int size = sizeof(result) / sizeof(result[0]);
  printf("Key found at position(s) : \n");
  for (int i = 0; i < size; i++) {
    if (result[i] != -1)
      printf("%d \n", result[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movups 0xee6(%rip),%xmm0
movups %xmm0,-0x14(%rbp)
movaps 0xecf(%rip),%xmm0
movaps %xmm0,-0x20(%rbp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,-0x30(%rbp)
movl   $0xb,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %rax,-0x58(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x60(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x48(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    $0x3,%ecx
call   1030 <linearSearch@plt>
mov    -0x58(%rbp),%rax
shl    $0x2,%rax
shr    $0x2,%rax
mov    %eax,-0x4c(%rbp)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    1201 <main+0xe1>
mov    -0x60(%rbp),%rax
movslq -0x50(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
je     11ee <main+0xce>
mov    -0x60(%rbp),%rax
movslq -0x50(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f3 <main+0xd3>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    11b7 <main+0x97>
movl   $0x0,-0x4(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
mov    %rsp,%rbx
movups 0xedd(%rip),%xmm0
movups %xmm0,0x4c(%rsp)
movaps 0xec5(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xea9(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0x30(%rsp),%rdi
mov    %rsp,%rsi
mov    $0xb,%edx
mov    $0x3,%ecx
call   1030 <linearSearch@plt>
lea    0xeb7(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%esi
cmp    $0xffffffff,%esi
je     1195 <main+0x65>
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
cmp    $0xffffffff,%esi
je     11ac <main+0x7c>
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
cmp    $0xffffffff,%esi
je     11c3 <main+0x93>
lea    0xe70(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
cmp    $0xffffffff,%esi
je     11da <main+0xaa>
lea    0xe59(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
cmp    $0xffffffff,%esi
je     11f1 <main+0xc1>
lea    0xe42(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
cmp    $0xffffffff,%esi
je     1208 <main+0xd8>
lea    0xe2b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rsp),%esi
cmp    $0xffffffff,%esi
je     121f <main+0xef>
lea    0xe14(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rsp),%esi
cmp    $0xffffffff,%esi
je     1236 <main+0x106>
lea    0xdfd(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rsp),%esi
cmp    $0xffffffff,%esi
je     124d <main+0x11d>
lea    0xde6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x24(%rsp),%esi
cmp    $0xffffffff,%esi
je     1264 <main+0x134>
lea    0xdcf(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x28(%rsp),%esi
cmp    $0xffffffff,%esi
je     127b <main+0x14b>
lea    0xdb8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rsp
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.a = [11 x i32] [i32 8, i32 12, i32 3, i32 4, i32 4, i32 7, i32 2, i32 3, i32 13, i32 17, i32 3]
@.str = [29 x i8] c"Key found at position(s) : \0A\00"
@.str.1 = [5 x i8] c"%d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [11 x i32]
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [11 x i32]* %2 to i8*
store i32 11, i32* %3
%9 = load i32, i32* %3
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %4
%12 = alloca i32, i64 %10
store i64 %10, i64* %5
%13 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 0
%14 = load i32, i32* %3
%15 = call i32 @linearSearch(i32* %13, i32* %12, i32 %14, i32 3)
%16 = mul nuw i64 4, %10
%17 = udiv i64 %16, 4
%18 = trunc i64 %17 to i32
store i32 %18, i32* %6
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %20
20: ; preds = %37, %0
%21 = load i32, i32* %7
%22 = load i32, i32* %6
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %40
24: ; preds = %20
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %12, i64 %26
%28 = load i32, i32* %27
%29 = icmp ne i32 %28, -1
br i1 %29, label %30, label %36
30: ; preds = %24
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %12, i64 %32
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %30, %24
br label %37
37: ; preds = %36
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %20
40: ; preds = %20
store i32 0, i32* %1
%41 = load i8*, i8** %4
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
@__const.main.a = [11 x i32] [i32 8, i32 12, i32 3, i32 4, i32 4, i32 7, i32 2, i32 3, i32 13, i32 17, i32 3]
@.str.1 = [5 x i8] c"%d \0A\00"
@str = [28 x i8] c"Key found at position(s) : \00"
define i32 @main() {
%1 = alloca [11 x i32]
%2 = bitcast [11 x i32]* %1 to i8*
%3 = tail call i8* @llvm.stacksave()
%4 = alloca [11 x i32]
%5 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 0
%6 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 0
%7 = call i32 @linearSearch(i32* %6, i32* %5, i32 11, i32 3)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, -1
br i1 %10, label %13, label %11
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %13
13: ; preds = %0, %11
%14 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 1
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, -1
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %19
19: ; preds = %17, %13
%20 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 2
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, -1
br i1 %22, label %25, label %23
23: ; preds = %19
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %25
25: ; preds = %23, %19
%26 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 3
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, -1
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %31
31: ; preds = %29, %25
%32 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 4
%33 = load i32, i32* %32
%34 = icmp eq i32 %33, -1
br i1 %34, label %37, label %35
35: ; preds = %31
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %33)
br label %37
37: ; preds = %35, %31
%38 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 5
%39 = load i32, i32* %38
%40 = icmp eq i32 %39, -1
br i1 %40, label %43, label %41
41: ; preds = %37
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %39)
br label %43
43: ; preds = %41, %37
%44 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 6
%45 = load i32, i32* %44
%46 = icmp eq i32 %45, -1
br i1 %46, label %49, label %47
47: ; preds = %43
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %45)
br label %49
49: ; preds = %47, %43
%50 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 7
%51 = load i32, i32* %50
%52 = icmp eq i32 %51, -1
br i1 %52, label %55, label %53
53: ; preds = %49
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %51)
br label %55
55: ; preds = %53, %49
%56 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 8
%57 = load i32, i32* %56
%58 = icmp eq i32 %57, -1
br i1 %58, label %61, label %59
59: ; preds = %55
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %57)
br label %61
61: ; preds = %59, %55
%62 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 9
%63 = load i32, i32* %62
%64 = icmp eq i32 %63, -1
br i1 %64, label %67, label %65
65: ; preds = %61
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %63)
br label %67
67: ; preds = %65, %61
%68 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 10
%69 = load i32, i32* %68
%70 = icmp eq i32 %69, -1
br i1 %70, label %73, label %71
71: ; preds = %67
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %69)
br label %73
73: ; preds = %71, %67
ret i32 0
}