void copy_mem_double(int howmany, void *old, void *new) {
  register int i;
  double *dold = old;
  double *dnew = new;
  for (i = 0; i < howmany; i++)
    dnew[i] = dold[i];
}


x86 assembly (clang, -O0):
<copy_mem_double>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    115a <copy_mem_double+0x5a>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1126 <copy_mem_double+0x26>
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_mem_double>:
test   %edi,%edi
jle    1276 <copy_mem_double+0x176>
mov    %edi,%r9d
cmp    $0x4,%edi
jb     1126 <copy_mem_double+0x26>
lea    (%rsi,%r9,8),%rax
cmp    %rdx,%rax
jbe    119c <copy_mem_double+0x9c>
lea    (%rdx,%r9,8),%rax
cmp    %rsi,%rax
jbe    119c <copy_mem_double+0x9c>
xor    %ecx,%ecx
mov    %rcx,%rax
not    %rax
add    %r9,%rax
mov    %r9,%rdi
and    $0x3,%rdi
je     1154 <copy_mem_double+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_mem_double+0x40>
cmp    $0x3,%rax
jb     1276 <copy_mem_double+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_mem_double+0x60>
jmp    1276 <copy_mem_double+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_mem_double+0xc2>
xor    %eax,%eax
jmp    1228 <copy_mem_double+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_mem_double+0xd0>
test   %r8,%r8
je     126d <copy_mem_double+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_mem_double+0x150>
cmp    %r9,%rcx
jne    1128 <copy_mem_double+0x28>
ret

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

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