void copy_arrays_double(double *array_to, double *array_from, int length) {
  unsigned int i;
  for (i = 0; i < length; ++i)
    array_to[i] = array_from[i];
}


x86 assembly (clang, -O0):
<copy_arrays_double>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1148 <copy_arrays_double+0x48>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1116 <copy_arrays_double+0x16>
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_arrays_double>:
test   %edx,%edx
je     1276 <copy_arrays_double+0x176>
mov    %edx,%r9d
cmp    $0x4,%edx
jb     1126 <copy_arrays_double+0x26>
lea    (%rsi,%r9,8),%rax
cmp    %rdi,%rax
jbe    119c <copy_arrays_double+0x9c>
lea    (%rdi,%r9,8),%rax
cmp    %rsi,%rax
jbe    119c <copy_arrays_double+0x9c>
xor    %ecx,%ecx
mov    %rcx,%rax
not    %rax
add    %r9,%rax
mov    %r9,%rdx
and    $0x3,%rdx
je     1154 <copy_arrays_double+0x54>
nopw   0x0(%rax,%rax,1)
movsd  (%rsi,%rcx,8),%xmm0
movsd  %xmm0,(%rdi,%rcx,8)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rdx
jne    1140 <copy_arrays_double+0x40>
cmp    $0x3,%rax
jb     1276 <copy_arrays_double+0x176>
xchg   %ax,%ax
movsd  (%rsi,%rcx,8),%xmm0
movsd  %xmm0,(%rdi,%rcx,8)
movsd  0x8(%rsi,%rcx,8),%xmm0
movsd  %xmm0,0x8(%rdi,%rcx,8)
movsd  0x10(%rsi,%rcx,8),%xmm0
movsd  %xmm0,0x10(%rdi,%rcx,8)
movsd  0x18(%rsi,%rcx,8),%xmm0
movsd  %xmm0,0x18(%rdi,%rcx,8)
add    $0x4,%rcx
cmp    %rcx,%r9
jne    1160 <copy_arrays_double+0x60>
jmp    1276 <copy_arrays_double+0x176>
mov    %r9d,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rax
mov    %rax,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
mov    %edx,%r8d
and    $0x3,%r8d
cmp    $0xc,%rax
jae    11c2 <copy_arrays_double+0xc2>
xor    %eax,%eax
jmp    1228 <copy_arrays_double+0x128>
and    $0xfffffffffffffffc,%rdx
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
movups (%rsi,%rax,8),%xmm0
movups 0x10(%rsi,%rax,8),%xmm1
movups %xmm0,(%rdi,%rax,8)
movups %xmm1,0x10(%rdi,%rax,8)
movups 0x20(%rsi,%rax,8),%xmm0
movups 0x30(%rsi,%rax,8),%xmm1
movups %xmm0,0x20(%rdi,%rax,8)
movups %xmm1,0x30(%rdi,%rax,8)
movups 0x40(%rsi,%rax,8),%xmm0
movups 0x50(%rsi,%rax,8),%xmm1
movups %xmm0,0x40(%rdi,%rax,8)
movups %xmm1,0x50(%rdi,%rax,8)
movups 0x60(%rsi,%rax,8),%xmm0
movups 0x70(%rsi,%rax,8),%xmm1
movups %xmm0,0x60(%rdi,%rax,8)
movups %xmm1,0x70(%rdi,%rax,8)
add    $0x10,%rax
add    $0xfffffffffffffffc,%rdx
jne    11d0 <copy_arrays_double+0xd0>
test   %r8,%r8
je     126d <copy_arrays_double+0x16d>
lea    (%rdi,%rax,8),%r10
add    $0x10,%r10
lea    (%rsi,%rax,8),%rax
add    $0x10,%rax
shl    $0x5,%r8
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movups -0x10(%rax,%rdx,1),%xmm0
movups (%rax,%rdx,1),%xmm1
movups %xmm0,-0x10(%r10,%rdx,1)
movups %xmm1,(%r10,%rdx,1)
add    $0x20,%rdx
cmp    %rdx,%r8
jne    1250 <copy_arrays_double+0x150>
cmp    %r9,%rcx
jne    1128 <copy_arrays_double+0x28>
ret

