#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*/ bubble_sort(unsigned int *, unsigned int);
int /*<<< orphan*/ insertion_sort(unsigned int *, unsigned int);
int /*<<< orphan*/ selection_sort(unsigned int *, unsigned int);
int /*<<< orphan*/ shellSort(unsigned int *, unsigned int);
void SORT(unsigned int *base, unsigned int n, int type) {
  switch (type) {
  case 0:
    shellSort(base, n);
    break;
  case 1:
    selection_sort(base, n);
    break;
  case 2:
    insertion_sort(base, n);
    break;
  case 3:
    bubble_sort(base, n);
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<SORT>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%rax
ja     11bb <SORT+0x7b>
mov    -0x18(%rbp),%rax
lea    0xe92(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <shellSort@plt>
jmp    11c0 <SORT+0x80>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <selection_sort@plt>
jmp    11c0 <SORT+0x80>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <insertion_sort@plt>
jmp    11c0 <SORT+0x80>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <bubble_sort@plt>
jmp    11c0 <SORT+0x80>
jmp    11c0 <SORT+0x80>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SORT>:
cmp    $0x3,%edx
ja     115c <SORT+0x1c>
mov    %edx,%eax
lea    0xeb2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1040 <shellSort@plt>
ret
jmp    1030 <selection_sort@plt>
jmp    1050 <insertion_sort@plt>
jmp    1060 <bubble_sort@plt>

LLVM IR (-O0):
define void @SORT(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
switch i32 %7, label %24 [
i32 0, label %8
i32 1, label %12
i32 2, label %16
i32 3, label %20
]
8: ; preds = %3
%9 = load i32*, i32** %4
%10 = load i32, i32* %5
%11 = call i32 @shellSort(i32* %9, i32 %10)
br label %25
12: ; preds = %3
%13 = load i32*, i32** %4
%14 = load i32, i32* %5
%15 = call i32 @selection_sort(i32* %13, i32 %14)
br label %25
16: ; preds = %3
%17 = load i32*, i32** %4
%18 = load i32, i32* %5
%19 = call i32 @insertion_sort(i32* %17, i32 %18)
br label %25
20: ; preds = %3
%21 = load i32*, i32** %4
%22 = load i32, i32* %5
%23 = call i32 @bubble_sort(i32* %21, i32 %22)
br label %25
24: ; preds = %3
br label %25
25: ; preds = %24, %20, %16, %12, %8
ret void
}

LLVM IR (-O2):
define void @SORT(i32* %0, i32 %1, i32 %2) {
switch i32 %2, label %12 [
i32 0, label %4
i32 1, label %6
i32 2, label %8
i32 3, label %10
]
4: ; preds = %3
%5 = tail call i32 @shellSort(i32* %0, i32 %1)
br label %12
6: ; preds = %3
%7 = tail call i32 @selection_sort(i32* %0, i32 %1)
br label %12
8: ; preds = %3
%9 = tail call i32 @insertion_sort(i32* %0, i32 %1)
br label %12
10: ; preds = %3
%11 = tail call i32 @bubble_sort(i32* %0, i32 %1)
br label %12
12: ; preds = %3, %10, %8, %6, %4
ret void
}