#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*/ fnDispArray(int *, int);
int /*<<< orphan*/ fnReadArray(int *, int);
int fnSearchArray(int *, int, int);
int /*<<< orphan*/ fnSortArray(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int iaList[100], iKey, iNum, iPos;
  printf("\nEnter the no. of elements\n");
  scanf("%d", &iNum);
  printf("\nEnter %d elements\n", iNum);
  fnReadArray(iaList, iNum);
  printf("\nEntered values are :\n");
  fnDispArray(iaList, iNum);
  fnSortArray(iaList, iNum);
  printf("\nAfter Sorting :\n");
  fnDispArray(iaList, iNum);
  printf("\nEnter the key element\n");
  scanf("%d", &iKey);
  iPos = fnSearchArray(iaList, iKey, iNum);
  if (-1 == iPos) {
    printf("\nElement not found\n");
  } else {
    printf("\nElement %d found at position %d\n", iKey, iPos + 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe95(%rip),%rdi
lea    -0x1a8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x1a8(%rbp),%esi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a8(%rbp),%esi
call   1040 <fnReadArray@plt>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a8(%rbp),%esi
call   1030 <fnDispArray@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a8(%rbp),%esi
call   1080 <fnSortArray@plt>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a8(%rbp),%esi
call   1030 <fnDispArray@plt>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdfc(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
call   1070 <scanf@plt>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a4(%rbp),%esi
mov    -0x1a8(%rbp),%edx
call   1060 <fnSearchArray@plt>
mov    %eax,-0x1ac(%rbp)
mov    $0xffffffff,%eax
cmp    -0x1ac(%rbp),%eax
jne    126e <main+0x10e>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    128b <main+0x12b>
mov    -0x1a4(%rbp),%esi
mov    -0x1ac(%rbp),%edx
add    $0x1,%edx
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x1a8,%rsp
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
lea    0xe73(%rip),%r14
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1080 <scanf@plt>
mov    0x8(%rsp),%esi
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%esi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <fnReadArray@plt>
lea    0xe90(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1030 <fnDispArray@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1090 <fnSortArray@plt>
lea    0xe82(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1030 <fnDispArray@plt>
lea    0xe7b(%rip),%rdi
call   1040 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   1080 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
call   1070 <fnSearchArray@plt>
cmp    $0xffffffff,%eax
je     1240 <main+0xd0>
mov    0xc(%rsp),%esi
add    $0x1,%eax
lea    0xde2(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    124c <main+0xdc>
lea    0xe4b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [28 x i8] c"\0AEnter the no. of elements\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"\0AEnter %d elements\0A\00"
@.str.3 = [23 x i8] c"\0AEntered values are :\0A\00"
@.str.4 = [18 x i8] c"\0AAfter Sorting :\0A\00"
@.str.5 = [24 x i8] c"\0AEnter the key element\0A\00"
@.str.6 = [20 x i8] c"\0AElement not found\0A\00"
@.str.7 = [34 x i8] c"\0AElement %d found at position %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%8 = load i32, i32* %4
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%11 = load i32, i32* %4
%12 = call i32 @fnReadArray(i32* %10, i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%14 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%15 = load i32, i32* %4
%16 = call i32 @fnDispArray(i32* %14, i32 %15)
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%18 = load i32, i32* %4
%19 = call i32 @fnSortArray(i32* %17, i32 %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%21 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%22 = load i32, i32* %4
%23 = call i32 @fnDispArray(i32* %21, i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%26 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = call i32 @fnSearchArray(i32* %26, i32 %27, i32 %28)
store i32 %29, i32* %5
%30 = load i32, i32* %5
%31 = icmp eq i32 -1, %30
br i1 %31, label %32, label %34
32: ; preds = %0
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %39
34: ; preds = %0
%35 = load i32, i32* %3
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %35, i32 %37)
br label %39
39: ; preds = %34, %32
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"\0AEnter %d elements\0A\00"
@.str.7 = [34 x i8] c"\0AElement %d found at position %d\0A\00"
@str = [27 x i8] c"\0AEnter the no. of elements\00"
@str.8 = [22 x i8] c"\0AEntered values are :\00"
@str.9 = [17 x i8] c"\0AAfter Sorting :\00"
@str.10 = [23 x i8] c"\0AEnter the key element\00"
@str.11 = [19 x i8] c"\0AElement 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 @puts(i8* dereferenceable(1) 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* %3)
%9 = load i32, i32* %3
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%12 = load i32, i32* %3
%13 = call i32 @fnReadArray(i32* %11, i32 %12)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0))
%15 = load i32, i32* %3
%16 = call i32 @fnDispArray(i32* %11, i32 %15)
%17 = load i32, i32* %3
%18 = call i32 @fnSortArray(i32* %11, i32 %17)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0))
%20 = load i32, i32* %3
%21 = call i32 @fnDispArray(i32* %11, i32 %20)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.10, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call i32 @fnSearchArray(i32* %11, i32 %24, i32 %25)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %30
28: ; preds = %0
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.11, i64 0, i64 0))
br label %34
30: ; preds = %0
%31 = load i32, i32* %2
%32 = add nuw nsw i32 %26, 1
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0), i32 %31, i32 %32)
br label %34
34: ; preds = %30, %28
ret i32 0
}