#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 /*<<< orphan*/ scanf(char *, int *);
void search(int a[], int len) {
  int num, f = 0, i;
  printf("\nEnter the number to be searched:");
  scanf("%d", &num);
  for (i = 0; i < len; i++) {
    if (a[i] == num) {
      printf("\nFount at position %d", i + 1);
      f = 1;
    }
  }
  if (f == 0)
    printf("\nNot found!!!!!");
}


x86 assembly (clang, -O0):
<search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a9 <search+0x89>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x10(%rbp),%eax
jne    1196 <search+0x76>
mov    -0x18(%rbp),%esi
add    $0x1,%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
jmp    119b <search+0x7b>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115b <search+0x3b>
cmpl   $0x0,-0x14(%rbp)
jne    11c1 <search+0xa1>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r15
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef4(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
test   %ebp,%ebp
jle    118e <search+0x6e>
mov    %ebp,%ebp
lea    0xeca(%rip),%r14
xor    %esi,%esi
xor    %eax,%eax
jmp    1168 <search+0x48>
xchg   %ax,%ax
mov    %rbx,%rsi
cmp    %rbx,%rbp
je     118a <search+0x6a>
mov    (%r15,%rsi,4),%ecx
lea    0x1(%rsi),%rbx
cmp    0x4(%rsp),%ecx
jne    1160 <search+0x40>
add    $0x1,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%eax
jmp    1160 <search+0x40>
test   %eax,%eax
jne    119c <search+0x7c>
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"\0AEnter the number to be searched:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"\0AFount at position %d\00"
@.str.3 = [16 x i8] c"\0ANot found!!!!!\00"
define void @search(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
store i32 0, i32* %7
br label %10
10: ; preds = %27, %2
%11 = load i32, i32* %7
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %30
14: ; preds = %10
%15 = load i32*, i32** %3
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
%20 = load i32, i32* %5
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %26
22: ; preds = %14
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %24)
store i32 1, i32* %6
br label %26
26: ; preds = %22, %14
br label %27
27: ; preds = %26
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %10
30: ; preds = %10
%31 = load i32, i32* %6
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %35
35: ; preds = %33, %30
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"\0AEnter the number to be searched:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 x i8] c"\0AFount at position %d\00"
@.str.3 = [16 x i8] c"\0ANot found!!!!!\00"
define void @search(i32* nocapture %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %26
8: ; preds = %2
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %8, %21
%11 = phi i64 [ 0, %8 ], [ %17, %21 ]
%12 = phi i32 [ 0, %8 ], [ %22, %21 ]
%13 = getelementptr inbounds i32, i32* %0, i64 %11
%14 = load i32, i32* %13
%15 = load i32, i32* %3
%16 = icmp eq i32 %14, %15
%17 = add nuw nsw i64 %11, 1
br i1 %16, label %18, label %21
18: ; preds = %10
%19 = trunc i64 %17 to i32
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %10, %18
%22 = phi i32 [ 1, %18 ], [ %12, %10 ]
%23 = icmp eq i64 %17, %9
br i1 %23, label %24, label %10
24: ; preds = %21
%25 = icmp eq i32 %22, 0
br i1 %25, label %26, label %28
26: ; preds = %2, %24
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %28
28: ; preds = %26, %24
ret void
}