#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 */
struct timeval {
  double tv_usec;
  int /*<<< orphan*/ tv_sec;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fnBinSearch(int *, int, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ fnDispArray(int *, int);
int /*<<< orphan*/ fnGenRandInput(int *, int);
int fnLinSearch(int *, int, int);
int /*<<< orphan*/ fnSort(int *, int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, double);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  FILE *fp1, *fp2;
  struct timeval tv;
  double dStart, dEnd;
  int iaArr[500000], iNum, iPos, iKey, i, iChoice;
  for (;;) {
    printf("\n1.Plot the Graph \n2.Binary Search");
    printf("\n3.Linear Search\n4.Exit");
    printf("\nEnter your choice\n");
    scanf("%d", &iChoice);
    switch (iChoice) {
    case 1:
      fp1 = fopen("BSearch.dat", "w");
      fp2 = fopen("LSearch.dat", "w");
      srand(time(NULL));
      for (i = 100; i < 10000; i += 100) {
        fnGenRandInput(iaArr, i);
        iKey = iaArr[0];
        gettimeofday(&tv, NULL);
        dStart = tv.tv_sec + (tv.tv_usec / 1000000.0);
        fnLinSearch(iaArr, i, iKey);
        gettimeofday(&tv, NULL);
        dEnd = tv.tv_sec + (tv.tv_usec / 1000000.0);
        fprintf(fp1, "%d\t%lf\n", i, dEnd - dStart);
        fnSort(iaArr, i);
        gettimeofday(&tv, NULL);
        dStart = tv.tv_sec + (tv.tv_usec / 1000000.0);
        fnBinSearch(iaArr, i, iKey, 0, i - 1);
        gettimeofday(&tv, NULL);
        dEnd = tv.tv_sec + (tv.tv_usec / 1000000.0);
        fprintf(fp2, "%d\t%lf\n", i, dEnd - dStart);
      }
      fclose(fp1);
      fclose(fp2);
      printf("\nData Files generated and stored in files < BSearch.dat > and < "
             "LSearch.dat >.");
      printf("\n Use a plotting utility\n");
      break;
    case 2:
      printf("\nEnter the number of elements to Search\n");
      scanf("%d", &iNum);
      printf("\nSearch Array\n");
      fnGenRandInput(iaArr, iNum);
      fnSort(iaArr, iNum);
      fnDispArray(iaArr, iNum);
      printf("\nEnter the key element to Search\n");
      scanf("%d", &iKey);
      iPos = fnBinSearch(iaArr, iNum, iKey, 0, iNum - 1);
      if (iPos == -1) {
        printf("\nElement not found \n");
      } else {
        printf("\nElement found at %d position\n", iPos + 1);
      }
      break;
    case 3:
      printf("\nEnter the number of elements to Search\n");
      scanf("%d", &iNum);
      printf("\nSearch Array\n");
      fnGenRandInput(iaArr, iNum);
      fnDispArray(iaArr, iNum);
      printf("\nEnter the key element to Search\n");
      scanf("%d", &iKey);
      iPos = fnLinSearch(iaArr, iNum, iKey);
      if (iPos == -1) {
        printf("\nElement not found \n");
      } else {
        printf("\nElement found at %d position\n", iPos + 1);
      }
      break;
    case 4:
      exit(0);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e84f0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x1e84e1(%rbp)
call   1070 <printf@plt>
mov    -0x1e84e1(%rbp),%al
lea    0xe28(%rip),%rdi
call   1070 <printf@plt>
mov    -0x1e84e1(%rbp),%al
lea    0xe2e(%rip),%rdi
call   1070 <printf@plt>
lea    0xe36(%rip),%rdi
lea    -0x1e84d4(%rbp),%rsi
call   10d0 <scanf@plt>
mov    -0x1e84d4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x1e84e0(%rbp)
sub    $0x3,%eax
ja     162d <main+0x44d>
mov    -0x1e84e0(%rbp),%rax
lea    0xda2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xdf4(%rip),%rdi
lea    0xdf9(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xdeb(%rip),%rdi
lea    0xde2(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,%edi
call   1090 <srand@plt>
movl   $0x64,-0x1e84d0(%rbp)
cmpl   $0x2710,-0x1e84d0(%rbp)
jge    1438 <main+0x258>
lea    -0x1e84c0(%rbp),%rdi
mov    -0x1e84d0(%rbp),%esi
call   1040 <fnGenRandInput@plt>
mov    -0x1e84c0(%rbp),%eax
mov    %eax,-0x1e84cc(%rbp)
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xcfc(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    -0x1e84c0(%rbp),%rdi
mov    -0x1e84d0(%rbp),%esi
mov    -0x1e84cc(%rbp),%edx
call   1050 <fnLinSearch@plt>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xcb8(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1e84d0(%rbp),%edx
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
lea    0xd14(%rip),%rsi
call   10a0 <fprintf@plt>
lea    -0x1e84c0(%rbp),%rdi
mov    -0x1e84d0(%rbp),%esi
call   10e0 <fnSort@plt>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xc5a(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    -0x1e84c0(%rbp),%rdi
mov    -0x1e84d0(%rbp),%esi
mov    -0x1e84cc(%rbp),%edx
mov    -0x1e84d0(%rbp),%r8d
sub    $0x1,%r8d
xor    %ecx,%ecx
call   10b0 <fnBinSearch@plt>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <gettimeofday@plt>
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xc09(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1e84d0(%rbp),%edx
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
lea    0xc65(%rip),%rsi
call   10a0 <fprintf@plt>
mov    -0x1e84d0(%rbp),%eax
add    $0x64,%eax
mov    %eax,-0x1e84d0(%rbp)
jmp    12b7 <main+0xd7>
mov    -0x10(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
lea    0xc3b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xc7c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    162d <main+0x44d>
lea    0xc83(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xbe7(%rip),%rdi
lea    -0x1e84c4(%rbp),%rsi
call   10d0 <scanf@plt>
lea    0xc8b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x1e84c0(%rbp),%rdi
mov    -0x1e84c4(%rbp),%esi
call   1040 <fnGenRandInput@plt>
lea    -0x1e84c0(%rbp),%rdi
mov    -0x1e84c4(%rbp),%esi
call   10e0 <fnSort@plt>
lea    -0x1e84c0(%rbp),%rdi
mov    -0x1e84c4(%rbp),%esi
call   1030 <fnDispArray@plt>
lea    0xc56(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xb82(%rip),%rdi
lea    -0x1e84cc(%rbp),%rsi
call   10d0 <scanf@plt>
lea    -0x1e84c0(%rbp),%rdi
mov    -0x1e84c4(%rbp),%esi
mov    -0x1e84cc(%rbp),%edx
mov    -0x1e84c4(%rbp),%r8d
sub    $0x1,%r8d
xor    %ecx,%ecx
call   10b0 <fnBinSearch@plt>
mov    %eax,-0x1e84c8(%rbp)
cmpl   $0xffffffff,-0x1e84c8(%rbp)
jne    153c <main+0x35c>
lea    0xc1f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1553 <main+0x373>
mov    -0x1e84c8(%rbp),%esi
add    $0x1,%esi
lea    0xc18(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    162d <main+0x44d>
lea    0xb96(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xafa(%rip),%rdi
lea    -0x1e84c4(%rbp),%rsi
call   10d0 <scanf@plt>
lea    0xb9e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x1e84c0(%rbp),%rdi
mov    -0x1e84c4(%rbp),%esi
call   1040 <fnGenRandInput@plt>
lea    -0x1e84c0(%rbp),%rdi
mov    -0x1e84c4(%rbp),%esi
call   1030 <fnDispArray@plt>
lea    0xb7b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xaa7(%rip),%rdi
lea    -0x1e84cc(%rbp),%rsi
call   10d0 <scanf@plt>
lea    -0x1e84c0(%rbp),%rdi
mov    -0x1e84c4(%rbp),%esi
mov    -0x1e84cc(%rbp),%edx
call   1050 <fnLinSearch@plt>
mov    %eax,-0x1e84c8(%rbp)
cmpl   $0xffffffff,-0x1e84c8(%rbp)
jne    160a <main+0x42a>
lea    0xb51(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1621 <main+0x441>
mov    -0x1e84c8(%rbp),%esi
add    $0x1,%esi
lea    0xb4a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    162d <main+0x44d>
xor    %edi,%edi
call   1100 <exit@plt>
jmp    11f2 <main+0x12>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1e84c8,%rsp
lea    0xe18(%rip),%r12
lea    0xedf(%rip),%r13
lea    0xc(%rsp),%rbx
lea    0x40(%rsp),%rbp
lea    0x10(%rsp),%r14
lea    0xe53(%rip),%r15
jmp    123f <main+0x4f>
lea    0xf2a(%rip),%rdi
call   1040 <puts@plt>
lea    0xc(%rsp),%rbx
lea    0xde1(%rip),%r12
mov    %r12,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xdf3(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
lea    0xdf5(%rip),%rdi
mov    %rbx,%rsi
call   10e0 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     123f <main+0x4f>
lea    0xd8f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xdcd(%rip),%rdi
lea    0xdd2(%rip),%rbx
mov    %rbx,%rsi
call   1100 <fopen@plt>
mov    %rax,%r12
lea    0xdc2(%rip),%rdi
mov    %rbx,%rsi
call   1100 <fopen@plt>
mov    %rax,%r13
xor    %edi,%edi
call   10d0 <time@plt>
mov    %eax,%edi
call   10a0 <srand@plt>
mov    $0x64,%ebx
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %ebx,%esi
call   1050 <fnGenRandInput@plt>
mov    0x40(%rsp),%eax
mov    %eax,0x8(%rsp)
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    0x8(%rsp),%edx
movss  0x18(%rsp),%xmm0
movaps %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
movaps %xmm0,0x30(%rsp)
mov    %rbp,%rdi
mov    %ebx,%esi
call   1060 <fnLinSearch@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
movaps 0x10(%rsp),%xmm0
movaps 0x20(%rsp),%xmm1
shufps $0xe4,%xmm0,%xmm1
shufps $0xe2,%xmm1,%xmm1
cvtdq2pd %xmm1,%xmm1
unpcklpd 0x30(%rsp),%xmm0
movapd 0xcc2(%rip),%xmm2
divpd  %xmm2,%xmm0
addpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
subsd  %xmm1,%xmm0
mov    %r12,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   10b0 <fprintf@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
call   10f0 <fnSort@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
mov    0x8(%rsp),%edx
lea    -0x1(%rbx),%r8d
movss  0x18(%rsp),%xmm0
movaps %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
movaps %xmm0,0x30(%rsp)
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %ecx,%ecx
call   10c0 <fnBinSearch@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <gettimeofday@plt>
movaps 0x10(%rsp),%xmm0
movaps 0x20(%rsp),%xmm1
shufps $0xe4,%xmm0,%xmm1
shufps $0xe2,%xmm1,%xmm1
cvtdq2pd %xmm1,%xmm1
unpcklpd 0x30(%rsp),%xmm0
divpd  0xc35(%rip),%xmm0
addpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
subsd  %xmm1,%xmm0
mov    %r13,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   10b0 <fprintf@plt>
lea    0x64(%rbx),%eax
cmp    $0x26ac,%ebx
mov    %eax,%ebx
jb     12d0 <main+0xe0>
mov    %r12,%rdi
call   1070 <fclose@plt>
mov    %r13,%rdi
call   1070 <fclose@plt>
lea    0xc70(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd4e(%rip),%rdi
call   1040 <puts@plt>
lea    0xbf6(%rip),%r12
lea    0xcbd(%rip),%r13
lea    0xc(%rsp),%rbx
jmp    123f <main+0x4f>
nopl   0x0(%rax,%rax,1)
lea    0xcba(%rip),%rdi
call   1040 <puts@plt>
lea    0xc08(%rip),%rdi
lea    0x4(%rsp),%rsi
call   10e0 <scanf@plt>
lea    0xcc5(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%esi
mov    %rbp,%rdi
call   1050 <fnGenRandInput@plt>
mov    0x4(%rsp),%esi
mov    %rbp,%rdi
call   10f0 <fnSort@plt>
mov    0x4(%rsp),%esi
mov    %rbp,%rdi
call   1030 <fnDispArray@plt>
lea    0xca3(%rip),%rdi
call   1040 <puts@plt>
lea    0xbbb(%rip),%rdi
lea    0x8(%rsp),%rsi
call   10e0 <scanf@plt>
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
lea    -0x1(%rsi),%r8d
mov    %rbp,%rdi
xor    %ecx,%ecx
call   10c0 <fnBinSearch@plt>
cmp    $0xffffffff,%eax
je     157e <main+0x38e>
add    $0x1,%eax
lea    0xbfc(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    123f <main+0x4f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xc0a(%rip),%rdi
call   1040 <puts@plt>
lea    0xb58(%rip),%r12
mov    %r12,%rdi
lea    0x4(%rsp),%rsi
call   10e0 <scanf@plt>
lea    0xc12(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%esi
mov    %rbp,%rdi
call   1050 <fnGenRandInput@plt>
mov    0x4(%rsp),%esi
mov    %rbp,%rdi
call   1030 <fnDispArray@plt>
lea    0xbfc(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
lea    0x8(%rsp),%rsi
call   10e0 <scanf@plt>
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%edx
mov    %rbp,%rdi
call   1060 <fnLinSearch@plt>
cmp    $0xffffffff,%eax
je     1227 <main+0x37>
add    $0x1,%eax
lea    0xb5f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1233 <main+0x43>
lea    0xbd3(%rip),%rdi
call   1040 <puts@plt>
jmp    123f <main+0x4f>
xor    %edi,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { double, i32 }
@.str = [35 x i8] c"\0A1.Plot the Graph \0A2.Binary Search\00"
@.str.1 = [24 x i8] c"\0A3.Linear Search\0A4.Exit\00"
@.str.2 = [20 x i8] c"\0AEnter your choice\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [12 x i8] c"BSearch.dat\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [12 x i8] c"LSearch.dat\00"
@.str.7 = [8 x i8] c"%d\09%lf\0A\00"
@.str.8 = [79 x i8] c"\0AData Files generated and stored in files < BSearch.dat > and < LSearch.dat >.\00"
@.str.9 = [26 x i8] c"\0A Use a plotting utility\0A\00"
@.str.10 = [41 x i8] c"\0AEnter the number of elements to Search\0A\00"
@.str.11 = [15 x i8] c"\0ASearch Array\0A\00"
@.str.12 = [34 x i8] c"\0AEnter the key element to Search\0A\00"
@.str.13 = [21 x i8] c"\0AElement not found \0A\00"
@.str.14 = [31 x i8] c"\0AElement found at %d position\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca %struct.timeval
%5 = alloca double
%6 = alloca double
%7 = alloca [500000 x i32]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %1
br label %13
13: ; preds = %157, %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %12)
%18 = load i32, i32* %12
switch i32 %18, label %157 [
i32 1, label %19
i32 2, label %100
i32 3, label %130
i32 4, label %155
]
19: ; preds = %13
%20 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %20, i32** %2
%21 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %21, i32** %3
%22 = call i32 @time(i32* null)
%23 = call i32 @srand(i32 %22)
store i32 100, i32* %11
br label %24
24: ; preds = %90, %19
%25 = load i32, i32* %11
%26 = icmp slt i32 %25, 10000
br i1 %26, label %27, label %93
27: ; preds = %24
%28 = getelementptr inbounds [500000 x i32], [500000 x i32]* %7, i64 0, i64 0
%29 = load i32, i32* %11
%30 = call i32 @fnGenRandInput(i32* %28, i32 %29)
%31 = getelementptr inbounds [500000 x i32], [500000 x i32]* %7, i64 0, i64 0
%32 = load i32, i32* %31
store i32 %32, i32* %10
%33 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%35 = load i32, i32* %34
%36 = sitofp i32 %35 to double
%37 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%38 = load double, double* %37
%39 = fdiv double %38, 1.000000e+06
%40 = fadd double %36, %39
store double %40, double* %5
%41 = getelementptr inbounds [500000 x i32], [500000 x i32]* %7, i64 0, i64 0
%42 = load i32, i32* %11
%43 = load i32, i32* %10
%44 = call i32 @fnLinSearch(i32* %41, i32 %42, i32 %43)
%45 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%46 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%47 = load i32, i32* %46
%48 = sitofp i32 %47 to double
%49 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%50 = load double, double* %49
%51 = fdiv double %50, 1.000000e+06
%52 = fadd double %48, %51
store double %52, double* %6
%53 = load i32*, i32** %2
%54 = load i32, i32* %11
%55 = load double, double* %6
%56 = load double, double* %5
%57 = fsub double %55, %56
%58 = call i32 @fprintf(i32* %53, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %54, double %57)
%59 = getelementptr inbounds [500000 x i32], [500000 x i32]* %7, i64 0, i64 0
%60 = load i32, i32* %11
%61 = call i32 @fnSort(i32* %59, i32 %60)
%62 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%63 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%64 = load i32, i32* %63
%65 = sitofp i32 %64 to double
%66 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%67 = load double, double* %66
%68 = fdiv double %67, 1.000000e+06
%69 = fadd double %65, %68
store double %69, double* %5
%70 = getelementptr inbounds [500000 x i32], [500000 x i32]* %7, i64 0, i64 0
%71 = load i32, i32* %11
%72 = load i32, i32* %10
%73 = load i32, i32* %11
%74 = sub nsw i32 %73, 1
%75 = call i32 @fnBinSearch(i32* %70, i32 %71, i32 %72, i32 0, i32 %74)
%76 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%77 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%78 = load i32, i32* %77
%79 = sitofp i32 %78 to double
%80 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%81 = load double, double* %80
%82 = fdiv double %81, 1.000000e+06
%83 = fadd double %79, %82
store double %83, double* %6
%84 = load i32*, i32** %3
%85 = load i32, i32* %11
%86 = load double, double* %6
%87 = load double, double* %5
%88 = fsub double %86, %87
%89 = call i32 @fprintf(i32* %84, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %85, double %88)
br label %90
90: ; preds = %27
%91 = load i32, i32* %11
%92 = add nsw i32 %91, 100
store i32 %92, i32* %11
br label %24
93: ; preds = %24
%94 = load i32*, i32** %2
%95 = call i32 @fclose(i32* %94)
%96 = load i32*, i32** %3
%97 = call i32 @fclose(i32* %96)
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.8, i64 0, i64 0))
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
br label %157
100: ; preds = %13
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.10, i64 0, i64 0))
%102 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %8)
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0))
%104 = getelementptr inbounds [500000 x i32], [500000 x i32]* %7, i64 0, i64 0
%105 = load i32, i32* %8
%106 = call i32 @fnGenRandInput(i32* %104, i32 %105)
%107 = getelementptr inbounds [500000 x i32], [500000 x i32]* %7, i64 0, i64 0
%108 = load i32, i32* %8
%109 = call i32 @fnSort(i32* %107, i32 %108)
%110 = getelementptr inbounds [500000 x i32], [500000 x i32]* %7, i64 0, i64 0
%111 = load i32, i32* %8
%112 = call i32 @fnDispArray(i32* %110, i32 %111)
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.12, i64 0, i64 0))
%114 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %10)
%115 = getelementptr inbounds [500000 x i32], [500000 x i32]* %7, i64 0, i64 0
%116 = load i32, i32* %8
%117 = load i32, i32* %10
%118 = load i32, i32* %8
%119 = sub nsw i32 %118, 1
%120 = call i32 @fnBinSearch(i32* %115, i32 %116, i32 %117, i32 0, i32 %119)
store i32 %120, i32* %9
%121 = load i32, i32* %9
%122 = icmp eq i32 %121, -1
br i1 %122, label %123, label %125
123: ; preds = %100
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.13, i64 0, i64 0))
br label %129
125: ; preds = %100
%126 = load i32, i32* %9
%127 = add nsw i32 %126, 1
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0), i32 %127)
br label %129
129: ; preds = %125, %123
br label %157
130: ; preds = %13
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.10, i64 0, i64 0))
%132 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %8)
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0))
%134 = getelementptr inbounds [500000 x i32], [500000 x i32]* %7, i64 0, i64 0
%135 = load i32, i32* %8
%136 = call i32 @fnGenRandInput(i32* %134, i32 %135)
%137 = getelementptr inbounds [500000 x i32], [500000 x i32]* %7, i64 0, i64 0
%138 = load i32, i32* %8
%139 = call i32 @fnDispArray(i32* %137, i32 %138)
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.12, i64 0, i64 0))
%141 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %10)
%142 = getelementptr inbounds [500000 x i32], [500000 x i32]* %7, i64 0, i64 0
%143 = load i32, i32* %8
%144 = load i32, i32* %10
%145 = call i32 @fnLinSearch(i32* %142, i32 %143, i32 %144)
store i32 %145, i32* %9
%146 = load i32, i32* %9
%147 = icmp eq i32 %146, -1
br i1 %147, label %148, label %150
148: ; preds = %130
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.13, i64 0, i64 0))
br label %154
150: ; preds = %130
%151 = load i32, i32* %9
%152 = add nsw i32 %151, 1
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0), i32 %152)
br label %154
154: ; preds = %150, %148
br label %157
155: ; preds = %13
%156 = call i32 @exit(i32 0)
unreachable
157: ; preds = %13, %154, %129, %93
br label %13
}

