#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*/ Improved_Bubble_Sort(long *, int, double *, double *);
long *Load_File(char *, int *);
int Save_File(char *, long *, int);
int /*<<< orphan*/ Shell_Insertion_Sort(long *, int, double *, double *);
scalar_t__ clock();
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main(int Argc, char **Argv) {
  double cstart, cend;
  int Response = 0;
  int Saved = 0;
  int Size = 0;
  double N_Comp = 0;
  double N_Move = 0;
  long *Array = NULL;
  char Filename[(50)] = "";
  while (1) {
    printf("\n");
    printf("TEST MENU\n");
    printf("1. Load array from file\n");
    printf("2. Save array to file\n");
    printf("3. Shell Sort (Insertion)\n");
    printf("4. Improved Bubble Sort\n");
    printf("5. Exit\n");
    printf("Enter your choice: ");
    scanf("%d", &Response);
    getchar();
    if (Response == 5) {
      if (Array != NULL) {
        printf("Removing and deallocating array\n");
        free((void *)Array);
        Array = NULL;
        printf("done!\n");
      }
      return ((0));
    }
    if (Response == 1) {
      if (Array != NULL) {
        printf("\nRemoving and deallocating array\n");
        free((void *)Array);
        Array = NULL;
        printf("done!\n");
      }
      printf("\nEnter input file (including path): ");
      scanf("%s", Filename);
      Array = Load_File(Filename, &Size);
      if (Size <= 0) {
        printf("\nError in inputs, file not loaded..\n");
        if (Array != NULL) {
          printf("Removing and deallocating array\n");
          free((void *)Array);
          Array = NULL;
          printf("done!\n");
        }
      } else {
        printf("\nLoaded %d long integers\n", Size);
      }
    }
    if (Response == 2) {
      if (Array == NULL) {
        printf("\nMust load in data from file (option 1) before saving one!\n");
      } else {
        printf("\nEnter output file (including path): ");
        scanf("%s", Filename);
        Saved = Save_File(Filename, Array, Size);
        if (Saved != Size) {
          printf("Error in saving!  Only %d out of %d long integers saved\n",
                 Saved, Size);
        } else {
          printf("Saved all %d long integers\n", Saved);
        }
      }
    }
    if ((Response > 2) && (Response < 5)) {
      if (Array == NULL) {
        printf(
            "\nMust load in data from file (option 1) before sorting one!\n");
      } else {
        cstart = (double)clock();
        N_Comp = 0;
        N_Move = 0;
        switch (Response) {
        case 3:
          printf("Sorting by Shell Sort (Insertion)\n");
          Shell_Insertion_Sort(Array, Size, &N_Comp, &N_Move);
          break;
        case 4:
          printf("Sorting by Improved Bubble Sort\n");
          Improved_Bubble_Sort(Array, Size, &N_Comp, &N_Move);
          break;
        }
        cend = (double)clock();
        printf("\n");
        printf(" Elapsed Time (sec): %f\n", (cend - cstart) / 1000000);
        printf("      # Comparisons: %f\n", N_Comp);
        printf("            # Moves: %f\n", N_Move);
      }
    }
  }
  return ((0));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   1090 <memset@plt>
lea    0x101c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xe27(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   10c0 <scanf@plt>
mov    $0x0,%al
call   10a0 <getchar@plt>
cmpl   $0x5,-0x24(%rbp)
jne    12cc <main+0x12c>
cmpq   $0x0,-0x48(%rbp)
je     12c1 <main+0x121>
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x48(%rbp)
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret
cmpl   $0x1,-0x24(%rbp)
jne    13aa <main+0x20a>
cmpq   $0x0,-0x48(%rbp)
je     130e <main+0x16e>
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x48(%rbp)
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   10c0 <scanf@plt>
lea    -0x80(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
call   1080 <Load_File@plt>
mov    %rax,-0x48(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jg     1394 <main+0x1f4>
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpq   $0x0,-0x48(%rbp)
je     138f <main+0x1ef>
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x48(%rbp)
lea    0xd0f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    13a5 <main+0x205>
mov    -0x2c(%rbp),%esi
lea    0xd6f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    13aa <main+0x20a>
cmpl   $0x2,-0x24(%rbp)
jne    1445 <main+0x2a5>
cmpq   $0x0,-0x48(%rbp)
jne    13d2 <main+0x232>
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1440 <main+0x2a0>
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xcfa(%rip),%rdi
mov    $0x0,%al
call   10c0 <scanf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <Save_File@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
je     142a <main+0x28a>
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    143b <main+0x29b>
mov    -0x28(%rbp),%esi
lea    0xd8e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1440 <main+0x2a0>
jmp    1445 <main+0x2a5>
cmpl   $0x2,-0x24(%rbp)
jle    157a <main+0x3da>
cmpl   $0x5,-0x24(%rbp)
jge    157a <main+0x3da>
cmpq   $0x0,-0x48(%rbp)
jne    1477 <main+0x2d7>
lea    0xd73(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1575 <main+0x3d5>
xor    %eax,%eax
call   1060 <clock@plt>
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x84(%rbp)
sub    $0x3,%eax
je     14c3 <main+0x323>
jmp    14af <main+0x30f>
mov    -0x84(%rbp),%eax
sub    $0x4,%eax
je     14ea <main+0x34a>
jmp    150c <main+0x36c>
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x2c(%rbp),%esi
lea    -0x38(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   10b0 <Shell_Insertion_Sort@plt>
jmp    150c <main+0x36c>
lea    0xd4d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x2c(%rbp),%esi
lea    -0x38(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   1050 <Improved_Bubble_Sort@plt>
mov    $0x0,%al
call   1060 <clock@plt>
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xcf5(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xac3(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xd17(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movsd  -0x38(%rbp),%xmm0
lea    0xd1d(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movsd  -0x40(%rbp),%xmm0
lea    0xd23(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
jmp    157a <main+0x3da>
jmp    11f6 <main+0x56>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movw   $0x0,0x50(%rsp)
lea    0xf28(%rip),%r14
lea    0xf2b(%rip),%r15
lea    0xf3c(%rip),%r12
lea    0xf4b(%rip),%r13
lea    0xf5e(%rip),%rbp
xor    %ebx,%ebx
jmp    122c <main+0x7c>
nop
lea    0xfb4(%rip),%rdi
call   1060 <puts@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    %r14,%rdi
call   1060 <puts@plt>
mov    %r15,%rdi
call   1060 <puts@plt>
mov    %r12,%rdi
call   1060 <puts@plt>
mov    %r13,%rdi
call   1060 <puts@plt>
mov    %rbp,%rdi
call   1060 <puts@plt>
lea    0xf2c(%rip),%rdi
call   1060 <puts@plt>
lea    0xd97(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd9d(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
xor    %eax,%eax
call   10b0 <getchar@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
je     12c0 <main+0x110>
cmp    $0x5,%eax
je     1512 <main+0x362>
cmp    $0x2,%eax
je     136e <main+0x1be>
jmp    1408 <main+0x258>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %rbx,%rbx
je     12e5 <main+0x135>
lea    0xfaa(%rip),%rdi
call   1060 <puts@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
lea    0xfb7(%rip),%rdi
call   1060 <puts@plt>
lea    0xd33(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd4a(%rip),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    %rbx,%rdi
mov    %rsp,%rsi
call   10a0 <Load_File@plt>
mov    %rax,%rbx
mov    (%rsp),%esi
test   %esi,%esi
jle    132e <main+0x17e>
lea    0xd22(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
jmp    1361 <main+0x1b1>
lea    0xf1d(%rip),%rdi
call   1060 <puts@plt>
test   %rbx,%rbx
je     135f <main+0x1af>
lea    0xf31(%rip),%rdi
call   1060 <puts@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
lea    0xf3d(%rip),%rdi
call   1060 <puts@plt>
xor    %ebx,%ebx
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
jne    1408 <main+0x258>
test   %rbx,%rbx
je     13c7 <main+0x217>
mov    %r12,%r13
mov    %r15,%r12
mov    %r14,%r15
lea    0xcde(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xcb3(%rip),%rdi
lea    0x20(%rsp),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    (%rsp),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <Save_File@plt>
mov    (%rsp),%edx
cmp    %edx,%eax
jne    13e8 <main+0x238>
lea    0xd04(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
jmp    13f8 <main+0x248>
lea    0xe49(%rip),%rdi
call   1060 <puts@plt>
mov    0x4(%rsp),%eax
add    $0xfffffffd,%eax
cmp    $0x2,%eax
jae    122c <main+0x7c>
jmp    1220 <main+0x70>
lea    0xc98(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15,%r14
mov    %r12,%r15
mov    %r13,%r12
lea    0xd57(%rip),%r13
mov    0x4(%rsp),%eax
add    $0xfffffffd,%eax
cmp    $0x2,%eax
jae    122c <main+0x7c>
test   %rbx,%rbx
je     1220 <main+0x70>
xor    %eax,%eax
call   1080 <clock@plt>
mov    %rax,%rbp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x4(%rsp),%eax
cmp    $0x4,%eax
je     146e <main+0x2be>
cmp    $0x3,%eax
jne    148f <main+0x2df>
lea    0xd67(%rip),%rdi
call   1060 <puts@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   10c0 <Shell_Insertion_Sort@plt>
jmp    148f <main+0x2df>
lea    0xd24(%rip),%rdi
call   1060 <puts@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1070 <Improved_Bubble_Sort@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rbp,%xmm0
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   1080 <clock@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
subsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
mov    $0xa,%edi
call   1050 <putchar@plt>
movsd  0x18(%rsp),%xmm0
divsd  0xb30(%rip),%xmm0
lea    0xc05(%rip),%rdi
mov    $0x1,%al
call   1090 <printf@plt>
movsd  0x10(%rsp),%xmm0
lea    0xc0a(%rip),%rdi
mov    $0x1,%al
call   1090 <printf@plt>
movsd  0x8(%rsp),%xmm0
lea    0xc0f(%rip),%rdi
mov    $0x1,%al
call   1090 <printf@plt>
lea    0xc6c(%rip),%rbp
jmp    122c <main+0x7c>
test   %rbx,%rbx
je     1537 <main+0x387>
lea    0xd59(%rip),%rdi
call   1060 <puts@plt>
mov    %rbx,%rdi
call   1040 <free@plt>
lea    0xd65(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [11 x i8] c"TEST MENU\0A\00"
@.str.2 = [25 x i8] c"1. Load array from file\0A\00"
@.str.3 = [23 x i8] c"2. Save array to file\0A\00"
@.str.4 = [27 x i8] c"3. Shell Sort (Insertion)\0A\00"
@.str.5 = [25 x i8] c"4. Improved Bubble Sort\0A\00"
@.str.6 = [9 x i8] c"5. Exit\0A\00"
@.str.7 = [20 x i8] c"Enter your choice: \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [33 x i8] c"Removing and deallocating array\0A\00"
@.str.10 = [7 x i8] c"done!\0A\00"
@.str.11 = [34 x i8] c"\0ARemoving and deallocating array\0A\00"
@.str.12 = [37 x i8] c"\0AEnter input file (including path): \00"
@.str.13 = [3 x i8] c"%s\00"
@.str.14 = [37 x i8] c"\0AError in inputs, file not loaded..\0A\00"
@.str.15 = [26 x i8] c"\0ALoaded %d long integers\0A\00"
@.str.16 = [60 x i8] c"\0AMust load in data from file (option 1) before saving one!\0A\00"
@.str.17 = [38 x i8] c"\0AEnter output file (including path): \00"
@.str.18 = [57 x i8] c"Error in saving! Only %d out of %d long integers saved\0A\00"
@.str.19 = [28 x i8] c"Saved all %d long integers\0A\00"
@.str.20 = [61 x i8] c"\0AMust load in data from file (option 1) before sorting one!\0A\00"
@.str.21 = [35 x i8] c"Sorting by Shell Sort (Insertion)\0A\00"
@.str.22 = [33 x i8] c"Sorting by Improved Bubble Sort\0A\00"
@.str.23 = [25 x i8] c" Elapsed Time (sec): %f\0A\00"
@.str.24 = [25 x i8] c" # Comparisons: %f\0A\00"
@.str.25 = [25 x i8] c" # Moves: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca i64*
%14 = alloca [50 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %12
store i64* null, i64** %13
%15 = bitcast [50 x i8]* %14 to i8*
br label %16
16: ; preds = %2, %141
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %8)
%26 = call i32 (...) @getchar()
%27 = load i32, i32* %8
%28 = icmp eq i32 %27, 5
br i1 %28, label %29, label %39
29: ; preds = %16
%30 = load i64*, i64** %13
%31 = icmp ne i64* %30, null
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
%34 = load i64*, i64** %13
%35 = bitcast i64* %34 to i8*
%36 = call i32 @free(i8* %35)
store i64* null, i64** %13
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
br label %38
38: ; preds = %32, %29
ret i32 0
39: ; preds = %16
%40 = load i32, i32* %8
%41 = icmp eq i32 %40, 1
br i1 %41, label %42, label %74
42: ; preds = %39
%43 = load i64*, i64** %13
%44 = icmp ne i64* %43, null
br i1 %44, label %45, label %51
45: ; preds = %42
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i64 0, i64 0))
%47 = load i64*, i64** %13
%48 = bitcast i64* %47 to i8*
%49 = call i32 @free(i8* %48)
store i64* null, i64** %13
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
br label %51
51: ; preds = %45, %42
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0))
%53 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 0, i64 0
%54 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* %53)
%55 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 0, i64 0
%56 = call i64* @Load_File(i8* %55, i32* %10)
store i64* %56, i64** %13
%57 = load i32, i32* %10
%58 = icmp sle i32 %57, 0
br i1 %58, label %59, label %70
59: ; preds = %51
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.14, i64 0, i64 0))
%61 = load i64*, i64** %13
%62 = icmp ne i64* %61, null
br i1 %62, label %63, label %69
63: ; preds = %59
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0))
%65 = load i64*, i64** %13
%66 = bitcast i64* %65 to i8*
%67 = call i32 @free(i8* %66)
store i64* null, i64** %13
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
br label %69
69: ; preds = %63, %59
br label %73
70: ; preds = %51
%71 = load i32, i32* %10
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.15, i64 0, i64 0), i32 %71)
br label %73
73: ; preds = %70, %69
br label %74
74: ; preds = %73, %39
%75 = load i32, i32* %8
%76 = icmp eq i32 %75, 2
br i1 %76, label %77, label %102
77: ; preds = %74
%78 = load i64*, i64** %13
%79 = icmp eq i64* %78, null
br i1 %79, label %80, label %82
80: ; preds = %77
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.16, i64 0, i64 0))
br label %101
82: ; preds = %77
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.17, i64 0, i64 0))
%84 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 0, i64 0
%85 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* %84)
%86 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 0, i64 0
%87 = load i64*, i64** %13
%88 = load i32, i32* %10
%89 = call i32 @Save_File(i8* %86, i64* %87, i32 %88)
store i32 %89, i32* %9
%90 = load i32, i32* %9
%91 = load i32, i32* %10
%92 = icmp ne i32 %90, %91
br i1 %92, label %93, label %97
93: ; preds = %82
%94 = load i32, i32* %9
%95 = load i32, i32* %10
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.18, i64 0, i64 0), i32 %94, i32 %95)
br label %100
97: ; preds = %82
%98 = load i32, i32* %9
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.19, i64 0, i64 0), i32 %98)
br label %100
100: ; preds = %97, %93
br label %101
101: ; preds = %100, %80
br label %102
102: ; preds = %101, %74
%103 = load i32, i32* %8
%104 = icmp sgt i32 %103, 2
br i1 %104, label %105, label %141
105: ; preds = %102
%106 = load i32, i32* %8
%107 = icmp slt i32 %106, 5
br i1 %107, label %108, label %141
108: ; preds = %105
%109 = load i64*, i64** %13
%110 = icmp eq i64* %109, null
br i1 %110, label %111, label %113
111: ; preds = %108
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.20, i64 0, i64 0))
br label %140
113: ; preds = %108
%114 = call i64 (...) @clock()
%115 = sitofp i64 %114 to double
store double %115, double* %6
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %12
%116 = load i32, i32* %8
switch i32 %116, label %127 [
i32 3, label %117
i32 4, label %122
]
117: ; preds = %113
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.21, i64 0, i64 0))
%119 = load i64*, i64** %13
%120 = load i32, i32* %10
%121 = call i32 @Shell_Insertion_Sort(i64* %119, i32 %120, double* %11, double* %12)
br label %127
122: ; preds = %113
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.22, i64 0, i64 0))
%124 = load i64*, i64** %13
%125 = load i32, i32* %10
%126 = call i32 @Improved_Bubble_Sort(i64* %124, i32 %125, double* %11, double* %12)
br label %127
127: ; preds = %113, %122, %117
%128 = call i64 (...) @clock()
%129 = sitofp i64 %128 to double
store double %129, double* %7
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%131 = load double, double* %7
%132 = load double, double* %6
%133 = fsub double %131, %132
%134 = fdiv double %133, 1.000000e+06
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.23, i64 0, i64 0), double %134)
%136 = load double, double* %11
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.24, i64 0, i64 0), double %136)
%138 = load double, double* %12
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.25, i64 0, i64 0), double %138)
br label %140
140: ; preds = %127, %111
br label %141
141: ; preds = %140, %105, %102
br label %16
}

