#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(int *, int);
int /*<<< orphan*/ insertion(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ selection(int *, int);
int main() {
  int arr[] = {5, 3, 8, 6, 2, 7, 9, 1, 12}, i;
  int arr1[] = {5, 4, 8, 6, 20, 7, 9, 24};
  int arr2[] = {5, 4, 8, 6, 20, 7, 9, 24};
  selection(arr, 9);
  for (i = 0; i < 9; i++)
    printf("%d ", arr[i]);
  printf("\n");
  bubble(arr1, 8);
  for (i = 0; i < 8; i++)
    printf("%d ", arr1[i]);
  printf("\n");
  insertion(arr2, 8);
  for (i = 0; i < 8; i++)
    printf("%d ", arr2[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe93(%rip),%rsi
mov    $0x24,%edx
call   1060 <memcpy@plt>
mov    0xeb2(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xeaf(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xeac(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xea9(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe86(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xe83(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xe80(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xe7d(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x9,%esi
call   1030 <selection@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x9,-0x34(%rbp)
jge    1212 <main+0xc2>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11e4 <main+0x94>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    $0x8,%esi
call   1040 <bubble@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x8,-0x34(%rbp)
jge    1263 <main+0x113>
movslq -0x34(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%esi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1235 <main+0xe5>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    $0x8,%esi
call   1070 <insertion@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x8,-0x34(%rbp)
jge    12b4 <main+0x164>
movslq -0x34(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%esi
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1286 <main+0x136>
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
mov    0xec5(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe8e(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xec3(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xea7(%rip),%xmm1
movaps %xmm1,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm1,0x30(%rsp)
mov    %rsp,%rdi
mov    $0x9,%esi
call   1040 <selection@plt>
mov    (%rsp),%esi
lea    0xea1(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x50(%rsp),%rdi
mov    $0x8,%esi
call   1050 <bubble@plt>
mov    0x50(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x54(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x58(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x5c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x60(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x64(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x68(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x6c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x30(%rsp),%rdi
mov    $0x8,%esi
call   1070 <insertion@plt>
mov    0x30(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x34(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x38(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x3c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x40(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x44(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x48(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.arr = [9 x i32] [i32 5, i32 3, i32 8, i32 6, i32 2, i32 7, i32 9, i32 1, i32 12]
@__const.main.arr1 = [8 x i32] [i32 5, i32 4, i32 8, i32 6, i32 20, i32 7, i32 9, i32 24]
@__const.main.arr2 = [8 x i32] [i32 5, i32 4, i32 8, i32 6, i32 20, i32 7, i32 9, i32 24]
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i32]
%3 = alloca i32
%4 = alloca [8 x i32]
%5 = alloca [8 x i32]
store i32 0, i32* %1
%6 = bitcast [9 x i32]* %2 to i8*
%7 = bitcast [8 x i32]* %4 to i8*
%8 = bitcast [8 x i32]* %5 to i8*
%9 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%10 = call i32 @selection(i32* %9, i32 9)
store i32 0, i32* %3
br label %11
11: ; preds = %20, %0
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 9
br i1 %13, label %14, label %23
14: ; preds = %11
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %14
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %11
23: ; preds = %11
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 0
%26 = call i32 @bubble(i32* %25, i32 8)
store i32 0, i32* %3
br label %27
27: ; preds = %36, %23
%28 = load i32, i32* %3
%29 = icmp slt i32 %28, 8
br i1 %29, label %30, label %39
30: ; preds = %27
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %30
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %27
39: ; preds = %27
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%41 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 0
%42 = call i32 @insertion(i32* %41, i32 8)
store i32 0, i32* %3
br label %43
43: ; preds = %52, %39
%44 = load i32, i32* %3
%45 = icmp slt i32 %44, 8
br i1 %45, label %46, label %55
46: ; preds = %43
%47 = load i32, i32* %3
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %46
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 1
store i32 %54, i32* %3
br label %43
55: ; preds = %43
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%57 = load i32, i32* %1
ret i32 %57
}

LLVM IR (-O2):
@__const.main.arr = [9 x i32] [i32 5, i32 3, i32 8, i32 6, i32 2, i32 7, i32 9, i32 1, i32 12]
@__const.main.arr2 = [8 x i32] [i32 5, i32 4, i32 8, i32 6, i32 20, i32 7, i32 9, i32 24]
@.str = [4 x i8] c"%d \00"
define i32 @main() {
%1 = alloca [9 x i32]
%2 = alloca [8 x i32]
%3 = alloca [8 x i32]
%4 = bitcast [9 x i32]* %1 to i8*
%5 = bitcast [8 x i32]* %2 to i8*
%6 = bitcast [8 x i32]* %3 to i8*
%7 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 0
%8 = call i32 @selection(i32* %7, i32 9)
%9 = load i32, i32* %7
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 1
%12 = load i32, i32* %11
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 2
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 3
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 4
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 5
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 6
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 7
%30 = load i32, i32* %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 8
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = call i32 @putchar(i32 10)
%36 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 0
%37 = call i32 @bubble(i32* %36, i32 8)
%38 = load i32, i32* %36
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 1
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 2
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %44)
%46 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 3
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %47)
%49 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 4
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %50)
%52 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 5
%53 = load i32, i32* %52
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %53)
%55 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 6
%56 = load i32, i32* %55
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %56)
%58 = getelementptr inbounds [8 x i32], [8 x i32]* %2, i64 0, i64 7
%59 = load i32, i32* %58
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %59)
%61 = call i32 @putchar(i32 10)
%62 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%63 = call i32 @insertion(i32* %62, i32 8)
%64 = load i32, i32* %62
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %64)
%66 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 1
%67 = load i32, i32* %66
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %67)
%69 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 2
%70 = load i32, i32* %69
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %70)
%72 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 3
%73 = load i32, i32* %72
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %73)
%75 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 4
%76 = load i32, i32* %75
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %76)
%78 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 5
%79 = load i32, i32* %78
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %79)
%81 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 6
%82 = load i32, i32* %81
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %82)
%84 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 7
%85 = load i32, i32* %84
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %85)
%87 = call i32 @putchar(i32 10)
ret i32 0
}