void copy(double *u_new, double *u_old) {
  for (int i = 0; i < 100; i++) {
    u_old[i] = u_new[i];
  }
}


x86 assembly (clang, -O0):
<copy>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    1145 <copy+0x45>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1113 <copy+0x13>
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy>:
lea    0x320(%rdi),%rax
cmp    %rsi,%rax
jbe    1166 <copy+0x66>
lea    0x320(%rsi),%rax
cmp    %rdi,%rax
jbe    1166 <copy+0x66>
mov    $0x4,%eax
nopl   (%rax)
movsd  -0x20(%rdi,%rax,8),%xmm0
movsd  %xmm0,-0x20(%rsi,%rax,8)
movsd  -0x18(%rdi,%rax,8),%xmm0
movsd  %xmm0,-0x18(%rsi,%rax,8)
movsd  -0x10(%rdi,%rax,8),%xmm0
movsd  %xmm0,-0x10(%rsi,%rax,8)
movsd  -0x8(%rdi,%rax,8),%xmm0
movsd  %xmm0,-0x8(%rsi,%rax,8)
movsd  (%rdi,%rax,8),%xmm0
movsd  %xmm0,(%rsi,%rax,8)
add    $0x5,%rax
cmp    $0x68,%rax
jne    1120 <copy+0x20>
jmp    11aa <copy+0xaa>
mov    $0x8,%eax
nopl   0x0(%rax,%rax,1)
movups -0x40(%rdi,%rax,8),%xmm0
movups %xmm0,-0x40(%rsi,%rax,8)
movups -0x30(%rdi,%rax,8),%xmm0
movups %xmm0,-0x30(%rsi,%rax,8)
movups -0x20(%rdi,%rax,8),%xmm0
movups %xmm0,-0x20(%rsi,%rax,8)
movups -0x10(%rdi,%rax,8),%xmm0
movups %xmm0,-0x10(%rsi,%rax,8)
movups (%rdi,%rax,8),%xmm0
movups %xmm0,(%rsi,%rax,8)
add    $0xa,%rax
cmp    $0x6c,%rax
jne    1170 <copy+0x70>
ret

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

LLVM IR (-O2):
define void @copy(double* nocapture %0, double* nocapture writeonly %1) {
%3 = getelementptr double, double* %1, i64 100
%4 = getelementptr double, double* %0, i64 100
%5 = icmp ugt double* %4, %1
%6 = icmp ugt double* %3, %0
%7 = and i1 %5, %6
br i1 %7, label %42, label %8
8: ; preds = %2, %8
%9 = phi i64 [ %39, %8 ], [ 0, %2 ]
%10 = getelementptr inbounds double, double* %0, i64 %9
%11 = bitcast double* %10 to <2 x double>*
%12 = load <2 x double>, <2 x double>* %11
%13 = getelementptr inbounds double, double* %1, i64 %9
%14 = bitcast double* %13 to <2 x double>*
store <2 x double> %12, <2 x double>* %14
%15 = add nuw nsw i64 %9, 2
%16 = getelementptr inbounds double, double* %0, i64 %15
%17 = bitcast double* %16 to <2 x double>*
%18 = load <2 x double>, <2 x double>* %17
%19 = getelementptr inbounds double, double* %1, i64 %15
%20 = bitcast double* %19 to <2 x double>*
store <2 x double> %18, <2 x double>* %20
%21 = add nuw nsw i64 %9, 4
%22 = getelementptr inbounds double, double* %0, i64 %21
%23 = bitcast double* %22 to <2 x double>*
%24 = load <2 x double>, <2 x double>* %23
%25 = getelementptr inbounds double, double* %1, i64 %21
%26 = bitcast double* %25 to <2 x double>*
store <2 x double> %24, <2 x double>* %26
%27 = add nuw nsw i64 %9, 6
%28 = getelementptr inbounds double, double* %0, i64 %27
%29 = bitcast double* %28 to <2 x double>*
%30 = load <2 x double>, <2 x double>* %29
%31 = getelementptr inbounds double, double* %1, i64 %27
%32 = bitcast double* %31 to <2 x double>*
store <2 x double> %30, <2 x double>* %32
%33 = add nuw nsw i64 %9, 8
%34 = getelementptr inbounds double, double* %0, i64 %33
%35 = bitcast double* %34 to <2 x double>*
%36 = load <2 x double>, <2 x double>* %35
%37 = getelementptr inbounds double, double* %1, i64 %33
%38 = bitcast double* %37 to <2 x double>*
store <2 x double> %36, <2 x double>* %38
%39 = add nuw nsw i64 %9, 10
%40 = icmp eq i64 %39, 100
br i1 %40, label %41, label %8
41: ; preds = %8, %42
ret void
42: ; preds = %2, %42
%43 = phi i64 [ %63, %42 ], [ 0, %2 ]
%44 = getelementptr inbounds double, double* %0, i64 %43
%45 = load double, double* %44
%46 = getelementptr inbounds double, double* %1, i64 %43
store double %45, double* %46
%47 = add nuw nsw i64 %43, 1
%48 = getelementptr inbounds double, double* %0, i64 %47
%49 = load double, double* %48
%50 = getelementptr inbounds double, double* %1, i64 %47
store double %49, double* %50
%51 = add nuw nsw i64 %43, 2
%52 = getelementptr inbounds double, double* %0, i64 %51
%53 = load double, double* %52
%54 = getelementptr inbounds double, double* %1, i64 %51
store double %53, double* %54
%55 = add nuw nsw i64 %43, 3
%56 = getelementptr inbounds double, double* %0, i64 %55
%57 = load double, double* %56
%58 = getelementptr inbounds double, double* %1, i64 %55
store double %57, double* %58
%59 = add nuw nsw i64 %43, 4
%60 = getelementptr inbounds double, double* %0, i64 %59
%61 = load double, double* %60
%62 = getelementptr inbounds double, double* %1, i64 %59
store double %61, double* %62
%63 = add nuw nsw i64 %43, 5
%64 = icmp eq i64 %63, 100
br i1 %64, label %41, label %42
}