LLVM IR (-O0):
define void @copy_arrays_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 = %22, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp ult i32 %9, %10
br i1 %11, label %12, label %25
12: ; preds = %8
%13 = load double*, double** %5
%14 = load i32, i32* %7
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = load double*, double** %4
%19 = load i32, i32* %7
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
store double %17, double* %21
br label %22
22: ; preds = %12
%23 = load i32, i32* %7
%24 = add i32 %23, 1
store i32 %24, i32* %7
br label %8
25: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @copy_arrays_double(double* nocapture writeonly %0, double* nocapture %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %130, label %5
5: ; preds = %3
%6 = zext i32 %2 to i64
%7 = icmp ult i32 %2, 4
br i1 %7, label %93, 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 %93, label %14
14: ; preds = %8
%15 = and i64 %6, 4294967292
%16 = add nsw i64 %15, -4
%17 = lshr exact i64 %16, 2
%18 = add nuw nsw i64 %17, 1
%19 = and i64 %18, 3
%20 = icmp ult i64 %16, 12
br i1 %20, label %72, label %21
21: ; preds = %14
%22 = and i64 %18, 9223372036854775804
br label %23
23: ; preds = %23, %21
%24 = phi i64 [ 0, %21 ], [ %69, %23 ]
%25 = phi i64 [ 0, %21 ], [ %70, %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 = getelementptr inbounds double, double* %26, i64 2
%30 = bitcast double* %29 to <2 x double>*
%31 = load <2 x double>, <2 x double>* %30
%32 = getelementptr inbounds double, double* %0, i64 %24
%33 = bitcast double* %32 to <2 x double>*
store <2 x double> %28, <2 x double>* %33
%34 = getelementptr inbounds double, double* %32, i64 2
%35 = bitcast double* %34 to <2 x double>*
store <2 x double> %31, <2 x double>* %35
%36 = or i64 %24, 4
%37 = getelementptr inbounds double, double* %1, i64 %36
%38 = bitcast double* %37 to <2 x double>*
%39 = load <2 x double>, <2 x double>* %38
%40 = getelementptr inbounds double, double* %37, i64 2
%41 = bitcast double* %40 to <2 x double>*
%42 = load <2 x double>, <2 x double>* %41
%43 = getelementptr inbounds double, double* %0, i64 %36
%44 = bitcast double* %43 to <2 x double>*
store <2 x double> %39, <2 x double>* %44
%45 = getelementptr inbounds double, double* %43, i64 2
%46 = bitcast double* %45 to <2 x double>*
store <2 x double> %42, <2 x double>* %46
%47 = or i64 %24, 8
%48 = getelementptr inbounds double, double* %1, i64 %47
%49 = bitcast double* %48 to <2 x double>*
%50 = load <2 x double>, <2 x double>* %49
%51 = getelementptr inbounds double, double* %48, i64 2
%52 = bitcast double* %51 to <2 x double>*
%53 = load <2 x double>, <2 x double>* %52
%54 = getelementptr inbounds double, double* %0, i64 %47
%55 = bitcast double* %54 to <2 x double>*
store <2 x double> %50, <2 x double>* %55
%56 = getelementptr inbounds double, double* %54, i64 2
%57 = bitcast double* %56 to <2 x double>*
store <2 x double> %53, <2 x double>* %57
%58 = or i64 %24, 12
%59 = getelementptr inbounds double, double* %1, i64 %58
%60 = bitcast double* %59 to <2 x double>*
%61 = load <2 x double>, <2 x double>* %60
%62 = getelementptr inbounds double, double* %59, i64 2
%63 = bitcast double* %62 to <2 x double>*
%64 = load <2 x double>, <2 x double>* %63
%65 = getelementptr inbounds double, double* %0, i64 %58
%66 = bitcast double* %65 to <2 x double>*
store <2 x double> %61, <2 x double>* %66
%67 = getelementptr inbounds double, double* %65, i64 2
%68 = bitcast double* %67 to <2 x double>*
store <2 x double> %64, <2 x double>* %68
%69 = add nuw i64 %24, 16
%70 = add nuw i64 %25, 4
%71 = icmp eq i64 %70, %22
br i1 %71, label %72, label %23
72: ; preds = %23, %14
%73 = phi i64 [ 0, %14 ], [ %69, %23 ]
%74 = icmp eq i64 %19, 0
br i1 %74, label %91, label %75
75: ; preds = %72, %75
%76 = phi i64 [ %88, %75 ], [ %73, %72 ]
%77 = phi i64 [ %89, %75 ], [ 0, %72 ]
%78 = getelementptr inbounds double, double* %1, i64 %76
%79 = bitcast double* %78 to <2 x double>*
%80 = load <2 x double>, <2 x double>* %79
%81 = getelementptr inbounds double, double* %78, i64 2
%82 = bitcast double* %81 to <2 x double>*
%83 = load <2 x double>, <2 x double>* %82
%84 = getelementptr inbounds double, double* %0, i64 %76
%85 = bitcast double* %84 to <2 x double>*
store <2 x double> %80, <2 x double>* %85
%86 = getelementptr inbounds double, double* %84, i64 2
%87 = bitcast double* %86 to <2 x double>*
store <2 x double> %83, <2 x double>* %87
%88 = add nuw i64 %76, 4
%89 = add i64 %77, 1
%90 = icmp eq i64 %89, %19
br i1 %90, label %91, label %75
91: ; preds = %75, %72
%92 = icmp eq i64 %15, %6
br i1 %92, label %130, label %93
93: ; preds = %8, %5, %91
%94 = phi i64 [ 0, %8 ], [ 0, %5 ], [ %15, %91 ]
%95 = xor i64 %94, -1
%96 = add nsw i64 %95, %6
%97 = and i64 %6, 3
%98 = icmp eq i64 %97, 0
br i1 %98, label %108, label %99
99: ; preds = %93, %99
%100 = phi i64 [ %105, %99 ], [ %94, %93 ]
%101 = phi i64 [ %106, %99 ], [ 0, %93 ]
%102 = getelementptr inbounds double, double* %1, i64 %100
%103 = load double, double* %102
%104 = getelementptr inbounds double, double* %0, i64 %100
store double %103, double* %104
%105 = add nuw nsw i64 %100, 1
%106 = add i64 %101, 1
%107 = icmp eq i64 %106, %97
br i1 %107, label %108, label %99
108: ; preds = %99, %93
%109 = phi i64 [ %94, %93 ], [ %105, %99 ]
%110 = icmp ult i64 %96, 3
br i1 %110, label %130, label %111
111: ; preds = %108, %111
%112 = phi i64 [ %128, %111 ], [ %109, %108 ]
%113 = getelementptr inbounds double, double* %1, i64 %112
%114 = load double, double* %113
%115 = getelementptr inbounds double, double* %0, i64 %112
store double %114, double* %115
%116 = add nuw nsw i64 %112, 1
%117 = getelementptr inbounds double, double* %1, i64 %116
%118 = load double, double* %117
%119 = getelementptr inbounds double, double* %0, i64 %116
store double %118, double* %119
%120 = add nuw nsw i64 %112, 2
%121 = getelementptr inbounds double, double* %1, i64 %120
%122 = load double, double* %121
%123 = getelementptr inbounds double, double* %0, i64 %120
store double %122, double* %123
%124 = add nuw nsw i64 %112, 3
%125 = getelementptr inbounds double, double* %1, i64 %124
%126 = load double, double* %125
%127 = getelementptr inbounds double, double* %0, i64 %124
store double %126, double* %127
%128 = add nuw nsw i64 %112, 4
%129 = icmp eq i64 %128, %6
br i1 %129, label %130, label %111
130: ; preds = %108, %111, %91, %3
ret void
}