#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 *);
int main() {
  int arr[100], search, i, n, count = 0;
  printf("\nEnter number of elements: ");
  scanf("%d", &n);
  printf("\nEnter elements: ");
  for (i = 0; i < n; i++)
    scanf("%d", &arr[i]);
  printf("\nEnter item to be searched: ");
  scanf("%d", &search);
  for (i = 0; i < n; i++) {
    if (arr[i] == search) {
      printf("\nElement present at location %d", i + 1);
      count++;
    }
  }
  if (!count)
    printf("Element not present");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1b0(%rbp)
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf17(%rip),%rdi
lea    -0x1ac(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0x1ac(%rbp),%eax
jge    11bc <main+0x9c>
movslq -0x1a8(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xec5(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    1175 <main+0x55>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%eax
cmp    -0x1ac(%rbp),%eax
jge    1252 <main+0x132>
movslq -0x1a8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
cmp    -0x1a4(%rbp),%eax
jne    1239 <main+0x119>
mov    -0x1a8(%rbp),%esi
add    $0x1,%esi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1b0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b0(%rbp)
jmp    123e <main+0x11e>
mov    -0x1a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a8(%rbp)
jmp    11e7 <main+0xc7>
cmpl   $0x0,-0x1b0(%rbp)
jne    126d <main+0x14d>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1a0,%rsp
lea    0xece(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf28(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,0x8(%rsp)
jle    118d <main+0x6d>
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
lea    0xefb(%rip),%r14
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
add    $0x1,%rbp
movslq 0x8(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     1170 <main+0x50>
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
test   %eax,%eax
jle    1203 <main+0xe3>
lea    0xe90(%rip),%r14
xor    %esi,%esi
xor    %ebp,%ebp
jmp    11db <main+0xbb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq %eax,%rcx
mov    %rbx,%rsi
cmp    %rcx,%rbx
jge    11ff <main+0xdf>
mov    0x10(%rsp,%rsi,4),%ecx
lea    0x1(%rsi),%rbx
cmp    0xc(%rsp),%ecx
jne    11d0 <main+0xb0>
add    $0x1,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
mov    0x8(%rsp),%eax
jmp    11d0 <main+0xb0>
test   %ebp,%ebp
jne    1211 <main+0xf1>
lea    0xe61(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"\0AEnter number of elements: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"\0AEnter elements: \00"
@.str.3 = [29 x i8] c"\0AEnter item to be searched: \00"
@.str.4 = [32 x i8] c"\0AElement present at location %d\00"
@.str.5 = [20 x i8] c"Element not present\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %10
10: ; preds = %19, %0
%11 = load i32, i32* %4
%12 = load i32, i32* %5
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %16
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
br label %19
19: ; preds = %14
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %10
22: ; preds = %10
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 0, i32* %4
br label %25
25: ; preds = %43, %22
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %46
29: ; preds = %25
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = load i32, i32* %3
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %42
36: ; preds = %29
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %42
42: ; preds = %36, %29
br label %43
43: ; preds = %42
%44 = load i32, i32* %4
%45 = add nsw i32 %44, 1
store i32 %45, i32* %4
br label %25
46: ; preds = %25
%47 = load i32, i32* %6
%48 = icmp ne i32 %47, 0
br i1 %48, label %51, label %49
49: ; preds = %46
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %51
51: ; preds = %49, %46
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"\0AEnter number of elements: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"\0AEnter elements: \00"
@.str.3 = [29 x i8] c"\0AEnter item to be searched: \00"
@.str.4 = [32 x i8] c"\0AElement present at location %d\00"
@.str.5 = [20 x i8] c"Element not present\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [100 x i32]* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %0, %12
%13 = phi i64 [ %16, %12 ], [ 0, %0 ]
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = add nuw nsw i64 %13, 1
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %12, label %20
20: ; preds = %12, %0
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%23 = load i32, i32* %3
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %46
25: ; preds = %20, %39
%26 = phi i32 [ %40, %39 ], [ %23, %20 ]
%27 = phi i64 [ %33, %39 ], [ 0, %20 ]
%28 = phi i32 [ %41, %39 ], [ 0, %20 ]
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %27
%30 = load i32, i32* %29
%31 = load i32, i32* %2
%32 = icmp eq i32 %30, %31
%33 = add nuw nsw i64 %27, 1
br i1 %32, label %34, label %39
34: ; preds = %25
%35 = trunc i64 %33 to i32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = add nsw i32 %28, 1
%38 = load i32, i32* %3
br label %39
39: ; preds = %25, %34
%40 = phi i32 [ %38, %34 ], [ %26, %25 ]
%41 = phi i32 [ %37, %34 ], [ %28, %25 ]
%42 = sext i32 %40 to i64
%43 = icmp slt i64 %33, %42
br i1 %43, label %25, label %44
44: ; preds = %39
%45 = icmp eq i32 %41, 0
br i1 %45, label %46, label %48
46: ; preds = %20, %44
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %48
48: ; preds = %46, %44
ret i32 0
}