void copy_double_1D(int length, double *from, double *to) {
  int i;
  for (i = 0; i < length; i++) {
    to[i] = from[i];
  }
}


x86 assembly (clang, -O0):
<copy_double_1D>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    114a <copy_double_1D+0x4a>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1116 <copy_double_1D+0x16>
pop    %rbp
ret

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

LLVM IR (-O0):
define void @copy_double_1D(i32 %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
store i32 %0, i32* %4
store double* %1, double** %5
store double* %2, double** %6
store i32 0, i32* %7
br label %8
8: ; preds = %22, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %25
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 = load double*, double** %6
%19 = load i32, i32* %7
%20 = sext 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 nsw i32 %23, 1
store i32 %24, i32* %7
br label %8
25: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @copy_double_1D(i32 %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %130
5: ; preds = %3
%6 = zext i32 %0 to i64
%7 = icmp ult i32 %0, 4
br i1 %7, label %93, label %8
8: ; preds = %5
%9 = getelementptr double, double* %2, i64 %6
%10 = getelementptr double, double* %1, i64 %6
%11 = icmp ugt double* %10, %2
%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* %2, 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* %2, 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* %2, 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* %2, 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* %2, 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* %2, 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* %2, 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* %2, 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* %2, 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* %2, 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
}