#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 */
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ swap(double *, double *);
void selectionSortAux(double arr[], double arr2[], int32_t n) {
  int32_t i, j, min_idx;
  for (i = 0; i < n - 1; i++) {
    min_idx = i;
    for (j = i + 1; j < n; j++)
      if (arr[j] < arr[min_idx])
        min_idx = j;
    swap(&arr[min_idx], &arr[i]);
    swap(&arr2[min_idx], &arr2[i]);
  }
}


x86 assembly (clang, -O0):
<selectionSortAux>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11e7 <selectionSortAux+0xd7>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1193 <selectionSortAux+0x83>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jbe    1180 <selectionSortAux+0x70>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1185 <selectionSortAux+0x75>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114a <selectionSortAux+0x3a>
mov    -0x8(%rbp),%rdi
movslq -0x20(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
call   1030 <swap@plt>
mov    -0x10(%rbp),%rdi
movslq -0x20(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
call   1030 <swap@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <selectionSortAux+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<selectionSortAux>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
cmp    $0x2,%edx
jl     11c0 <selectionSortAux+0xb0>
mov    %rdi,%rbx
mov    %rdx,%rax
mov    %eax,%r12d
add    $0xffffffff,%eax
mov    %rax,0x8(%rsp)
mov    $0x1,%r13d
xor    %ebp,%ebp
jmp    1182 <selectionSortAux+0x72>
nopw   0x0(%rax,%rax,1)
mov    %ebp,%ecx
movslq %ecx,%r15
lea    (%rbx,%r15,8),%rdi
lea    (%rbx,%rbp,8),%rsi
call   1030 <swap@plt>
mov    0x10(%rsp),%rax
lea    (%rax,%r15,8),%rdi
lea    (%rax,%rbp,8),%rsi
call   1030 <swap@plt>
add    $0x1,%r13
mov    %r14,%rbp
cmp    0x8(%rsp),%r14
je     11c0 <selectionSortAux+0xb0>
lea    0x1(%rbp),%r14
cmp    %r12,%r14
jae    1150 <selectionSortAux+0x40>
mov    %r13,%rax
mov    %ebp,%edx
jmp    11ab <selectionSortAux+0x9b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rax
mov    %ecx,%edx
cmp    %rax,%r12
je     1152 <selectionSortAux+0x42>
movslq %edx,%rcx
movsd  (%rbx,%rcx,8),%xmm0
ucomisd (%rbx,%rax,8),%xmm0
mov    %eax,%ecx
ja     11a0 <selectionSortAux+0x90>
mov    %edx,%ecx
jmp    11a0 <selectionSortAux+0x90>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @selectionSortAux(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %10
10: ; preds = %60, %3
%11 = load i32, i32* %7
%12 = load i32, i32* %6
%13 = sub nsw i32 %12, 1
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %63
15: ; preds = %10
%16 = load i32, i32* %7
store i32 %16, i32* %9
%17 = load i32, i32* %7
%18 = add nsw i32 %17, 1
store i32 %18, i32* %8
br label %19
19: ; preds = %38, %15
%20 = load i32, i32* %8
%21 = load i32, i32* %6
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %41
23: ; preds = %19
%24 = load double*, double** %4
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = load double, double* %27
%29 = load double*, double** %4
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = fcmp olt double %28, %33
br i1 %34, label %35, label %37
35: ; preds = %23
%36 = load i32, i32* %8
store i32 %36, i32* %9
br label %37
37: ; preds = %35, %23
br label %38
38: ; preds = %37
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
br label %19
41: ; preds = %19
%42 = load double*, double** %4
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
%46 = load double*, double** %4
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %46, i64 %48
%50 = call i32 @swap(double* %45, double* %49)
%51 = load double*, double** %5
%52 = load i32, i32* %9
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double*, double** %5
%56 = load i32, i32* %7
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double, double* %55, i64 %57
%59 = call i32 @swap(double* %54, double* %58)
br label %60
60: ; preds = %41
%61 = load i32, i32* %7
%62 = add nsw i32 %61, 1
store i32 %62, i32* %7
br label %10
63: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @selectionSortAux(double* %0, double* %1, i32 %2) {
%4 = icmp sgt i32 %2, 1
br i1 %4, label %5, label %40
5: ; preds = %3
%6 = add nsw i32 %2, -1
%7 = zext i32 %2 to i64
%8 = zext i32 %6 to i64
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %5, %29
%11 = phi i64 [ 0, %5 ], [ %13, %29 ]
%12 = phi i64 [ 1, %5 ], [ %38, %29 ]
%13 = add nuw nsw i64 %11, 1
%14 = icmp ult i64 %13, %7
%15 = trunc i64 %11 to i32
br i1 %14, label %16, label %29
16: ; preds = %10, %16
%17 = phi i64 [ %27, %16 ], [ %12, %10 ]
%18 = phi i32 [ %26, %16 ], [ %15, %10 ]
%19 = getelementptr inbounds double, double* %0, i64 %17
%20 = load double, double* %19
%21 = sext i32 %18 to i64
%22 = getelementptr inbounds double, double* %0, i64 %21
%23 = load double, double* %22
%24 = fcmp olt double %20, %23
%25 = trunc i64 %17 to i32
%26 = select i1 %24, i32 %25, i32 %18
%27 = add nuw nsw i64 %17, 1
%28 = icmp eq i64 %27, %9
br i1 %28, label %29, label %16
29: ; preds = %16, %10
%30 = phi i32 [ %15, %10 ], [ %26, %16 ]
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %0, i64 %31
%33 = getelementptr inbounds double, double* %0, i64 %11
%34 = tail call i32 @swap(double* %32, double* %33)
%35 = getelementptr inbounds double, double* %1, i64 %31
%36 = getelementptr inbounds double, double* %1, i64 %11
%37 = tail call i32 @swap(double* %35, double* %36)
%38 = add nuw nsw i64 %12, 1
%39 = icmp eq i64 %13, %8
br i1 %39, label %40, label %10
40: ; preds = %29, %3
ret void
}