#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*/ accept(int *, unsigned int *);
int /*<<< orphan*/ bubsort(int *, unsigned int);
int /*<<< orphan*/ display(int *, unsigned int);
int /*<<< orphan*/ inssort(int *, unsigned int);
int /*<<< orphan*/ mrgsort(int *, unsigned int);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ qiksort(int *, unsigned int);
int /*<<< orphan*/ scanf(char *, unsigned int *);
int /*<<< orphan*/ selsort(int *, unsigned int);
int main() {
  unsigned n, ch;
  int a[50];
  n = 0;
  do {
    puts("What would you like to do?");
    puts(" ( 0) Exit");
    puts(" ( 1) Populate Array");
    puts(" ( 2) Print Array");
    puts(" ( 3) Bubble Sort");
    puts(" ( 4) Insertion Sort");
    puts(" ( 5) Selection Sort");
    puts(" ( 6) Quick Sort");
    puts(" ( 7) Merge Sort");
    scanf(" %u%*c", &ch);
    switch (ch) {
    case 0:
      puts("Bye!");
      break;
    case 1:
      accept(a, &n);
      break;
    case 2:
      display(a, n);
      break;
    case 3:
      bubsort(a, n);
      display(a, n);
      break;
    case 4:
      inssort(a, n);
      display(a, n);
      break;
    case 5:
      selsort(a, n);
      display(a, n);
      break;
    case 6:
      qiksort(a, n);
      display(a, n);
      break;
    case 7:
      mrgsort(a, n);
      display(a, n);
      break;
    default:
      puts("Incorrect Choice!");
      break;
    }
    putchar('\n');
  } while (ch);
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe60(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6f(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe77(%rip),%rdi
call   1040 <puts@plt>
lea    0xe7d(%rip),%rdi
call   1040 <puts@plt>
lea    0xe83(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8c(%rip),%rdi
call   1040 <puts@plt>
lea    0xe95(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9f(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %rax,-0xe8(%rbp)
sub    $0x7,%rax
ja     1349 <main+0x1a9>
mov    -0xe8(%rbp),%rax
lea    0xda9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe6b(%rip),%rdi
call   1040 <puts@plt>
jmp    1355 <main+0x1b5>
lea    -0xe0(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   10b0 <accept@plt>
jmp    1355 <main+0x1b5>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <display@plt>
jmp    1355 <main+0x1b5>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <bubsort@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <display@plt>
jmp    1355 <main+0x1b5>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1090 <inssort@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <display@plt>
jmp    1355 <main+0x1b5>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1080 <selsort@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <display@plt>
jmp    1355 <main+0x1b5>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   10c0 <qiksort@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <display@plt>
jmp    1355 <main+0x1b5>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1070 <mrgsort@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <display@plt>
jmp    1355 <main+0x1b5>
lea    0xd87(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11b9 <main+0x19>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
movl   $0x0,0x8(%rsp)
lea    0xee9(%rip),%r15
lea    0xef3(%rip),%r12
lea    0xefd(%rip),%r13
lea    0xc(%rsp),%rbx
lea    0xe26(%rip),%r14
lea    0x10(%rsp),%rbp
jmp    1211 <main+0x71>
mov    0x8(%rsp),%esi
mov    %rbp,%rdi
call   1070 <mrgsort@plt>
nopl   (%rax)
mov    0x8(%rsp),%esi
mov    %rbp,%rdi
call   1050 <display@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0xc(%rsp)
je     1303 <main+0x163>
lea    0xe08(%rip),%rdi
call   1040 <puts@plt>
lea    0xe17(%rip),%rdi
call   1040 <puts@plt>
lea    0xe16(%rip),%rdi
call   1040 <puts@plt>
lea    0xe1f(%rip),%rdi
call   1040 <puts@plt>
lea    0xe25(%rip),%rdi
call   1040 <puts@plt>
lea    0xe2b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe34(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   10a0 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x7,%rax
ja     129c <main+0xfc>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
lea    0xe38(%rip),%rdi
jmp    12a3 <main+0x103>
lea    0xe34(%rip),%rdi
call   1040 <puts@plt>
jmp    11fc <main+0x5c>
mov    %rbp,%rdi
lea    0x8(%rsp),%rsi
call   10b0 <accept@plt>
jmp    11fc <main+0x5c>
mov    0x8(%rsp),%esi
mov    %rbp,%rdi
call   1060 <bubsort@plt>
jmp    11f0 <main+0x50>
mov    0x8(%rsp),%esi
mov    %rbp,%rdi
call   1090 <inssort@plt>
jmp    11f0 <main+0x50>
mov    0x8(%rsp),%esi
mov    %rbp,%rdi
call   1080 <selsort@plt>
jmp    11f0 <main+0x50>
mov    0x8(%rsp),%esi
mov    %rbp,%rdi
call   10c0 <qiksort@plt>
jmp    11f0 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"What would you like to do?\00"
@.str.1 = [11 x i8] c" ( 0) Exit\00"
@.str.2 = [21 x i8] c" ( 1) Populate Array\00"
@.str.3 = [18 x i8] c" ( 2) Print Array\00"
@.str.4 = [18 x i8] c" ( 3) Bubble Sort\00"
@.str.5 = [21 x i8] c" ( 4) Insertion Sort\00"
@.str.6 = [21 x i8] c" ( 5) Selection Sort\00"
@.str.7 = [17 x i8] c" ( 6) Quick Sort\00"
@.str.8 = [17 x i8] c" ( 7) Merge Sort\00"
@.str.9 = [7 x i8] c" %u%*c\00"
@.str.10 = [5 x i8] c"Bye!\00"
@.str.11 = [18 x i8] c"Incorrect Choice!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [50 x i32]
store i32 0, i32* %1
store i32 0, i32* %2
br label %5
5: ; preds = %65, %0
%6 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @puts(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%14 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %3
switch i32 %16, label %61 [
i32 0, label %17
i32 1, label %19
i32 2, label %22
i32 3, label %26
i32 4, label %33
i32 5, label %40
i32 6, label %47
i32 7, label %54
]
17: ; preds = %5
%18 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %63
19: ; preds = %5
%20 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%21 = call i32 @accept(i32* %20, i32* %2)
br label %63
22: ; preds = %5
%23 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%24 = load i32, i32* %2
%25 = call i32 @display(i32* %23, i32 %24)
br label %63
26: ; preds = %5
%27 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%28 = load i32, i32* %2
%29 = call i32 @bubsort(i32* %27, i32 %28)
%30 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%31 = load i32, i32* %2
%32 = call i32 @display(i32* %30, i32 %31)
br label %63
33: ; preds = %5
%34 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%35 = load i32, i32* %2
%36 = call i32 @inssort(i32* %34, i32 %35)
%37 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%38 = load i32, i32* %2
%39 = call i32 @display(i32* %37, i32 %38)
br label %63
40: ; preds = %5
%41 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%42 = load i32, i32* %2
%43 = call i32 @selsort(i32* %41, i32 %42)
%44 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%45 = load i32, i32* %2
%46 = call i32 @display(i32* %44, i32 %45)
br label %63
47: ; preds = %5
%48 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%49 = load i32, i32* %2
%50 = call i32 @qiksort(i32* %48, i32 %49)
%51 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%52 = load i32, i32* %2
%53 = call i32 @display(i32* %51, i32 %52)
br label %63
54: ; preds = %5
%55 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%56 = load i32, i32* %2
%57 = call i32 @mrgsort(i32* %55, i32 %56)
%58 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%59 = load i32, i32* %2
%60 = call i32 @display(i32* %58, i32 %59)
br label %63
61: ; preds = %5
%62 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
br label %63
63: ; preds = %61, %54, %47, %40, %33, %26, %22, %19, %17
%64 = call i32 @putchar(i8 signext 10)
br label %65
65: ; preds = %63
%66 = load i32, i32* %3
%67 = icmp ne i32 %66, 0
br i1 %67, label %5, label %68
68: ; preds = %65
%69 = call i32 @putchar(i8 signext 10)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"What would you like to do?\00"
@.str.1 = [11 x i8] c" ( 0) Exit\00"
@.str.2 = [21 x i8] c" ( 1) Populate Array\00"
@.str.3 = [18 x i8] c" ( 2) Print Array\00"
@.str.4 = [18 x i8] c" ( 3) Bubble Sort\00"
@.str.5 = [21 x i8] c" ( 4) Insertion Sort\00"
@.str.6 = [21 x i8] c" ( 5) Selection Sort\00"
@.str.7 = [17 x i8] c" ( 6) Quick Sort\00"
@.str.8 = [17 x i8] c" ( 7) Merge Sort\00"
@.str.9 = [7 x i8] c" %u%*c\00"
@.str.10 = [5 x i8] c"Bye!\00"
@.str.11 = [18 x i8] c"Incorrect Choice!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [50 x i32]
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast [50 x i32]* %3 to i8*
store i32 0, i32* %1
%7 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 0
br label %8
8: ; preds = %54, %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i32* %2)
%19 = load i32, i32* %2
switch i32 %19, label %52 [
i32 0, label %20
i32 1, label %22
i32 2, label %24
i32 3, label %27
i32 4, label %32
i32 5, label %37
i32 6, label %42
i32 7, label %47
]
20: ; preds = %8
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
br label %54
22: ; preds = %8
%23 = call i32 @accept(i32* %7, i32* %1)
br label %54
24: ; preds = %8
%25 = load i32, i32* %1
%26 = call i32 @display(i32* %7, i32 %25)
br label %54
27: ; preds = %8
%28 = load i32, i32* %1
%29 = call i32 @bubsort(i32* %7, i32 %28)
%30 = load i32, i32* %1
%31 = call i32 @display(i32* %7, i32 %30)
br label %54
32: ; preds = %8
%33 = load i32, i32* %1
%34 = call i32 @inssort(i32* %7, i32 %33)
%35 = load i32, i32* %1
%36 = call i32 @display(i32* %7, i32 %35)
br label %54
37: ; preds = %8
%38 = load i32, i32* %1
%39 = call i32 @selsort(i32* %7, i32 %38)
%40 = load i32, i32* %1
%41 = call i32 @display(i32* %7, i32 %40)
br label %54
42: ; preds = %8
%43 = load i32, i32* %1
%44 = call i32 @qiksort(i32* %7, i32 %43)
%45 = load i32, i32* %1
%46 = call i32 @display(i32* %7, i32 %45)
br label %54
47: ; preds = %8
%48 = load i32, i32* %1
%49 = call i32 @mrgsort(i32* %7, i32 %48)
%50 = load i32, i32* %1
%51 = call i32 @display(i32* %7, i32 %50)
br label %54
52: ; preds = %8
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
br label %54
54: ; preds = %52, %47, %42, %37, %32, %27, %24, %22, %20
%55 = call i32 @putchar(i8 signext 10)
%56 = load i32, i32* %2
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %8
58: ; preds = %54
%59 = call i32 @putchar(i8 signext 10)
ret i32 0
}