#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(void) {
  int T[10] = {4, 36, 89, 11, 124, 90, 4, 33, 7, 29};
  int n;
  int searchKey;
  int element = -1;
  printf("Enter integer search key: ");
  scanf("%d", &searchKey);
  for (n = 0; n < 10; n++) {
    if (T[n] == searchKey) {
      element = n;
    }
  }
  if (element != -1) {
    printf("Found value in element %d\n", element);
  } else {
    printf("Value not found\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
movl   $0xffffffff,-0x3c(%rbp)
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    11b4 <main+0x84>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
cmp    -0x38(%rbp),%eax
jne    11a1 <main+0x71>
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    11a6 <main+0x76>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1180 <main+0x50>
cmpl   $0xffffffff,-0x3c(%rbp)
je     11d4 <main+0xa4>
mov    -0x3c(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e2 <main+0xb2>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
xor    %ecx,%ecx
cmp    $0x4,%eax
setne  %cl
neg    %ecx
cmp    $0x24,%eax
mov    $0x1,%edx
cmovne %ecx,%edx
cmp    $0x59,%eax
mov    $0x2,%ecx
cmovne %edx,%ecx
cmp    $0xb,%eax
mov    $0x3,%edx
cmovne %ecx,%edx
cmp    $0x7c,%eax
mov    $0x4,%ecx
cmovne %edx,%ecx
cmp    $0x5a,%eax
mov    $0x5,%edx
cmovne %ecx,%edx
cmp    $0x4,%eax
mov    $0x6,%ecx
cmovne %edx,%ecx
cmp    $0x21,%eax
mov    $0x7,%edx
cmovne %ecx,%edx
cmp    $0x7,%eax
mov    $0x8,%ecx
cmovne %edx,%ecx
cmp    $0x1d,%eax
mov    $0x9,%esi
cmovne %ecx,%esi
cmp    $0xffffffff,%esi
je     11d6 <main+0xa6>
lea    0xe51(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11e2 <main+0xb2>
lea    0xe5c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.main.T = [10 x i32] [i32 4, i32 36, i32 89, i32 11, i32 124, i32 90, i32 4, i32 33, i32 7, i32 29]
@.str = [27 x i8] c"Enter integer search key: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"Found value in element %d\0A\00"
@.str.3 = [17 x i8] c"Value not found\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [10 x i32]* %2 to i8*
store i32 -1, i32* %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 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* %4)
store i32 0, i32* %3
br label %9
9: ; preds = %22, %0
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %25
12: ; preds = %9
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = load i32, i32* %4
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %12
%20 = load i32, i32* %3
store i32 %20, i32* %5
br label %21
21: ; preds = %19, %12
br label %22
22: ; preds = %21
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %9
25: ; preds = %9
%26 = load i32, i32* %5
%27 = icmp ne i32 %26, -1
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32, i32* %5
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %29)
br label %33
31: ; preds = %25
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %33
33: ; preds = %31, %28
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Enter integer search key: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"Found value in element %d\0A\00"
@str = [16 x i8] c"Value not found\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 4
%7 = xor i1 %6, true
%8 = sext i1 %7 to i32
%9 = icmp eq i32 %5, 36
%10 = select i1 %9, i32 1, i32 %8
%11 = icmp eq i32 %5, 89
%12 = select i1 %11, i32 2, i32 %10
%13 = icmp eq i32 %5, 11
%14 = select i1 %13, i32 3, i32 %12
%15 = icmp eq i32 %5, 124
%16 = select i1 %15, i32 4, i32 %14
%17 = icmp eq i32 %5, 90
%18 = select i1 %17, i32 5, i32 %16
%19 = select i1 %6, i32 6, i32 %18
%20 = icmp eq i32 %5, 33
%21 = select i1 %20, i32 7, i32 %19
%22 = icmp eq i32 %5, 7
%23 = select i1 %22, i32 8, i32 %21
%24 = icmp eq i32 %5, 29
%25 = select i1 %24, i32 9, i32 %23
%26 = icmp eq i32 %25, -1
br i1 %26, label %29, label %27
27: ; preds = %0
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %31
29: ; preds = %0
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %31
31: ; preds = %29, %27
ret i32 0
}