#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 *, ...);
scalar_t__ scanf(char *, int *);
int main(void) {
  int arr[100];
  int num, key;
  printf("Enter number of elements: ");
  if (scanf("%d", &num) != 0) {
    for (size_t i = 0; i < num; i++) {
      if (scanf("%d", &arr[i]) != 0) {
      } else {
        printf("Please enter appropriate input!");
        goto end;
      }
    }
  } else {
    printf("Please enter appropriate input!");
    goto end;
  }
  printf("Enter number to search: ");
  if (scanf("%d", &key) != 0) {
    for (size_t i = 0; i < num; i++) {
      if (arr[i] == key) {
        printf("Found %d in position %d", key, i);
      } else
        printf("Not Found");
    }
  } else {
    printf("Please enter appropriate input!");
    goto end;
  }
end:
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf22(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     11e3 <main+0xc3>
movq   $0x0,-0x1b0(%rbp)
mov    -0x1b0(%rbp),%rax
movslq -0x1a4(%rbp),%rcx
cmp    %rcx,%rax
jae    11de <main+0xbe>
mov    -0x1b0(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xece(%rip),%rdi
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     11af <main+0x8f>
jmp    11c2 <main+0xa2>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c4 <main+0x1a4>
jmp    11c7 <main+0xa7>
mov    -0x1b0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1b0(%rbp)
jmp    1168 <main+0x48>
jmp    11f6 <main+0xd6>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c4 <main+0x1a4>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5e(%rip),%rdi
lea    -0x1a8(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x0,%rax
je     12ac <main+0x18c>
movq   $0x0,-0x1b8(%rbp)
mov    -0x1b8(%rbp),%rax
movslq -0x1a4(%rbp),%rcx
cmp    %rcx,%rax
jae    12a7 <main+0x187>
mov    -0x1b8(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%eax
cmp    -0x1a8(%rbp),%eax
jne    127d <main+0x15d>
mov    -0x1a8(%rbp),%esi
mov    -0x1b8(%rbp),%rdx
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    128b <main+0x16b>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1290 <main+0x170>
mov    -0x1b8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1b8(%rbp)
jmp    122c <main+0x10c>
jmp    12bf <main+0x19f>
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12c4 <main+0x1a4>
jmp    12c4 <main+0x1a4>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1a0,%rsp
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf28(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
test   %rax,%rax
je     1211 <main+0xf1>
cmpl   $0x0,0x8(%rsp)
je     1196 <main+0x76>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xf00(%rip),%r14
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
test   %rax,%rax
je     1211 <main+0xf1>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jb     1170 <main+0x50>
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
test   %rax,%rax
je     1211 <main+0xf1>
cmpl   $0x0,0x8(%rsp)
je     121f <main+0xff>
lea    0xe8c(%rip),%r14
lea    0xe9d(%rip),%r15
xor    %ebx,%ebx
jmp    11f8 <main+0xd8>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
cmp    %rax,%rbx
jae    121f <main+0xff>
mov    0x10(%rsp,%rbx,4),%esi
cmp    0xc(%rsp),%esi
jne    11e0 <main+0xc0>
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11ea <main+0xca>
lea    0xe03(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Enter number of elements: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"Please enter appropriate input!\00"
@.str.3 = [25 x i8] c"Enter number to search: \00"
@.str.4 = [24 x i8] c"Found %d in position %d\00"
@.str.5 = [10 x i8] c"Not Found\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%8 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %29
10: ; preds = %0
store i64 0, i64* %5
br label %11
11: ; preds = %25, %10
%12 = load i64, i64* %5
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = icmp ult i64 %12, %14
br i1 %15, label %16, label %28
16: ; preds = %11
%17 = load i64, i64* %5
%18 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %17
%19 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
br label %24
22: ; preds = %16
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %61
24: ; preds = %21
br label %25
25: ; preds = %24
%26 = load i64, i64* %5
%27 = add i64 %26, 1
store i64 %27, i64* %5
br label %11
28: ; preds = %11
br label %31
29: ; preds = %0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %61
31: ; preds = %28
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%33 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %58
35: ; preds = %31
store i64 0, i64* %6
br label %36
36: ; preds = %54, %35
%37 = load i64, i64* %6
%38 = load i32, i32* %3
%39 = sext i32 %38 to i64
%40 = icmp ult i64 %37, %39
br i1 %40, label %41, label %57
41: ; preds = %36
%42 = load i64, i64* %6
%43 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = load i32, i32* %4
%46 = icmp eq i32 %44, %45
br i1 %46, label %47, label %51
47: ; preds = %41
%48 = load i32, i32* %4
%49 = load i64, i64* %6
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %48, i64 %49)
br label %53
51: ; preds = %41
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %53
53: ; preds = %51, %47
br label %54
54: ; preds = %53
%55 = load i64, i64* %6
%56 = add i64 %55, 1
store i64 %56, i64* %6
br label %36
57: ; preds = %36
br label %60
58: ; preds = %31
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %61
60: ; preds = %57
br label %61
61: ; preds = %60, %58, %29, %22
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Enter number of elements: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"Please enter appropriate input!\00"
@.str.3 = [25 x i8] c"Enter number to search: \00"
@.str.4 = [24 x i8] c"Found %d in position %d\00"
@.str.5 = [10 x i8] c"Not Found\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 ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%8 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %45, label %10
10: ; preds = %0
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 0
br i1 %12, label %23, label %17
13: ; preds = %17
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = icmp ult i64 %22, %15
br i1 %16, label %17, label %23
17: ; preds = %10, %13
%18 = phi i64 [ %22, %13 ], [ 0, %10 ]
%19 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %18
%20 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %19)
%21 = icmp eq i64 %20, 0
%22 = add nuw i64 %18, 1
br i1 %21, label %45, label %13
23: ; preds = %13, %10
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%25 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%26 = icmp eq i64 %25, 0
br i1 %26, label %45, label %27
27: ; preds = %23
%28 = load i32, i32* %2
%29 = icmp eq i32 %28, 0
br i1 %29, label %47, label %30
30: ; preds = %27, %40
%31 = phi i64 [ %41, %40 ], [ 0, %27 ]
%32 = getelementptr inbounds [100 x i32], [100 x i32]* %1, 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 %38
36: ; preds = %30
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %33, i64 %31)
br label %40
38: ; preds = %30
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %40
40: ; preds = %36, %38
%41 = add nuw i64 %31, 1
%42 = load i32, i32* %2
%43 = sext i32 %42 to i64
%44 = icmp ult i64 %41, %43
br i1 %44, label %30, label %47
45: ; preds = %17, %23, %0
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %47
47: ; preds = %40, %45, %27
ret i32 0
}