void gather_array_double_min(double *restrict out, const double *restrict in,
                             unsigned int n) {
  for (; n; --n) {
    double q = *in++, *p = out++;
    if (q < *p)
      *p = q;
  }
}


x86 assembly (clang, -O0):
<gather_array_double_min>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     117b <gather_array_double_min+0x7b>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    %rax,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    1168 <gather_array_double_min+0x68>
movsd  -0x20(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    116d <gather_array_double_min+0x6d>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    110f <gather_array_double_min+0xf>
pop    %rbp
ret

x86 assembly (clang, -O2):
<gather_array_double_min>:
test   %edx,%edx
je     1134 <gather_array_double_min+0x34>
test   $0x1,%dl
jne    1112 <gather_array_double_min+0x12>
mov    %edx,%eax
cmp    $0x1,%edx
je     1134 <gather_array_double_min+0x34>
jmp    1135 <gather_array_double_min+0x35>
movsd  (%rsi),%xmm0
movsd  (%rdi),%xmm1
ucomisd %xmm0,%xmm1
jbe    1124 <gather_array_double_min+0x24>
movsd  %xmm0,(%rdi)
add    $0x8,%rsi
add    $0x8,%rdi
lea    -0x1(%rdx),%eax
cmp    $0x1,%edx
jne    1135 <gather_array_double_min+0x35>
ret
mov    %eax,%eax
xor    %ecx,%ecx
jmp    1148 <gather_array_double_min+0x48>
nopl   0x0(%rax,%rax,1)
add    $0x2,%rcx
cmp    %ecx,%eax
je     1134 <gather_array_double_min+0x34>
movsd  (%rsi,%rcx,8),%xmm0
movsd  (%rdi,%rcx,8),%xmm1
ucomisd %xmm0,%xmm1
jbe    115d <gather_array_double_min+0x5d>
movsd  %xmm0,(%rdi,%rcx,8)
movsd  0x8(%rsi,%rcx,8),%xmm0
movsd  0x8(%rdi,%rcx,8),%xmm1
ucomisd %xmm0,%xmm1
jbe    1140 <gather_array_double_min+0x40>
movsd  %xmm0,0x8(%rdi,%rcx,8)
jmp    1140 <gather_array_double_min+0x40>

LLVM IR (-O0):
define void @gather_array_double_min(double* noalias %0, double* noalias %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca double*
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
br label %9
9: ; preds = %26, %3
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %29
12: ; preds = %9
%13 = load double*, double** %5
%14 = getelementptr inbounds double, double* %13, i32 1
store double* %14, double** %5
%15 = load double, double* %13
store double %15, double* %7
%16 = load double*, double** %4
%17 = getelementptr inbounds double, double* %16, i32 1
store double* %17, double** %4
store double* %16, double** %8
%18 = load double, double* %7
%19 = load double*, double** %8
%20 = load double, double* %19
%21 = fcmp olt double %18, %20
br i1 %21, label %22, label %25
22: ; preds = %12
%23 = load double, double* %7
%24 = load double*, double** %8
store double %23, double* %24
br label %25
25: ; preds = %22, %12
br label %26
26: ; preds = %25
%27 = load i32, i32* %6
%28 = add i32 %27, -1
store i32 %28, i32* %6
br label %9
29: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @gather_array_double_min(double* noalias nocapture %0, double* noalias nocapture %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %42, label %5
5: ; preds = %3
%6 = and i32 %2, 1
%7 = icmp eq i32 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %5
%9 = getelementptr inbounds double, double* %1, i64 1
%10 = load double, double* %1
%11 = getelementptr inbounds double, double* %0, i64 1
%12 = load double, double* %0
%13 = fcmp olt double %10, %12
br i1 %13, label %14, label %15
14: ; preds = %8
store double %10, double* %0
br label %15
15: ; preds = %14, %8
%16 = add i32 %2, -1
br label %17
17: ; preds = %15, %5
%18 = phi double* [ %0, %5 ], [ %11, %15 ]
%19 = phi double* [ %1, %5 ], [ %9, %15 ]
%20 = phi i32 [ %2, %5 ], [ %16, %15 ]
%21 = icmp eq i32 %2, 1
br i1 %21, label %42, label %22
22: ; preds = %17, %39
%23 = phi double* [ %35, %39 ], [ %18, %17 ]
%24 = phi double* [ %33, %39 ], [ %19, %17 ]
%25 = phi i32 [ %40, %39 ], [ %20, %17 ]
%26 = getelementptr inbounds double, double* %24, i64 1
%27 = load double, double* %24
%28 = getelementptr inbounds double, double* %23, i64 1
%29 = load double, double* %23
%30 = fcmp olt double %27, %29
br i1 %30, label %31, label %32
31: ; preds = %22
store double %27, double* %23
br label %32
32: ; preds = %31, %22
%33 = getelementptr inbounds double, double* %24, i64 2
%34 = load double, double* %26
%35 = getelementptr inbounds double, double* %23, i64 2
%36 = load double, double* %28
%37 = fcmp olt double %34, %36
br i1 %37, label %38, label %39
38: ; preds = %32
store double %34, double* %28
br label %39
39: ; preds = %38, %32
%40 = add i32 %25, -2
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %22
42: ; preds = %17, %39, %3
ret void
}