void vsqrt_double(double *dst, double *src, int count) {
  for (int i = 0; i < count; ++i)
    dst[i] = __builtin_floor(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 <floor@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   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %edx,%edx
jle    12d0 <vsqrt_double+0x1c0>
mov    %rsi,%r14
mov    %rdi,%r12
mov    %edx,%r15d
cmp    $0x1,%edx
je     114e <vsqrt_double+0x3e>
lea    (%r14,%r15,8),%rax
cmp    %r12,%rax
jbe    11f8 <vsqrt_double+0xe8>
lea    (%r12,%r15,8),%rax
cmp    %r14,%rax
jbe    11f8 <vsqrt_double+0xe8>
xor    %ebx,%ebx
mov    %r15d,%ebp
sub    %ebx,%ebp
mov    %rbx,%r13
not    %r13
add    %r15,%r13
and    $0x3,%rbp
je     118b <vsqrt_double+0x7b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%r14,%rbx,8),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
add    $0xffffffffffffffff,%rbp
jne    1170 <vsqrt_double+0x60>
cmp    $0x3,%r13
jb     12d0 <vsqrt_double+0x1c0>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%r14,%rbx,8),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,(%r12,%rbx,8)
movsd  0x8(%r14,%rbx,8),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,0x8(%r12,%rbx,8)
movsd  0x10(%r14,%rbx,8),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,0x10(%r12,%rbx,8)
movsd  0x18(%r14,%rbx,8),%xmm0
call   1030 <floor@plt>
movsd  %xmm0,0x18(%r12,%rbx,8)
add    $0x4,%rbx
cmp    %rbx,%r15
jne    11a0 <vsqrt_double+0x90>
jmp    12d0 <vsqrt_double+0x1c0>
mov    %r15d,%ebx
and    $0xfffffffe,%ebx
lea    -0x2(%rbx),%rax
mov    %rax,%rbp
shr    %rbp
add    $0x1,%rbp
test   %rax,%rax
mov    %rbp,0x20(%rsp)
je     12df <vsqrt_double+0x1cf>
and    $0xfffffffffffffffe,%rbp
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movups (%r14,%r13,8),%xmm0
movaps %xmm0,(%rsp)
call   1030 <floor@plt>
movaps %xmm0,0x10(%rsp)
movaps (%rsp),%xmm0
movhlps %xmm0,%xmm0
call   1030 <floor@plt>
movaps 0x10(%rsp),%xmm1
movlhps %xmm0,%xmm1
movups %xmm1,(%r12,%r13,8)
movups 0x10(%r14,%r13,8),%xmm0
movaps %xmm0,(%rsp)
call   1030 <floor@plt>
movaps %xmm0,0x10(%rsp)
movaps (%rsp),%xmm0
movhlps %xmm0,%xmm0
call   1030 <floor@plt>
movaps 0x10(%rsp),%xmm1
movlhps %xmm0,%xmm1
movups %xmm1,0x10(%r12,%r13,8)
add    $0x4,%r13
add    $0xfffffffffffffffe,%rbp
jne    1230 <vsqrt_double+0x120>
testb  $0x1,0x20(%rsp)
je     12c7 <vsqrt_double+0x1b7>
movups (%r14,%r13,8),%xmm0
movaps %xmm0,(%rsp)
call   1030 <floor@plt>
movaps %xmm0,0x10(%rsp)
movaps (%rsp),%xmm0
movhlps %xmm0,%xmm0
call   1030 <floor@plt>
movaps 0x10(%rsp),%xmm1
movlhps %xmm0,%xmm1
movups %xmm1,(%r12,%r13,8)
cmp    %r15,%rbx
jne    1150 <vsqrt_double+0x40>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r13d,%r13d
testb  $0x1,0x20(%rsp)
jne    129b <vsqrt_double+0x18b>
jmp    12c7 <vsqrt_double+0x1b7>

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 @llvm.floor.f64(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 %74
5: ; preds = %3
%6 = zext i32 %2 to i64
%7 = icmp eq i32 %2, 1
br i1 %7, label %54, label %8
8: ; preds = %5
%9 = getelementptr double, double* %0, i64 %6
%10 = getelementptr double, double* %1, i64 %6
%11 = icmp ugt double* %10, %0
%12 = icmp ugt double* %9, %1
%13 = and i1 %11, %12
br i1 %13, label %54, label %14
14: ; preds = %8
%15 = and i64 %6, 4294967294
%16 = add nsw i64 %15, -2
%17 = lshr exact i64 %16, 1
%18 = add nuw i64 %17, 1
%19 = and i64 %18, 1
%20 = icmp eq i64 %16, 0
br i1 %20, label %42, label %21
21: ; preds = %14
%22 = and i64 %18, -2
br label %23
23: ; preds = %23, %21
%24 = phi i64 [ 0, %21 ], [ %39, %23 ]
%25 = phi i64 [ 0, %21 ], [ %40, %23 ]
%26 = getelementptr inbounds double, double* %1, i64 %24
%27 = bitcast double* %26 to <2 x double>*
%28 = load <2 x double>, <2 x double>* %27
%29 = call <2 x double> @llvm.floor.v2f64(<2 x double> %28)
%30 = getelementptr inbounds double, double* %0, i64 %24
%31 = bitcast double* %30 to <2 x double>*
store <2 x double> %29, <2 x double>* %31
%32 = or i64 %24, 2
%33 = getelementptr inbounds double, double* %1, i64 %32
%34 = bitcast double* %33 to <2 x double>*
%35 = load <2 x double>, <2 x double>* %34
%36 = call <2 x double> @llvm.floor.v2f64(<2 x double> %35)
%37 = getelementptr inbounds double, double* %0, i64 %32
%38 = bitcast double* %37 to <2 x double>*
store <2 x double> %36, <2 x double>* %38
%39 = add nuw i64 %24, 4
%40 = add nuw i64 %25, 2
%41 = icmp eq i64 %40, %22
br i1 %41, label %42, label %23
42: ; preds = %23, %14
%43 = phi i64 [ 0, %14 ], [ %39, %23 ]
%44 = icmp eq i64 %19, 0
br i1 %44, label %52, label %45
45: ; preds = %42
%46 = getelementptr inbounds double, double* %1, i64 %43
%47 = bitcast double* %46 to <2 x double>*
%48 = load <2 x double>, <2 x double>* %47
%49 = call <2 x double> @llvm.floor.v2f64(<2 x double> %48)
%50 = getelementptr inbounds double, double* %0, i64 %43
%51 = bitcast double* %50 to <2 x double>*
store <2 x double> %49, <2 x double>* %51
br label %52
52: ; preds = %42, %45
%53 = icmp eq i64 %15, %6
br i1 %53, label %74, label %54
54: ; preds = %8, %5, %52
%55 = phi i64 [ 0, %8 ], [ 0, %5 ], [ %15, %52 ]
%56 = sub nsw i64 %6, %55
%57 = xor i64 %55, -1
%58 = add nsw i64 %57, %6
%59 = and i64 %56, 3
%60 = icmp eq i64 %59, 0
br i1 %60, label %71, label %61
61: ; preds = %54, %61
%62 = phi i64 [ %68, %61 ], [ %55, %54 ]
%63 = phi i64 [ %69, %61 ], [ 0, %54 ]
%64 = getelementptr inbounds double, double* %1, i64 %62
%65 = load double, double* %64
%66 = tail call double @llvm.floor.f64(double %65)
%67 = getelementptr inbounds double, double* %0, i64 %62
store double %66, double* %67
%68 = add nuw nsw i64 %62, 1
%69 = add i64 %63, 1
%70 = icmp eq i64 %69, %59
br i1 %70, label %71, label %61
71: ; preds = %61, %54
%72 = phi i64 [ %55, %54 ], [ %68, %61 ]
%73 = icmp ult i64 %58, 3
br i1 %73, label %74, label %75
74: ; preds = %71, %75, %52, %3
ret void
75: ; preds = %71, %75
%76 = phi i64 [ %96, %75 ], [ %72, %71 ]
%77 = getelementptr inbounds double, double* %1, i64 %76
%78 = load double, double* %77
%79 = tail call double @llvm.floor.f64(double %78)
%80 = getelementptr inbounds double, double* %0, i64 %76
store double %79, double* %80
%81 = add nuw nsw i64 %76, 1
%82 = getelementptr inbounds double, double* %1, i64 %81
%83 = load double, double* %82
%84 = tail call double @llvm.floor.f64(double %83)
%85 = getelementptr inbounds double, double* %0, i64 %81
store double %84, double* %85
%86 = add nuw nsw i64 %76, 2
%87 = getelementptr inbounds double, double* %1, i64 %86
%88 = load double, double* %87
%89 = tail call double @llvm.floor.f64(double %88)
%90 = getelementptr inbounds double, double* %0, i64 %86
store double %89, double* %90
%91 = add nuw nsw i64 %76, 3
%92 = getelementptr inbounds double, double* %1, i64 %91
%93 = load double, double* %92
%94 = tail call double @llvm.floor.f64(double %93)
%95 = getelementptr inbounds double, double* %0, i64 %91
store double %94, double* %95
%96 = add nuw nsw i64 %76, 4
%97 = icmp eq i64 %96, %6
br i1 %97, label %74, label %75
}