#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*/ swap(int *, int *);
void selection_sort(int paramArr[]) {
  int sorted_index = 0;
  int swap_counter = 1;
  while (swap_counter == 1) {
    swap_counter = 0;
    for (int i = sorted_index; i < 13; i++) {
      if (paramArr[sorted_index] > paramArr[i]) {
        swap(&paramArr[sorted_index], &paramArr[i]);
        swap_counter = 1;
      }
    }
    sorted_index++;
  }
}


x86 assembly (clang, -O0):
<selection_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    11b2 <selection_sort+0xa2>
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0xd,-0x14(%rbp)
jge    11a4 <selection_sort+0x94>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jle    1191 <selection_sort+0x81>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <swap@plt>
movl   $0x1,-0x10(%rbp)
jmp    1196 <selection_sort+0x86>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <selection_sort+0x31>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112a <selection_sort+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<selection_sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xd,%r14d
xor    %r13d,%r13d
mov    %rdi,(%rsp)
mov    %rdi,%rbp
jmp    1141 <selection_sort+0x31>
nopl   (%rax)
add    $0x1,%r13
add    $0x4,%rbp
add    $0xffffffffffffffff,%r14
cmp    $0x1,%eax
jne    1183 <selection_sort+0x73>
cmp    $0xc,%r13
ja     1183 <selection_sort+0x73>
mov    (%rsp),%rax
lea    (%rax,%r13,4),%r15
xor    %eax,%eax
mov    %r14,%r12
mov    %rbp,%rbx
jmp    116a <selection_sort+0x5a>
nopl   0x0(%rax)
add    $0x4,%rbx
add    $0xffffffffffffffff,%r12
je     1130 <selection_sort+0x20>
mov    (%r15),%ecx
cmp    (%rbx),%ecx
jle    1160 <selection_sort+0x50>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <swap@plt>
mov    $0x1,%eax
jmp    1160 <selection_sort+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @selection_sort(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
store i32 1, i32* %4
br label %6
6: ; preds = %40, %1
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %43
9: ; preds = %6
store i32 0, i32* %4
%10 = load i32, i32* %3
store i32 %10, i32* %5
br label %11
11: ; preds = %37, %9
%12 = load i32, i32* %5
%13 = icmp slt i32 %12, 13
br i1 %13, label %14, label %40
14: ; preds = %11
%15 = load i32*, i32** %2
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
%20 = load i32*, i32** %2
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = load i32, i32* %23
%25 = icmp sgt i32 %19, %24
br i1 %25, label %26, label %36
26: ; preds = %14
%27 = load i32*, i32** %2
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32*, i32** %2
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = call i32 @swap(i32* %30, i32* %34)
store i32 1, i32* %4
br label %36
36: ; preds = %26, %14
br label %37
37: ; preds = %36
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %11
40: ; preds = %11
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %6
43: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @selection_sort(i32* %0) {
br label %2
2: ; preds = %1, %7
%3 = phi i64 [ 0, %1 ], [ %8, %7 ]
%4 = icmp ult i64 %3, 13
br i1 %4, label %5, label %23
5: ; preds = %2
%6 = getelementptr inbounds i32, i32* %0, i64 %3
br label %10
7: ; preds = %19
%8 = add nuw i64 %3, 1
%9 = icmp eq i32 %20, 1
br i1 %9, label %2, label %23
10: ; preds = %5, %19
%11 = phi i64 [ %3, %5 ], [ %21, %19 ]
%12 = phi i32 [ 0, %5 ], [ %20, %19 ]
%13 = load i32, i32* %6
%14 = getelementptr inbounds i32, i32* %0, i64 %11
%15 = load i32, i32* %14
%16 = icmp sgt i32 %13, %15
br i1 %16, label %17, label %19
17: ; preds = %10
%18 = tail call i32 @swap(i32* %6, i32* %14)
br label %19
19: ; preds = %10, %17
%20 = phi i32 [ 1, %17 ], [ %12, %10 ]
%21 = add nuw i64 %11, 1
%22 = icmp eq i64 %21, 13
br i1 %22, label %7, label %10
23: ; preds = %2, %7
ret void
}