#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(int *, int);
int /*<<< orphan*/ heap_sort(int *, int);
int /*<<< orphan*/ insert_sort(int *, int);
int /*<<< orphan*/ merge_sort(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quick_sort(int *, int);
int /*<<< orphan*/ select_sort(int *, int);
scalar_t__ strncmp(char *, char *, int);
void sort_option(int *arr, int size, char *sort) {
  if (strncmp(sort, "ins", 3) == 0)
    insert_sort(arr, size);
  else if (strncmp(sort, "bub", 3) == 0)
    bubble_sort(arr, size);
  else if (strncmp(sort, "sel", 3) == 0)
    select_sort(arr, size);
  else if (strncmp(sort, "heap", 4) == 0)
    heap_sort(arr, size);
  else if (strncmp(sort, "quick", 5) == 0)
    quick_sort(arr, size);
  else if (strncmp(sort, "merge", 5) == 0)
    merge_sort(arr, 0, size - 1);
  else {
    printf("sort_option error\n");
    return;
  }
}


x86 assembly (clang, -O0):
<sort_option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe62(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    11c3 <sort_option+0x43>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1090 <insert_sort@plt>
jmp    12e2 <sort_option+0x162>
mov    -0x18(%rbp),%rdi
lea    0xe36(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    11f3 <sort_option+0x73>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   10a0 <bubble_sort@plt>
jmp    12dd <sort_option+0x15d>
mov    -0x18(%rbp),%rdi
lea    0xe0a(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1223 <sort_option+0xa3>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1080 <select_sort@plt>
jmp    12d8 <sort_option+0x158>
mov    -0x18(%rbp),%rdi
lea    0xdde(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1253 <sort_option+0xd3>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <heap_sort@plt>
jmp    12d3 <sort_option+0x153>
mov    -0x18(%rbp),%rdi
lea    0xdb3(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1283 <sort_option+0x103>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1070 <quick_sort@plt>
jmp    12ce <sort_option+0x14e>
mov    -0x18(%rbp),%rdi
lea    0xd89(%rip),%rsi
mov    $0x5,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    12b8 <sort_option+0x138>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1060 <merge_sort@plt>
jmp    12c9 <sort_option+0x149>
lea    0xd5e(%rip),%rdi
call   1050 <printf@plt>
jmp    12e2 <sort_option+0x162>
jmp    12ce <sort_option+0x14e>
jmp    12d3 <sort_option+0x153>
jmp    12d8 <sort_option+0x158>
jmp    12dd <sort_option+0x15d>
jmp    12e2 <sort_option+0x162>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sort_option>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbp
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xe6c(%rip),%rsi
mov    %rdx,%rdi
mov    $0x3,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     123b <sort_option+0xbb>
lea    0xe53(%rip),%rsi
mov    %rbp,%rdi
mov    $0x3,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     124a <sort_option+0xca>
lea    0xe3a(%rip),%rsi
mov    %rbp,%rdi
mov    $0x3,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1259 <sort_option+0xd9>
lea    0xe25(%rip),%rsi
mov    %rbp,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1268 <sort_option+0xe8>
lea    0xe11(%rip),%rsi
mov    %rbp,%rdi
mov    $0x5,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1277 <sort_option+0xf7>
lea    0xdfe(%rip),%rsi
mov    %rbp,%rdi
mov    $0x5,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1286 <sort_option+0x106>
lea    0xdeb(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <puts@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1090 <insert_sort@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    10a0 <bubble_sort@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1080 <select_sort@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <heap_sort@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <quick_sort@plt>
add    $0xffffffff,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <merge_sort@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"ins\00"
@.str.1 = [4 x i8] c"bub\00"
@.str.2 = [4 x i8] c"sel\00"
@.str.3 = [5 x i8] c"heap\00"
@.str.4 = [6 x i8] c"quick\00"
@.str.5 = [6 x i8] c"merge\00"
@.str.6 = [19 x i8] c"sort_option error\0A\00"
define void @sort_option(i32* %0, i32 %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
store i32* %0, i32** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%7 = load i8*, i8** %6
%8 = call i64 @strncmp(i8* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i32*, i32** %4
%12 = load i32, i32* %5
%13 = call i32 @insert_sort(i32* %11, i32 %12)
br label %62
14: ; preds = %3
%15 = load i8*, i8** %6
%16 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i32*, i32** %4
%20 = load i32, i32* %5
%21 = call i32 @bubble_sort(i32* %19, i32 %20)
br label %61
22: ; preds = %14
%23 = load i8*, i8** %6
%24 = call i64 @strncmp(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i32*, i32** %4
%28 = load i32, i32* %5
%29 = call i32 @select_sort(i32* %27, i32 %28)
br label %60
30: ; preds = %22
%31 = load i8*, i8** %6
%32 = call i64 @strncmp(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i32*, i32** %4
%36 = load i32, i32* %5
%37 = call i32 @heap_sort(i32* %35, i32 %36)
br label %59
38: ; preds = %30
%39 = load i8*, i8** %6
%40 = call i64 @strncmp(i8* %39, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 5)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %38
%43 = load i32*, i32** %4
%44 = load i32, i32* %5
%45 = call i32 @quick_sort(i32* %43, i32 %44)
br label %58
46: ; preds = %38
%47 = load i8*, i8** %6
%48 = call i64 @strncmp(i8* %47, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 5)
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %46
%51 = load i32*, i32** %4
%52 = load i32, i32* %5
%53 = sub nsw i32 %52, 1
%54 = call i32 @merge_sort(i32* %51, i32 0, i32 %53)
br label %57
55: ; preds = %46
%56 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %62
57: ; preds = %50
br label %58
58: ; preds = %57, %42
br label %59
59: ; preds = %58, %34
br label %60
60: ; preds = %59, %26
br label %61
61: ; preds = %60, %18
br label %62
62: ; preds = %55, %61, %10
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"ins\00"
@.str.1 = [4 x i8] c"bub\00"
@.str.2 = [4 x i8] c"sel\00"
@.str.3 = [5 x i8] c"heap\00"
@.str.4 = [6 x i8] c"quick\00"
@.str.5 = [6 x i8] c"merge\00"
@str = [18 x i8] c"sort_option error\00"
define void @sort_option(i32* %0, i32 %1, i8* %2) {
%4 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @insert_sort(i32* %0, i32 %1)
br label %36
8: ; preds = %3
%9 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @bubble_sort(i32* %0, i32 %1)
br label %36
13: ; preds = %8
%14 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = tail call i32 @select_sort(i32* %0, i32 %1)
br label %36
18: ; preds = %13
%19 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 @heap_sort(i32* %0, i32 %1)
br label %36
23: ; preds = %18
%24 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 5)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = tail call i32 @quick_sort(i32* %0, i32 %1)
br label %36
28: ; preds = %23
%29 = tail call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 5)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = add nsw i32 %1, -1
%33 = tail call i32 @merge_sort(i32* %0, i32 0, i32 %32)
br label %36
34: ; preds = %28
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %36
36: ; preds = %11, %21, %31, %26, %16, %34, %6
ret void
}