void vsqrt_double(double *dst, double *src, int count) {
  for (int i = 0; i < count; ++i)
    dst[i] = __builtin_sqrt(src[i]);
}


x86 assembly (clang, -O0):
<vsqrt_double>:
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
cmp    -0x14(%rbp),%eax
jge    1163 <vsqrt_double+0x53>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <sqrt@plt>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <vsqrt_double+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vsqrt_double>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
jle    118a <vsqrt_double+0x7a>
mov    %rsi,%r14
mov    %rdi,%r13
mov    %edx,%r12d
lea    -0x1(%r12),%rax
mov    %r12d,%r15d
and    $0x3,%r15d
cmp    $0x3,%rax
jae    1194 <vsqrt_double+0x84>
xor    %ebx,%ebx
test   %r15,%r15
je     118a <vsqrt_double+0x7a>
lea    0x0(,%rbx,8),%r12
add    %r13,%r12
lea    (%r14,%rbx,8),%r14
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
jmp    1178 <vsqrt_double+0x68>
cs nopw 0x0(%rax,%rax,1)
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
je     118a <vsqrt_double+0x7a>
movsd  (%r14,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1160 <vsqrt_double+0x50>
sqrtsd %xmm0,%xmm0
jmp    1169 <vsqrt_double+0x59>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
and    $0xfffffffc,%r12d
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
jmp    11b9 <vsqrt_double+0xa9>
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x18(%r13,%rbx,8)
add    $0x4,%rbx
cmp    %rbx,%r12
je     113a <vsqrt_double+0x2a>
movsd  (%r14,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     11d0 <vsqrt_double+0xc0>
sqrtsd %xmm0,%xmm0
jmp    11d9 <vsqrt_double+0xc9>
nopl   0x0(%rax,%rax,1)
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x0(%r13,%rbx,8)
movsd  0x8(%r14,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1200 <vsqrt_double+0xf0>
sqrtsd %xmm0,%xmm0
jmp    1209 <vsqrt_double+0xf9>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x8(%r13,%rbx,8)
movsd  0x10(%r14,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1230 <vsqrt_double+0x120>
sqrtsd %xmm0,%xmm0
jmp    1239 <vsqrt_double+0x129>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x10(%r13,%rbx,8)
movsd  0x18(%r14,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     11a0 <vsqrt_double+0x90>
sqrtsd %xmm0,%xmm0
jmp    11a9 <vsqrt_double+0x99>

LLVM IR (-O0):
define void @vsqrt_double(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %23, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %26
12: ; preds = %8
%13 = load double*, double** %5
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = call double @sqrt(double %17)
%19 = load double*, double** %4
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
store double %18, double* %22
br label %23
23: ; preds = %12
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %8
26: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @vsqrt_double(double* nocapture writeonly %0, double* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %25
5: ; preds = %3
%6 = zext i32 %2 to i64
%7 = add nsw i64 %6, -1
%8 = and i64 %6, 3
%9 = icmp ult i64 %7, 3
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = and i64 %6, 4294967292
br label %26
12: ; preds = %26, %5
%13 = phi i64 [ 0, %5 ], [ %48, %26 ]
%14 = icmp eq i64 %8, 0
br i1 %14, label %25, label %15
15: ; preds = %12, %15
%16 = phi i64 [ %22, %15 ], [ %13, %12 ]
%17 = phi i64 [ %23, %15 ], [ 0, %12 ]
%18 = getelementptr inbounds double, double* %1, i64 %16
%19 = load double, double* %18
%20 = tail call double @sqrt(double %19)
%21 = getelementptr inbounds double, double* %0, i64 %16
store double %20, double* %21
%22 = add nuw nsw i64 %16, 1
%23 = add i64 %17, 1
%24 = icmp eq i64 %23, %8
br i1 %24, label %25, label %15
25: ; preds = %12, %15, %3
ret void
26: ; preds = %26, %10
%27 = phi i64 [ 0, %10 ], [ %48, %26 ]
%28 = phi i64 [ 0, %10 ], [ %49, %26 ]
%29 = getelementptr inbounds double, double* %1, i64 %27
%30 = load double, double* %29
%31 = tail call double @sqrt(double %30)
%32 = getelementptr inbounds double, double* %0, i64 %27
store double %31, double* %32
%33 = or i64 %27, 1
%34 = getelementptr inbounds double, double* %1, i64 %33
%35 = load double, double* %34
%36 = tail call double @sqrt(double %35)
%37 = getelementptr inbounds double, double* %0, i64 %33
store double %36, double* %37
%38 = or i64 %27, 2
%39 = getelementptr inbounds double, double* %1, i64 %38
%40 = load double, double* %39
%41 = tail call double @sqrt(double %40)
%42 = getelementptr inbounds double, double* %0, i64 %38
store double %41, double* %42
%43 = or i64 %27, 3
%44 = getelementptr inbounds double, double* %1, i64 %43
%45 = load double, double* %44
%46 = tail call double @sqrt(double %45)
%47 = getelementptr inbounds double, double* %0, i64 %43
store double %46, double* %47
%48 = add nuw nsw i64 %27, 4
%49 = add i64 %28, 4
%50 = icmp eq i64 %49, %11
br i1 %50, label %12, label %26
}