void select_sort_dsample(samp, n) double *samp;
int n;
{
  int i, j;
  double t;
  for (i = 1; i < n; i++) {
    t = samp[i];
    for (j = i; j > 0 && samp[j - 1] > t; j--) {
      samp[j] = samp[j - 1];
    }
    samp[j] = t;
  }
}


x86 assembly (clang, -O0):
<select_sort_dsample>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11bf <select_sort_dsample+0xbf>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x21(%rbp)
jle    1162 <select_sort_dsample+0x62>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd -0x20(%rbp),%xmm0
seta   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1172 <select_sort_dsample+0x72>
jmp    119f <select_sort_dsample+0x9f>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1136 <select_sort_dsample+0x36>
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1112 <select_sort_dsample+0x12>
pop    %rbp
ret

x86 assembly (clang, -O2):
<select_sort_dsample>:
cmp    $0x2,%esi
jl     1157 <select_sort_dsample+0x57>
mov    %esi,%r8d
mov    $0x1,%ecx
jmp    1121 <select_sort_dsample+0x21>
nop
movslq %edx,%rax
movsd  %xmm0,(%rdi,%rax,8)
add    $0x1,%rcx
cmp    %r8,%rcx
je     1157 <select_sort_dsample+0x57>
movsd  (%rdi,%rcx,8),%xmm0
mov    %rcx,%rdx
nopl   0x0(%rax)
lea    -0x1(%rdx),%rsi
mov    %esi,%eax
movsd  (%rdi,%rax,8),%xmm1
ucomisd %xmm0,%xmm1
jbe    1110 <select_sort_dsample+0x10>
movsd  %xmm1,(%rdi,%rdx,8)
lea    0x1(%rsi),%rax
mov    %rsi,%rdx
cmp    $0x1,%rax
jg     1130 <select_sort_dsample+0x30>
xor    %edx,%edx
jmp    1110 <select_sort_dsample+0x10>
ret

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

LLVM IR (-O2):
define void @select_sort_dsample(double* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 1
br i1 %3, label %4, label %27
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %20
%7 = phi i64 [ 1, %4 ], [ %25, %20 ]
%8 = getelementptr inbounds double, double* %0, i64 %7
%9 = load double, double* %8
br label %10
10: ; preds = %6, %17
%11 = phi i64 [ %7, %6 ], [ %12, %17 ]
%12 = add nsw i64 %11, -1
%13 = and i64 %12, 4294967295
%14 = getelementptr inbounds double, double* %0, i64 %13
%15 = load double, double* %14
%16 = fcmp ogt double %15, %9
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = getelementptr inbounds double, double* %0, i64 %11
store double %15, double* %18
%19 = icmp sgt i64 %11, 1
br i1 %19, label %10, label %20
20: ; preds = %17, %10
%21 = phi i64 [ 0, %17 ], [ %11, %10 ]
%22 = shl i64 %21, 32
%23 = ashr exact i64 %22, 32
%24 = getelementptr inbounds double, double* %0, i64 %23
store double %9, double* %24
%25 = add nuw nsw i64 %7, 1
%26 = icmp eq i64 %25, %5
br i1 %26, label %27, label %6
27: ; preds = %20, %2
ret void
}