LLVM IR (-O2):
%struct.timeval = type { double, i32 }
@.str = [35 x i8] c"\0A1.Plot the Graph \0A2.Binary Search\00"
@.str.1 = [24 x i8] c"\0A3.Linear Search\0A4.Exit\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [12 x i8] c"BSearch.dat\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [12 x i8] c"LSearch.dat\00"
@.str.7 = [8 x i8] c"%d\09%lf\0A\00"
@.str.8 = [79 x i8] c"\0AData Files generated and stored in files < BSearch.dat > and < LSearch.dat >.\00"
@.str.14 = [31 x i8] c"\0AElement found at %d position\0A\00"
@str = [19 x i8] c"\0AEnter your choice\00"
@str.19 = [40 x i8] c"\0AEnter the number of elements to Search\00"
@str.20 = [14 x i8] c"\0ASearch Array\00"
@str.21 = [33 x i8] c"\0AEnter the key element to Search\00"
@str.22 = [20 x i8] c"\0AElement not found \00"
@str.23 = [25 x i8] c"\0A Use a plotting utility\00"
define i32 @main() {
%1 = alloca <4 x i32>
%2 = bitcast <4 x i32>* %1 to %struct.timeval*
%3 = alloca [500000 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast <4 x i32>* %1 to i8*
%8 = bitcast [500000 x i32]* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = getelementptr inbounds [500000 x i32], [500000 x i32]* %3, i64 0, i64 0
%13 = getelementptr inbounds <4 x i32>, <4 x i32>* %1, i64 0, i64 2
%14 = bitcast <4 x i32>* %1 to double*
br label %15
15: ; preds = %113, %0
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%20 = load i32, i32* %6
switch i32 %20, label %113 [
i32 1, label %21
i32 2, label %75
i32 3, label %97
i32 4, label %117
]
21: ; preds = %15
%22 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%23 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 @time(i32* null)
%25 = call i32 @srand(i32 %24)
br label %26
26: ; preds = %21, %26
%27 = phi i32 [ 100, %21 ], [ %68, %26 ]
%28 = call i32 @fnGenRandInput(i32* %12, i32 %27)
%29 = load i32, i32* %12
store i32 %29, i32* %5
%30 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%31 = load i32, i32* %13
%32 = load double, double* %14
%33 = load i32, i32* %5
%34 = call i32 @fnLinSearch(i32* %12, i32 %27, i32 %33)
%35 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%36 = load <4 x i32>, <4 x i32>* %1
%37 = shufflevector <4 x i32> %36, <4 x i32> poison, <2 x i32> <i32 2, i32 undef>
%38 = insertelement <2 x i32> %37, i32 %31, i64 1
%39 = sitofp <2 x i32> %38 to <2 x double>
%40 = bitcast <4 x i32> %36 to <2 x double>
%41 = insertelement <2 x double> %40, double %32, i64 1
%42 = fdiv <2 x double> %41, <double 1.000000e+06, double 1.000000e+06>
%43 = fadd <2 x double> %42, %39
%44 = shufflevector <2 x double> %43, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%45 = fsub <2 x double> %43, %44
%46 = extractelement <2 x double> %45, i64 0
%47 = call i32 @fprintf(i32* %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %27, double %46)
%48 = call i32 @fnSort(i32* %12, i32 %27)
%49 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%50 = load i32, i32* %13
%51 = load double, double* %14
%52 = load i32, i32* %5
%53 = add nsw i32 %27, -1
%54 = call i32 @fnBinSearch(i32* %12, i32 %27, i32 %52, i32 0, i32 %53)
%55 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%56 = load <4 x i32>, <4 x i32>* %1
%57 = shufflevector <4 x i32> %56, <4 x i32> poison, <2 x i32> <i32 2, i32 undef>
%58 = insertelement <2 x i32> %57, i32 %50, i64 1
%59 = sitofp <2 x i32> %58 to <2 x double>
%60 = bitcast <4 x i32> %56 to <2 x double>
%61 = insertelement <2 x double> %60, double %51, i64 1
%62 = fdiv <2 x double> %61, <double 1.000000e+06, double 1.000000e+06>
%63 = fadd <2 x double> %62, %59
%64 = shufflevector <2 x double> %63, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%65 = fsub <2 x double> %63, %64
%66 = extractelement <2 x double> %65, i64 0
%67 = call i32 @fprintf(i32* %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 %27, double %66)
%68 = add nuw nsw i32 %27, 100
%69 = icmp ult i32 %27, 9900
br i1 %69, label %26, label %70
70: ; preds = %26
%71 = call i32 @fclose(i32* %22)
%72 = call i32 @fclose(i32* %23)
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @.str.8, i64 0, i64 0))
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.23, i64 0, i64 0))
br label %113
75: ; preds = %15
%76 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.19, i64 0, i64 0))
%77 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.20, i64 0, i64 0))
%79 = load i32, i32* %4
%80 = call i32 @fnGenRandInput(i32* %12, i32 %79)
%81 = load i32, i32* %4
%82 = call i32 @fnSort(i32* %12, i32 %81)
%83 = load i32, i32* %4
%84 = call i32 @fnDispArray(i32* %12, i32 %83)
%85 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.21, i64 0, i64 0))
%86 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%87 = load i32, i32* %4
%88 = load i32, i32* %5
%89 = add nsw i32 %87, -1
%90 = call i32 @fnBinSearch(i32* %12, i32 %87, i32 %88, i32 0, i32 %89)
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %94
92: ; preds = %75
%93 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.22, i64 0, i64 0))
br label %113
94: ; preds = %75
%95 = add nuw nsw i32 %90, 1
%96 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0), i32 %95)
br label %113
97: ; preds = %15
%98 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.19, i64 0, i64 0))
%99 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%100 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.20, i64 0, i64 0))
%101 = load i32, i32* %4
%102 = call i32 @fnGenRandInput(i32* %12, i32 %101)
%103 = load i32, i32* %4
%104 = call i32 @fnDispArray(i32* %12, i32 %103)
%105 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.21, i64 0, i64 0))
%106 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%107 = load i32, i32* %4
%108 = load i32, i32* %5
%109 = call i32 @fnLinSearch(i32* %12, i32 %107, i32 %108)
%110 = icmp eq i32 %109, -1
br i1 %110, label %111, label %114
111: ; preds = %97
%112 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.22, i64 0, i64 0))
br label %113
113: ; preds = %111, %114, %92, %94, %15, %70
br label %15
114: ; preds = %97
%115 = add nuw nsw i32 %109, 1
%116 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0), i32 %115)
br label %113
117: ; preds = %15
%118 = call i32 @exit(i32 0)
unreachable
}