LLVM IR (-O2):
@.str.7 = [20 x i8] c"Enter your choice: \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.12 = [37 x i8] c"\0AEnter input file (including path): \00"
@.str.13 = [3 x i8] c"%s\00"
@.str.15 = [26 x i8] c"\0ALoaded %d long integers\0A\00"
@.str.17 = [38 x i8] c"\0AEnter output file (including path): \00"
@.str.18 = [57 x i8] c"Error in saving! Only %d out of %d long integers saved\0A\00"
@.str.19 = [28 x i8] c"Saved all %d long integers\0A\00"
@.str.23 = [25 x i8] c" Elapsed Time (sec): %f\0A\00"
@.str.24 = [25 x i8] c" # Comparisons: %f\0A\00"
@.str.25 = [25 x i8] c" # Moves: %f\0A\00"
@str = [10 x i8] c"TEST MENU\00"
@str.26 = [24 x i8] c"1. Load array from file\00"
@str.27 = [22 x i8] c"2. Save array to file\00"
@str.28 = [26 x i8] c"3. Shell Sort (Insertion)\00"
@str.29 = [24 x i8] c"4. Improved Bubble Sort\00"
@str.30 = [8 x i8] c"5. Exit\00"
@str.31 = [32 x i8] c"Sorting by Improved Bubble Sort\00"
@str.32 = [34 x i8] c"Sorting by Shell Sort (Insertion)\00"
@str.33 = [60 x i8] c"\0AMust load in data from file (option 1) before sorting one!\00"
@str.34 = [59 x i8] c"\0AMust load in data from file (option 1) before saving one!\00"
@str.35 = [36 x i8] c"\0AError in inputs, file not loaded..\00"
@str.38 = [33 x i8] c"\0ARemoving and deallocating array\00"
@str.40 = [32 x i8] c"Removing and deallocating array\00"
@str.41 = [6 x i8] c"done!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca [50 x i8]
%8 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%9 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%10 = bitcast double* %5 to i8*
store double 0.000000e+00, double* %5
%11 = bitcast double* %6 to i8*
store double 0.000000e+00, double* %6
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %7, i64 0, i64 0
br label %13
13: ; preds = %86, %2
%14 = phi i64* [ null, %2 ], [ %62, %86 ]
%15 = call i32 @putchar(i32 10)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.26, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.27, i64 0, i64 0))
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.28, i64 0, i64 0))
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.29, i64 0, i64 0))
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.30, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %3)
%24 = call i32 (...) @getchar()
%25 = load i32, i32* %3
switch i32 %25, label %60 [
i32 5, label %26
i32 1, label %34
]
26: ; preds = %13
%27 = icmp eq i64* %14, null
br i1 %27, label %33, label %28
28: ; preds = %26
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.40, i64 0, i64 0))
%30 = bitcast i64* %14 to i8*
%31 = call i32 @free(i8* %30)
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.41, i64 0, i64 0))
br label %33
33: ; preds = %28, %26
ret i32 0
34: ; preds = %13
%35 = icmp eq i64* %14, null
br i1 %35, label %41, label %36
36: ; preds = %34
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.38, i64 0, i64 0))
%38 = bitcast i64* %14 to i8*
%39 = call i32 @free(i8* %38)
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.41, i64 0, i64 0))
br label %41
41: ; preds = %36, %34
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0))
%43 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* %12)
%44 = call i64* @Load_File(i8* %12, i32* %4)
%45 = load i32, i32* %4
%46 = icmp slt i32 %45, 1
br i1 %46, label %47, label %55
47: ; preds = %41
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.35, i64 0, i64 0))
%49 = icmp eq i64* %44, null
br i1 %49, label %57, label %50
50: ; preds = %47
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.40, i64 0, i64 0))
%52 = bitcast i64* %44 to i8*
%53 = call i32 @free(i8* %52)
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.41, i64 0, i64 0))
br label %57
55: ; preds = %41
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.15, i64 0, i64 0), i32 %45)
br label %57
57: ; preds = %47, %50, %55
%58 = phi i64* [ %44, %55 ], [ null, %47 ], [ null, %50 ]
%59 = load i32, i32* %3
br label %60
60: ; preds = %57, %13
%61 = phi i32 [ %59, %57 ], [ %25, %13 ]
%62 = phi i64* [ %58, %57 ], [ %14, %13 ]
%63 = icmp eq i32 %61, 2
br i1 %63, label %64, label %77
64: ; preds = %60
%65 = icmp eq i64* %62, null
br i1 %65, label %81, label %66
66: ; preds = %64
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.17, i64 0, i64 0))
%68 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* %12)
%69 = load i32, i32* %4
%70 = call i32 @Save_File(i8* %12, i64* %62, i32 %69)
%71 = load i32, i32* %4
%72 = icmp eq i32 %70, %71
br i1 %72, label %75, label %73
73: ; preds = %66
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.18, i64 0, i64 0), i32 %70, i32 %71)
br label %77
75: ; preds = %66
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.19, i64 0, i64 0), i32 %70)
br label %77
77: ; preds = %75, %73, %60
%78 = load i32, i32* %3
%79 = add i32 %78, -3
%80 = icmp ult i32 %79, 2
br i1 %80, label %87, label %86
81: ; preds = %64
%82 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.34, i64 0, i64 0))
%83 = load i32, i32* %3
%84 = add i32 %83, -3
%85 = icmp ult i32 %84, 2
br i1 %85, label %89, label %86
86: ; preds = %81, %89, %103, %77
br label %13
87: ; preds = %77
%88 = icmp eq i64* %62, null
br i1 %88, label %89, label %91
89: ; preds = %81, %87
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.33, i64 0, i64 0))
br label %86
91: ; preds = %87
%92 = call i64 (...) @clock()
%93 = sitofp i64 %92 to double
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %6
%94 = load i32, i32* %3
switch i32 %94, label %103 [
i32 3, label %95
i32 4, label %99
]
95: ; preds = %91
%96 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.32, i64 0, i64 0))
%97 = load i32, i32* %4
%98 = call i32 @Shell_Insertion_Sort(i64* %62, i32 %97, double* %5, double* %6)
br label %103
99: ; preds = %91
%100 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.31, i64 0, i64 0))
%101 = load i32, i32* %4
%102 = call i32 @Improved_Bubble_Sort(i64* %62, i32 %101, double* %5, double* %6)
br label %103
103: ; preds = %91, %99, %95
%104 = call i64 (...) @clock()
%105 = sitofp i64 %104 to double
%106 = call i32 @putchar(i32 10)
%107 = fsub double %105, %93
%108 = fdiv double %107, 1.000000e+06
%109 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.23, i64 0, i64 0), double %108)
%110 = load double, double* %5
%111 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.24, i64 0, i64 0), double %110)
%112 = load double, double* %6
%113 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.25, i64 0, i64 0), double %112)
br label %86
}