#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int binSearch(int *, int, int, int *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  FILE *fp;
  int list[500], i = 0, j = 0, pivot = 0, count = 0, index = 0;
  srand(time(NULL));
  fp = fopen("Average.txt", "w");
  if (fp == NULL) {
    perror("Error opening file.\n");
    exit(EXIT_FAILURE);
  }
  for (i = 0; i < 500; i++)
    list[i] = rand() % 1000;
  for (i = 0; i < 500; i++)
    fprintf(fp, "%d ", list[i]);
  fclose(fp);
  for (i = 1; i < 500; i++) {
    pivot = list[i];
    j = i - 1;
    while (j >= 0 && list[j] > pivot) {
      list[j + 1] = list[j];
      j--;
      ++count;
    }
    list[j + 1] = pivot;
  }
  fp = fopen("Output.txt", "w");
  if (fp == NULL) {
    perror("Error opening file.\n");
    exit(EXIT_FAILURE);
  }
  for (i = 0; i < 500; i++)
    fprintf(fp, "%d ", list[i]);
  printf("The number of comparisons for SIZE elements in the average case of "
         "insertion sort was %d.\n",
         count);
  count = 0;
  for (i = 1; i < 500; i++) {
    pivot = list[i];
    j = i - 1;
    while (j >= 0 && list[j] > pivot) {
      list[j + 1] = list[j];
      j--;
    }
    ++count;
    list[j + 1] = pivot;
  }
  printf("The number of comparisons performed for SIZE elements in the best "
         "case of insertion sort was %d.\n",
         count);
  for (i = 1; i < 500; i++) {
    pivot = list[i];
    j = i - 1;
    while (j >= 0 && list[j] < pivot) {
      list[j + 1] = list[j];
      j--;
    }
    list[j + 1] = pivot;
  }
  count = 0;
  for (i = 1; i < 500; i++) {
    pivot = list[i];
    j = i - 1;
    while (j >= 0 && list[j] > pivot) {
      ++count;
      list[j + 1] = list[j];
      j--;
    }
    list[j + 1] = pivot;
  }
  printf("The number of comparisons performed for SIZE elements in the worst "
         "case of insertion sort was %d.\n",
         count);
  count = 0;
  index = rand() % 500;
  printf("The chosen index is %d which has a value of %d.\n", index,
         list[index]);
  printf("The key was found at position %d.\n",
         binSearch(list, 500, list[index], &count) + 1);
  printf("The number of comparisons performed in binary search was %d.\n",
         count);
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x800,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x7e4(%rbp)
movl   $0x0,-0x7e8(%rbp)
movl   $0x0,-0x7ec(%rbp)
movl   $0x0,-0x7f0(%rbp)
movl   $0x0,-0x7f4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe05(%rip),%rdi
lea    0xe0a(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1230 <main+0x90>
lea    0xdf1(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
movl   $0x0,-0x7e4(%rbp)
cmpl   $0x1f4,-0x7e4(%rbp)
jge    127b <main+0xdb>
mov    $0x0,%al
call   10c0 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
movslq -0x7e4(%rbp),%rax
mov    %edx,-0x7e0(%rbp,%rax,4)
mov    -0x7e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7e4(%rbp)
jmp    123a <main+0x9a>
movl   $0x0,-0x7e4(%rbp)
cmpl   $0x1f4,-0x7e4(%rbp)
jge    12c7 <main+0x127>
mov    -0x10(%rbp),%rdi
movslq -0x7e4(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%edx
lea    0xd75(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x7e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7e4(%rbp)
jmp    1285 <main+0xe5>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x7e4(%rbp)
cmpl   $0x1f4,-0x7e4(%rbp)
jge    13c1 <main+0x221>
movslq -0x7e4(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%eax
mov    %eax,-0x7ec(%rbp)
mov    -0x7e4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x7e8(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x7e8(%rbp)
mov    %al,-0x7f5(%rbp)
jl     133f <main+0x19f>
movslq -0x7e8(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%eax
cmp    -0x7ec(%rbp),%eax
setg   %al
mov    %al,-0x7f5(%rbp)
mov    -0x7f5(%rbp),%al
test   $0x1,%al
jne    1352 <main+0x1b2>
jmp    1395 <main+0x1f5>
movslq -0x7e8(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%ecx
mov    -0x7e8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x7e0(%rbp,%rax,4)
mov    -0x7e8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x7e8(%rbp)
mov    -0x7f0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7f0(%rbp)
jmp    130d <main+0x16d>
mov    -0x7ec(%rbp),%ecx
mov    -0x7e8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x7e0(%rbp,%rax,4)
mov    -0x7e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7e4(%rbp)
jmp    12da <main+0x13a>
lea    0xc5f(%rip),%rdi
lea    0xc3d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    13fd <main+0x25d>
lea    0xc24(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2bea(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
movl   $0x0,-0x7e4(%rbp)
cmpl   $0x1f4,-0x7e4(%rbp)
jge    1449 <main+0x2a9>
mov    -0x10(%rbp),%rdi
movslq -0x7e4(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%edx
lea    0xbf3(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x7e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7e4(%rbp)
jmp    1407 <main+0x267>
mov    -0x7f0(%rbp),%esi
lea    0xbdc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x7f0(%rbp)
movl   $0x1,-0x7e4(%rbp)
cmpl   $0x1f4,-0x7e4(%rbp)
jge    1558 <main+0x3b8>
movslq -0x7e4(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%eax
mov    %eax,-0x7ec(%rbp)
mov    -0x7e4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x7e8(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x7e8(%rbp)
mov    %al,-0x7f6(%rbp)
jl     14d6 <main+0x336>
movslq -0x7e8(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%eax
cmp    -0x7ec(%rbp),%eax
setg   %al
mov    %al,-0x7f6(%rbp)
mov    -0x7f6(%rbp),%al
test   $0x1,%al
jne    14e9 <main+0x349>
jmp    151d <main+0x37d>
movslq -0x7e8(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%ecx
mov    -0x7e8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x7e0(%rbp,%rax,4)
mov    -0x7e8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x7e8(%rbp)
jmp    14a4 <main+0x304>
mov    -0x7f0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7f0(%rbp)
mov    -0x7ec(%rbp),%ecx
mov    -0x7e8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x7e0(%rbp,%rax,4)
mov    -0x7e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7e4(%rbp)
jmp    1471 <main+0x2d1>
mov    -0x7f0(%rbp),%esi
lea    0xb28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x7e4(%rbp)
cmpl   $0x1f4,-0x7e4(%rbp)
jge    164e <main+0x4ae>
movslq -0x7e4(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%eax
mov    %eax,-0x7ec(%rbp)
mov    -0x7e4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x7e8(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x7e8(%rbp)
mov    %al,-0x7f7(%rbp)
jl     15db <main+0x43b>
movslq -0x7e8(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%eax
cmp    -0x7ec(%rbp),%eax
setl   %al
mov    %al,-0x7f7(%rbp)
mov    -0x7f7(%rbp),%al
test   $0x1,%al
jne    15ee <main+0x44e>
jmp    1622 <main+0x482>
movslq -0x7e8(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%ecx
mov    -0x7e8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x7e0(%rbp,%rax,4)
mov    -0x7e8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x7e8(%rbp)
jmp    15a9 <main+0x409>
mov    -0x7ec(%rbp),%ecx
mov    -0x7e8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x7e0(%rbp,%rax,4)
mov    -0x7e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7e4(%rbp)
jmp    1576 <main+0x3d6>
movl   $0x0,-0x7f0(%rbp)
movl   $0x1,-0x7e4(%rbp)
cmpl   $0x1f4,-0x7e4(%rbp)
jge    1749 <main+0x5a9>
movslq -0x7e4(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%eax
mov    %eax,-0x7ec(%rbp)
mov    -0x7e4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x7e8(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x7e8(%rbp)
mov    %al,-0x7f8(%rbp)
jl     16c7 <main+0x527>
movslq -0x7e8(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%eax
cmp    -0x7ec(%rbp),%eax
setg   %al
mov    %al,-0x7f8(%rbp)
mov    -0x7f8(%rbp),%al
test   $0x1,%al
jne    16da <main+0x53a>
jmp    171d <main+0x57d>
mov    -0x7f0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7f0(%rbp)
movslq -0x7e8(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%ecx
mov    -0x7e8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x7e0(%rbp,%rax,4)
mov    -0x7e8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x7e8(%rbp)
jmp    1695 <main+0x4f5>
mov    -0x7ec(%rbp),%ecx
mov    -0x7e8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %ecx,-0x7e0(%rbp,%rax,4)
mov    -0x7e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7e4(%rbp)
jmp    1662 <main+0x4c2>
mov    -0x7f0(%rbp),%esi
lea    0x999(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x7f0(%rbp)
mov    $0x0,%al
call   10c0 <rand@plt>
mov    $0x1f4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x7f4(%rbp)
mov    -0x7f4(%rbp),%esi
movslq -0x7f4(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%edx
lea    0x9bb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x7e0(%rbp),%rdi
movslq -0x7f4(%rbp),%rax
mov    -0x7e0(%rbp,%rax,4),%edx
mov    $0x1f4,%esi
lea    -0x7f0(%rbp),%rcx
call   1060 <binSearch@plt>
mov    %eax,%esi
add    $0x1,%esi
lea    0x9b3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x7f0(%rbp),%esi
lea    0x9c2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x7e8,%rsp
movl   $0x0,0xc(%rsp)
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe35(%rip),%rdi
lea    0xe3a(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     14c4 <main+0x324>
mov    %rax,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   10c0 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
mov    %eax,0x10(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x1f4,%rbx
jne    11f0 <main+0x50>
xor    %ebx,%ebx
lea    0xdf4(%rip),%r14
nop
mov    0x10(%rsp,%rbx,4),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <fprintf@plt>
add    $0x1,%rbx
cmp    $0x1f4,%rbx
jne    1230 <main+0x90>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %r12d,%r12d
mov    $0x1,%eax
jmp    1276 <main+0xd6>
xchg   %ax,%ax
mov    %edx,%r12d
movslq %esi,%rdx
mov    %ecx,0x10(%rsp,%rdx,4)
add    $0x1,%rax
cmp    $0x1f4,%rax
je     12b6 <main+0x116>
mov    %r12d,%edx
mov    0x10(%rsp,%rax,4),%ecx
lea    (%rax,%rdx,1),%r12d
mov    %rax,%rsi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    -0x1(%rsi),%rdi
mov    %edi,%ebx
mov    0x10(%rsp,%rbx,4),%ebx
cmp    %ecx,%ebx
jle    1260 <main+0xc0>
mov    %ebx,0x10(%rsp,%rsi,4)
add    $0x1,%edx
lea    0x1(%rdi),%rbx
mov    %rdi,%rsi
cmp    $0x1,%rbx
jg     1290 <main+0xf0>
xor    %esi,%esi
jmp    1263 <main+0xc3>
lea    0xd6a(%rip),%rdi
lea    0xd48(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     14c4 <main+0x324>
mov    %rax,%r14
xor    %ebx,%ebx
lea    0xd45(%rip),%r15
xchg   %ax,%ax
mov    0x10(%rsp,%rbx,4),%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <fprintf@plt>
add    $0x1,%rbx
cmp    $0x1f4,%rbx
jne    12e0 <main+0x140>
lea    0xd2f(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x0,0xc(%rsp)
mov    $0x1,%eax
jmp    1333 <main+0x193>
nopl   0x0(%rax)
movslq %edx,%rdx
mov    %ecx,0x10(%rsp,%rdx,4)
add    $0x1,%rax
cmp    $0x1f4,%rax
je     1363 <main+0x1c3>
mov    0x10(%rsp,%rax,4),%ecx
mov    %rax,%rdx
nopw   0x0(%rax,%rax,1)
lea    -0x1(%rdx),%rsi
mov    %esi,%edi
mov    0x10(%rsp,%rdi,4),%edi
cmp    %ecx,%edi
jle    1320 <main+0x180>
mov    %edi,0x10(%rsp,%rdx,4)
lea    0x1(%rsi),%rdi
mov    %rsi,%rdx
cmp    $0x1,%rdi
jg     1340 <main+0x1a0>
xor    %edx,%edx
jmp    1320 <main+0x180>
lea    0xd23(%rip),%rdi
mov    $0x1f3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
jmp    1393 <main+0x1f3>
nopl   (%rax)
movslq %edx,%rdx
mov    %ecx,0x10(%rsp,%rdx,4)
add    $0x1,%rax
cmp    $0x1f4,%rax
je     13c3 <main+0x223>
mov    0x10(%rsp,%rax,4),%ecx
mov    %rax,%rdx
nopw   0x0(%rax,%rax,1)
lea    -0x1(%rdx),%rsi
mov    %esi,%edi
mov    0x10(%rsp,%rdi,4),%edi
cmp    %ecx,%edi
jge    1380 <main+0x1e0>
mov    %edi,0x10(%rsp,%rdx,4)
lea    0x1(%rsi),%rdi
mov    %rsi,%rdx
cmp    $0x1,%rdi
jg     13a0 <main+0x200>
xor    %edx,%edx
jmp    1380 <main+0x1e0>
xor    %esi,%esi
mov    $0x1,%r8d
jmp    13e5 <main+0x245>
nopl   (%rax)
mov    %edx,%esi
cltq
mov    %ecx,0x10(%rsp,%rax,4)
add    $0x1,%r8
cmp    $0x1f4,%r8
je     1420 <main+0x280>
mov    %esi,%edx
mov    0x10(%rsp,%r8,4),%ecx
lea    (%r8,%rdx,1),%esi
mov    %r8,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x1(%rax),%rdi
mov    %edi,%ebx
mov    0x10(%rsp,%rbx,4),%ebx
cmp    %ecx,%ebx
jle    13d0 <main+0x230>
add    $0x1,%edx
mov    %ebx,0x10(%rsp,%rax,4)
mov    %rdi,%rax
test   %edi,%edi
jne    1400 <main+0x260>
xor    %eax,%eax
jmp    13d2 <main+0x232>
lea    0xcc8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x0,0xc(%rsp)
xor    %eax,%eax
call   10c0 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x1f4,%ecx,%ecx
sub    %ecx,%eax
movslq %eax,%rsi
mov    0x10(%rsp,%rsi,4),%ebx
lea    0xce9(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rcx
mov    $0x1f4,%esi
mov    %ebx,%edx
call   1060 <binSearch@plt>
lea    0x1(%rax),%esi
lea    0xcf1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xd02(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x7e8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xb43(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2b09(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"Average.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [21 x i8] c"Error opening file.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [4 x i8] c"%d \00"
@.str.4 = [11 x i8] c"Output.txt\00"
@.str.5 = [91 x i8] c"The number of comparisons for SIZE elements in the average case of insertion sort was %d.\0A\00"
@.str.6 = [98 x i8] c"The number of comparisons performed for SIZE elements in the best case of insertion sort was %d.\0A\00"
@.str.7 = [99 x i8] c"The number of comparisons performed for SIZE elements in the worst case of insertion sort was %d.\0A\00"
@.str.8 = [49 x i8] c"The chosen index is %d which has a value of %d.\0A\00"
@.str.9 = [35 x i8] c"The key was found at position %d.\0A\00"
@.str.10 = [62 x i8] c"The number of comparisons performed in binary search was %d.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [500 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%9 = call i32 @time(i32* null)
%10 = call i32 @srand(i32 %9)
%11 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %2
%12 = load i32*, i32** %2
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %18
14: ; preds = %0
%15 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %0
store i32 0, i32* %4
br label %19
19: ; preds = %28, %18
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 500
br i1 %21, label %22, label %31
22: ; preds = %19
%23 = call i32 (...) @rand()
%24 = srem i32 %23, 1000
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %26
store i32 %24, i32* %27
br label %28
28: ; preds = %22
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %19
31: ; preds = %19
store i32 0, i32* %4
br label %32
32: ; preds = %42, %31
%33 = load i32, i32* %4
%34 = icmp slt i32 %33, 500
br i1 %34, label %35, label %45
35: ; preds = %32
%36 = load i32*, i32** %2
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = call i32 @fprintf(i32* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %35
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 1
store i32 %44, i32* %4
br label %32
45: ; preds = %32
%46 = load i32*, i32** %2
%47 = call i32 @fclose(i32* %46)
store i32 1, i32* %4
br label %48
48: ; preds = %89, %45
%49 = load i32, i32* %4
%50 = icmp slt i32 %49, 500
br i1 %50, label %51, label %92
51: ; preds = %48
%52 = load i32, i32* %4
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %53
%55 = load i32, i32* %54
store i32 %55, i32* %6
%56 = load i32, i32* %4
%57 = sub nsw i32 %56, 1
store i32 %57, i32* %5
br label %58
58: ; preds = %70, %51
%59 = load i32, i32* %5
%60 = icmp sge i32 %59, 0
br i1 %60, label %61, label %68
61: ; preds = %58
%62 = load i32, i32* %5
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %63
%65 = load i32, i32* %64
%66 = load i32, i32* %6
%67 = icmp sgt i32 %65, %66
br label %68
68: ; preds = %61, %58
%69 = phi i1 [ false, %58 ], [ %67, %61 ]
br i1 %69, label %70, label %83
70: ; preds = %68
%71 = load i32, i32* %5
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %72
%74 = load i32, i32* %73
%75 = load i32, i32* %5
%76 = add nsw i32 %75, 1
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %77
store i32 %74, i32* %78
%79 = load i32, i32* %5
%80 = add nsw i32 %79, -1
store i32 %80, i32* %5
%81 = load i32, i32* %7
%82 = add nsw i32 %81, 1
store i32 %82, i32* %7
br label %58
83: ; preds = %68
%84 = load i32, i32* %6
%85 = load i32, i32* %5
%86 = add nsw i32 %85, 1
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %87
store i32 %84, i32* %88
br label %89
89: ; preds = %83
%90 = load i32, i32* %4
%91 = add nsw i32 %90, 1
store i32 %91, i32* %4
br label %48
92: ; preds = %48
%93 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %93, i32** %2
%94 = load i32*, i32** %2
%95 = icmp eq i32* %94, null
br i1 %95, label %96, label %100
96: ; preds = %92
%97 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%98 = load i32, i32* @EXIT_FAILURE
%99 = call i32 @exit(i32 %98)
unreachable
100: ; preds = %92
store i32 0, i32* %4
br label %101
101: ; preds = %111, %100
%102 = load i32, i32* %4
%103 = icmp slt i32 %102, 500
br i1 %103, label %104, label %114
104: ; preds = %101
%105 = load i32*, i32** %2
%106 = load i32, i32* %4
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %107
%109 = load i32, i32* %108
%110 = call i32 @fprintf(i32* %105, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %109)
br label %111
111: ; preds = %104
%112 = load i32, i32* %4
%113 = add nsw i32 %112, 1
store i32 %113, i32* %4
br label %101
114: ; preds = %101
%115 = load i32, i32* %7
%116 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.5, i64 0, i64 0), i32 %115)
store i32 0, i32* %7
store i32 1, i32* %4
br label %117
117: ; preds = %158, %114
%118 = load i32, i32* %4
%119 = icmp slt i32 %118, 500
br i1 %119, label %120, label %161
120: ; preds = %117
%121 = load i32, i32* %4
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %122
%124 = load i32, i32* %123
store i32 %124, i32* %6
%125 = load i32, i32* %4
%126 = sub nsw i32 %125, 1
store i32 %126, i32* %5
br label %127
127: ; preds = %139, %120
%128 = load i32, i32* %5
%129 = icmp sge i32 %128, 0
br i1 %129, label %130, label %137
130: ; preds = %127
%131 = load i32, i32* %5
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %132
%134 = load i32, i32* %133
%135 = load i32, i32* %6
%136 = icmp sgt i32 %134, %135
br label %137
137: ; preds = %130, %127
%138 = phi i1 [ false, %127 ], [ %136, %130 ]
br i1 %138, label %139, label %150
139: ; preds = %137
%140 = load i32, i32* %5
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %141
%143 = load i32, i32* %142
%144 = load i32, i32* %5
%145 = add nsw i32 %144, 1
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %146
store i32 %143, i32* %147
%148 = load i32, i32* %5
%149 = add nsw i32 %148, -1
store i32 %149, i32* %5
br label %127
150: ; preds = %137
%151 = load i32, i32* %7
%152 = add nsw i32 %151, 1
store i32 %152, i32* %7
%153 = load i32, i32* %6
%154 = load i32, i32* %5
%155 = add nsw i32 %154, 1
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %156
store i32 %153, i32* %157
br label %158
158: ; preds = %150
%159 = load i32, i32* %4
%160 = add nsw i32 %159, 1
store i32 %160, i32* %4
br label %117
161: ; preds = %117
%162 = load i32, i32* %7
%163 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.6, i64 0, i64 0), i32 %162)
store i32 1, i32* %4
br label %164
164: ; preds = %203, %161
%165 = load i32, i32* %4
%166 = icmp slt i32 %165, 500
br i1 %166, label %167, label %206
167: ; preds = %164
%168 = load i32, i32* %4
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %169
%171 = load i32, i32* %170
store i32 %171, i32* %6
%172 = load i32, i32* %4
%173 = sub nsw i32 %172, 1
store i32 %173, i32* %5
br label %174
174: ; preds = %186, %167
%175 = load i32, i32* %5
%176 = icmp sge i32 %175, 0
br i1 %176, label %177, label %184
177: ; preds = %174
%178 = load i32, i32* %5
%179 = sext i32 %178 to i64
%180 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %179
%181 = load i32, i32* %180
%182 = load i32, i32* %6
%183 = icmp slt i32 %181, %182
br label %184
184: ; preds = %177, %174
%185 = phi i1 [ false, %174 ], [ %183, %177 ]
br i1 %185, label %186, label %197
186: ; preds = %184
%187 = load i32, i32* %5
%188 = sext i32 %187 to i64
%189 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %188
%190 = load i32, i32* %189
%191 = load i32, i32* %5
%192 = add nsw i32 %191, 1
%193 = sext i32 %192 to i64
%194 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %193
store i32 %190, i32* %194
%195 = load i32, i32* %5
%196 = add nsw i32 %195, -1
store i32 %196, i32* %5
br label %174
197: ; preds = %184
%198 = load i32, i32* %6
%199 = load i32, i32* %5
%200 = add nsw i32 %199, 1
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %201
store i32 %198, i32* %202
br label %203
203: ; preds = %197
%204 = load i32, i32* %4
%205 = add nsw i32 %204, 1
store i32 %205, i32* %4
br label %164
206: ; preds = %164
store i32 0, i32* %7
store i32 1, i32* %4
br label %207
207: ; preds = %248, %206
%208 = load i32, i32* %4
%209 = icmp slt i32 %208, 500
br i1 %209, label %210, label %251
210: ; preds = %207
%211 = load i32, i32* %4
%212 = sext i32 %211 to i64
%213 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %212
%214 = load i32, i32* %213
store i32 %214, i32* %6
%215 = load i32, i32* %4
%216 = sub nsw i32 %215, 1
store i32 %216, i32* %5
br label %217
217: ; preds = %229, %210
%218 = load i32, i32* %5
%219 = icmp sge i32 %218, 0
br i1 %219, label %220, label %227
220: ; preds = %217
%221 = load i32, i32* %5
%222 = sext i32 %221 to i64
%223 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %222
%224 = load i32, i32* %223
%225 = load i32, i32* %6
%226 = icmp sgt i32 %224, %225
br label %227
227: ; preds = %220, %217
%228 = phi i1 [ false, %217 ], [ %226, %220 ]
br i1 %228, label %229, label %242
229: ; preds = %227
%230 = load i32, i32* %7
%231 = add nsw i32 %230, 1
store i32 %231, i32* %7
%232 = load i32, i32* %5
%233 = sext i32 %232 to i64
%234 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %233
%235 = load i32, i32* %234
%236 = load i32, i32* %5
%237 = add nsw i32 %236, 1
%238 = sext i32 %237 to i64
%239 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %238
store i32 %235, i32* %239
%240 = load i32, i32* %5
%241 = add nsw i32 %240, -1
store i32 %241, i32* %5
br label %217
242: ; preds = %227
%243 = load i32, i32* %6
%244 = load i32, i32* %5
%245 = add nsw i32 %244, 1
%246 = sext i32 %245 to i64
%247 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %246
store i32 %243, i32* %247
br label %248
248: ; preds = %242
%249 = load i32, i32* %4
%250 = add nsw i32 %249, 1
store i32 %250, i32* %4
br label %207
251: ; preds = %207
%252 = load i32, i32* %7
%253 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([99 x i8], [99 x i8]* @.str.7, i64 0, i64 0), i32 %252)
store i32 0, i32* %7
%254 = call i32 (...) @rand()
%255 = srem i32 %254, 500
store i32 %255, i32* %8
%256 = load i32, i32* %8
%257 = load i32, i32* %8
%258 = sext i32 %257 to i64
%259 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %258
%260 = load i32, i32* %259
%261 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i32 %256, i32 %260)
%262 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 0
%263 = load i32, i32* %8
%264 = sext i32 %263 to i64
%265 = getelementptr inbounds [500 x i32], [500 x i32]* %3, i64 0, i64 %264
%266 = load i32, i32* %265
%267 = call i32 @binSearch(i32* %262, i32 500, i32 %266, i32* %7)
%268 = add nsw i32 %267, 1
%269 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %268)
%270 = load i32, i32* %7
%271 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.10, i64 0, i64 0), i32 %270)
%272 = load i32*, i32** %2
%273 = call i32 @fclose(i32* %272)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Average.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [21 x i8] c"Error opening file.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [4 x i8] c"%d \00"
@.str.4 = [11 x i8] c"Output.txt\00"
@.str.5 = [91 x i8] c"The number of comparisons for SIZE elements in the average case of insertion sort was %d.\0A\00"
@.str.6 = [98 x i8] c"The number of comparisons performed for SIZE elements in the best case of insertion sort was %d.\0A\00"
@.str.7 = [99 x i8] c"The number of comparisons performed for SIZE elements in the worst case of insertion sort was %d.\0A\00"
@.str.8 = [49 x i8] c"The chosen index is %d which has a value of %d.\0A\00"
@.str.9 = [35 x i8] c"The key was found at position %d.\0A\00"
@.str.10 = [62 x i8] c"The number of comparisons performed in binary search was %d.\0A\00"
define i32 @main() {
%1 = alloca [500 x i32]
%2 = alloca i32
%3 = bitcast [500 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %0, %13
%14 = phi i64 [ %18, %13 ], [ 0, %0 ]
%15 = tail call i32 (...) @rand()
%16 = srem i32 %15, 1000
%17 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %14
store i32 %16, i32* %17
%18 = add nuw nsw i64 %14, 1
%19 = icmp eq i64 %18, 500
br i1 %19, label %20, label %13
20: ; preds = %13, %20
%21 = phi i64 [ %25, %20 ], [ 0, %13 ]
%22 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = tail call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = add nuw nsw i64 %21, 1
%26 = icmp eq i64 %25, 500
br i1 %26, label %27, label %20
27: ; preds = %20
%28 = tail call i32 @fclose(i32* %7)
br label %29
29: ; preds = %27, %48
%30 = phi i64 [ 1, %27 ], [ %54, %48 ]
%31 = phi i32 [ 0, %27 ], [ %49, %48 ]
%32 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %30
%33 = load i32, i32* %32
%34 = trunc i64 %30 to i32
%35 = add i32 %31, %34
br label %36
36: ; preds = %29, %44
%37 = phi i64 [ %30, %29 ], [ %39, %44 ]
%38 = phi i32 [ %31, %29 ], [ %46, %44 ]
%39 = add nsw i64 %37, -1
%40 = and i64 %39, 4294967295
%41 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = icmp sgt i32 %42, %33
br i1 %43, label %44, label %48
44: ; preds = %36
%45 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %37
store i32 %42, i32* %45
%46 = add nsw i32 %38, 1
%47 = icmp sgt i64 %37, 1
br i1 %47, label %36, label %48
48: ; preds = %44, %36
%49 = phi i32 [ %35, %44 ], [ %38, %36 ]
%50 = phi i64 [ 0, %44 ], [ %37, %36 ]
%51 = shl i64 %50, 32
%52 = ashr exact i64 %51, 32
%53 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %52
store i32 %33, i32* %53
%54 = add nuw nsw i64 %30, 1
%55 = icmp eq i64 %54, 500
br i1 %55, label %56, label %29
56: ; preds = %48
%57 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%58 = icmp eq i32* %57, null
br i1 %58, label %59, label %63
59: ; preds = %56
%60 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%61 = load i32, i32* @EXIT_FAILURE
%62 = tail call i32 @exit(i32 %61)
unreachable
63: ; preds = %56, %63
%64 = phi i64 [ %68, %63 ], [ 0, %56 ]
%65 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %64
%66 = load i32, i32* %65
%67 = tail call i32 @fprintf(i32* %57, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %66)
%68 = add nuw nsw i64 %64, 1
%69 = icmp eq i64 %68, 500
br i1 %69, label %70, label %63
70: ; preds = %63
%71 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.5, i64 0, i64 0), i32 %49)
store i32 0, i32* %2
br label %72
72: ; preds = %70, %86
%73 = phi i64 [ 1, %70 ], [ %91, %86 ]
%74 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %73
%75 = load i32, i32* %74
br label %76
76: ; preds = %72, %83
%77 = phi i64 [ %73, %72 ], [ %78, %83 ]
%78 = add nsw i64 %77, -1
%79 = and i64 %78, 4294967295
%80 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %79
%81 = load i32, i32* %80
%82 = icmp sgt i32 %81, %75
br i1 %82, label %83, label %86
83: ; preds = %76
%84 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %77
store i32 %81, i32* %84
%85 = icmp sgt i64 %77, 1
br i1 %85, label %76, label %86
86: ; preds = %83, %76
%87 = phi i64 [ 0, %83 ], [ %77, %76 ]
%88 = shl i64 %87, 32
%89 = ashr exact i64 %88, 32
%90 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %89
store i32 %75, i32* %90
%91 = add nuw nsw i64 %73, 1
%92 = icmp eq i64 %91, 500
br i1 %92, label %93, label %72
93: ; preds = %86
%94 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.6, i64 0, i64 0), i32 499)
br label %95
95: ; preds = %93, %109
%96 = phi i64 [ 1, %93 ], [ %114, %109 ]
%97 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %96
%98 = load i32, i32* %97
br label %99
99: ; preds = %95, %106
%100 = phi i64 [ %96, %95 ], [ %101, %106 ]
%101 = add nsw i64 %100, -1
%102 = and i64 %101, 4294967295
%103 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %102
%104 = load i32, i32* %103
%105 = icmp slt i32 %104, %98
br i1 %105, label %106, label %109
106: ; preds = %99
%107 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %100
store i32 %104, i32* %107
%108 = icmp sgt i64 %100, 1
br i1 %108, label %99, label %109
109: ; preds = %106, %99
%110 = phi i64 [ 0, %106 ], [ %100, %99 ]
%111 = shl i64 %110, 32
%112 = ashr exact i64 %111, 32
%113 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %112
store i32 %98, i32* %113
%114 = add nuw nsw i64 %96, 1
%115 = icmp eq i64 %114, 500
br i1 %115, label %116, label %95
116: ; preds = %109, %135
%117 = phi i64 [ %141, %135 ], [ 1, %109 ]
%118 = phi i32 [ %136, %135 ], [ 0, %109 ]
%119 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %117
%120 = load i32, i32* %119
%121 = trunc i64 %117 to i32
%122 = add i32 %118, %121
br label %123
123: ; preds = %116, %131
%124 = phi i64 [ %117, %116 ], [ %126, %131 ]
%125 = phi i32 [ %118, %116 ], [ %132, %131 ]
%126 = add nsw i64 %124, -1
%127 = and i64 %126, 4294967295
%128 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %127
%129 = load i32, i32* %128
%130 = icmp sgt i32 %129, %120
br i1 %130, label %131, label %135
131: ; preds = %123
%132 = add i32 %125, 1
%133 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %124
store i32 %129, i32* %133
%134 = icmp eq i32 %132, %122
br i1 %134, label %135, label %123
135: ; preds = %131, %123
%136 = phi i32 [ %122, %131 ], [ %125, %123 ]
%137 = phi i64 [ 0, %131 ], [ %124, %123 ]
%138 = shl i64 %137, 32
%139 = ashr exact i64 %138, 32
%140 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %139
store i32 %120, i32* %140
%141 = add nuw nsw i64 %117, 1
%142 = icmp eq i64 %141, 500
br i1 %142, label %143, label %116
143: ; preds = %135
%144 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([99 x i8], [99 x i8]* @.str.7, i64 0, i64 0), i32 %136)
store i32 0, i32* %2
%145 = tail call i32 (...) @rand()
%146 = srem i32 %145, 500
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 %147
%149 = load i32, i32* %148
%150 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.8, i64 0, i64 0), i32 %146, i32 %149)
%151 = getelementptr inbounds [500 x i32], [500 x i32]* %1, i64 0, i64 0
%152 = call i32 @binSearch(i32* %151, i32 500, i32 %149, i32* %2)
%153 = add nsw i32 %152, 1
%154 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), i32 %153)
%155 = load i32, i32* %2
%156 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.10, i64 0, i64 0), i32 %155)
%157 = call i32 @fclose(i32* %57)
ret i32 0
}