#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*/ bubblesort(int *, int);
int /*<<< orphan*/ insertionsort(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ selectionsort(int *, int);
int main() {
  int n, i, arr[100];
  printf("\nEnter the number of elements :");
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  int op;
  do {
    printf("\n 1 for bubble sort");
    printf("\n 2 for selection sort");
    printf("\n 3 for insertion sort");
    scanf("%d", &op);
    switch (op) {
    case 1:
      bubblesort(arr, n);
      break;
    case 2:
      selectionsort(arr, n);
      break;
    case 3:
      insertionsort(arr, n);
      break;
    }
  } while (op <= 3);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11bd <main+0x6d>
movslq -0xc(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe76(%rip),%rdi
call   1060 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1185 <main+0x35>
jmp    11c2 <main+0x72>
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
lea    0xe33(%rip),%rdi
lea    -0x1a4(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x1a4(%rbp),%eax
mov    %eax,-0x1a8(%rbp)
sub    $0x1,%eax
je     123b <main+0xeb>
jmp    1213 <main+0xc3>
mov    -0x1a8(%rbp),%eax
sub    $0x2,%eax
je     124f <main+0xff>
jmp    1227 <main+0xd7>
mov    -0x1a8(%rbp),%eax
sub    $0x3,%eax
je     1263 <main+0x113>
jmp    1272 <main+0x122>
lea    -0x1a0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1070 <bubblesort@plt>
jmp    1272 <main+0x122>
lea    -0x1a0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <selectionsort@plt>
jmp    1272 <main+0x122>
lea    -0x1a0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <insertionsort@plt>
jmp    1277 <main+0x127>
cmpl   $0x3,-0x1a4(%rbp)
jle    11c2 <main+0x72>
mov    -0x4(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    11bd <main+0x6d>
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
lea    0xe8d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
add    $0x1,%rbp
movslq 0x8(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     11a0 <main+0x50>
lea    0xe5f(%rip),%r14
lea    0xe6c(%rip),%r15
lea    0xe7c(%rip),%r12
lea    0xe47(%rip),%r13
lea    0xc(%rsp),%rbx
lea    0x10(%rsp),%rbp
jmp    1205 <main+0xb5>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x8(%rsp),%esi
mov    %rbp,%rdi
call   1040 <insertionsort@plt>
mov    0xc(%rsp),%eax
cmp    $0x4,%eax
jge    125e <main+0x10e>
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
call   1030 <printf@plt>
mov    %r12,%rdi
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
je     11f0 <main+0xa0>
cmp    $0x2,%eax
je     1250 <main+0x100>
cmp    $0x1,%eax
jne    1200 <main+0xb0>
mov    0x8(%rsp),%esi
mov    %rbp,%rdi
call   1070 <bubblesort@plt>
jmp    11fc <main+0xac>
nopl   0x0(%rax)
mov    0x8(%rsp),%esi
mov    %rbp,%rdi
call   1050 <selectionsort@plt>
jmp    11fc <main+0xac>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"\0AEnter the number of elements :\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"\0A 1 for bubble sort\00"
@.str.3 = [23 x i8] c"\0A 2 for selection sort\00"
@.str.4 = [23 x i8] c"\0A 3 for insertion sort\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100 x i32]
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
br label %8
8: ; preds = %17, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %14
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %15)
br label %17
17: ; preds = %12
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %8
20: ; preds = %8
br label %21
21: ; preds = %40, %20
%22 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%26 = load i32, i32* %5
switch i32 %26, label %39 [
i32 1, label %27
i32 2, label %31
i32 3, label %35
]
27: ; preds = %21
%28 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%29 = load i32, i32* %2
%30 = call i32 @bubblesort(i32* %28, i32 %29)
br label %39
31: ; preds = %21
%32 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%33 = load i32, i32* %2
%34 = call i32 @selectionsort(i32* %32, i32 %33)
br label %39
35: ; preds = %21
%36 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%37 = load i32, i32* %2
%38 = call i32 @insertionsort(i32* %36, i32 %37)
br label %39
39: ; preds = %21, %35, %31, %27
br label %40
40: ; preds = %39
%41 = load i32, i32* %5
%42 = icmp sle i32 %41, 3
br i1 %42, label %21, label %43
43: ; preds = %40
%44 = load i32, i32* %1
ret i32 %44
}

LLVM IR (-O2):
@.str = [32 x i8] c"\0AEnter the number of elements :\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"\0A 1 for bubble sort\00"
@.str.3 = [23 x i8] c"\0A 2 for selection sort\00"
@.str.4 = [23 x i8] c"\0A 3 for insertion sort\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast [100 x i32]* %2 to i8*
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %0, %10
%11 = phi i64 [ %14, %10 ], [ 0, %0 ]
%12 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %11
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%14 = add nuw nsw i64 %11, 1
%15 = load i32, i32* %1
%16 = sext i32 %15 to i64
%17 = icmp slt i64 %14, %16
br i1 %17, label %10, label %18
18: ; preds = %10, %0
%19 = bitcast i32* %3 to i8*
%20 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
br label %21
21: ; preds = %38, %18
%22 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%26 = load i32, i32* %3
switch i32 %26, label %38 [
i32 1, label %27
i32 2, label %30
i32 3, label %33
]
27: ; preds = %21
%28 = load i32, i32* %1
%29 = call i32 @bubblesort(i32* %20, i32 %28)
br label %36
30: ; preds = %21
%31 = load i32, i32* %1
%32 = call i32 @selectionsort(i32* %20, i32 %31)
br label %36
33: ; preds = %21
%34 = load i32, i32* %1
%35 = call i32 @insertionsort(i32* %20, i32 %34)
br label %36
36: ; preds = %33, %30, %27
%37 = load i32, i32* %3
br label %38
38: ; preds = %36, %21
%39 = phi i32 [ %37, %36 ], [ %26, %21 ]
%40 = icmp slt i32 %39, 4
br i1 %40, label %21, label %41
41: ; preds = %38
ret i32 0
}