void copy_double_RT(int nrow, int ncol, double **from, double **to) {
  int i, j;
  for (i = 0; i < nrow; i++) {
    for (j = 0; j < ncol; j++) {
      to[i][j] = from[i][j];
    }
  }
}


x86 assembly (clang, -O0):
<copy_double_RT>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1183 <copy_double_RT+0x83>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1170 <copy_double_RT+0x70>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112c <copy_double_RT+0x2c>
jmp    1175 <copy_double_RT+0x75>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1119 <copy_double_RT+0x19>
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_double_RT>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edi,%edi
jle    12bf <copy_double_RT+0x1bf>
mov    %edi,%r14d
mov    %esi,%r8d
mov    %r8d,%r11d
and    $0xfffffffc,%r11d
lea    -0x4(%r11),%r9
mov    %r9,-0x8(%rsp)
shr    $0x2,%r9
add    $0x1,%r9
mov    %r9d,%r12d
and    $0x3,%r12d
and    $0xfffffffffffffffc,%r9
mov    %r8d,%r15d
and    $0x3,%r15d
mov    %r12,-0x10(%rsp)
shl    $0x5,%r12
xor    %r13d,%r13d
jmp    115d <copy_double_RT+0x5d>
add    $0x1,%r13
cmp    %r14,%r13
je     12bf <copy_double_RT+0x1bf>
test   %esi,%esi
jle    1150 <copy_double_RT+0x50>
mov    (%rdx,%r13,8),%rax
mov    (%rcx,%r13,8),%rbx
cmp    $0x4,%esi
jb     1184 <copy_double_RT+0x84>
lea    (%rax,%r8,8),%rdi
cmp    %rdi,%rbx
jae    11fc <copy_double_RT+0xfc>
lea    (%rbx,%r8,8),%rdi
cmp    %rdi,%rax
jae    11fc <copy_double_RT+0xfc>
xor    %ebp,%ebp
mov    %rbp,%r10
not    %r10
add    %r8,%r10
test   %r15,%r15
je     11b4 <copy_double_RT+0xb4>
mov    %r15,%rdi
nopw   0x0(%rax,%rax,1)
movsd  (%rax,%rbp,8),%xmm0
movsd  %xmm0,(%rbx,%rbp,8)
add    $0x1,%rbp
add    $0xffffffffffffffff,%rdi
jne    11a0 <copy_double_RT+0xa0>
cmp    $0x3,%r10
jb     1150 <copy_double_RT+0x50>
nopw   0x0(%rax,%rax,1)
movsd  (%rax,%rbp,8),%xmm0
movsd  %xmm0,(%rbx,%rbp,8)
movsd  0x8(%rax,%rbp,8),%xmm0
movsd  %xmm0,0x8(%rbx,%rbp,8)
movsd  0x10(%rax,%rbp,8),%xmm0
movsd  %xmm0,0x10(%rbx,%rbp,8)
movsd  0x18(%rax,%rbp,8),%xmm0
movsd  %xmm0,0x18(%rbx,%rbp,8)
add    $0x4,%rbp
cmp    %rbp,%r8
jne    11c0 <copy_double_RT+0xc0>
jmp    1150 <copy_double_RT+0x50>
cmpq   $0xc,-0x8(%rsp)
jae    1208 <copy_double_RT+0x108>
xor    %ebp,%ebp
jmp    1268 <copy_double_RT+0x168>
mov    %r9,%r10
xor    %ebp,%ebp
nopl   (%rax)
movups (%rax,%rbp,8),%xmm0
movups 0x10(%rax,%rbp,8),%xmm1
movups %xmm0,(%rbx,%rbp,8)
movups %xmm1,0x10(%rbx,%rbp,8)
movups 0x20(%rax,%rbp,8),%xmm0
movups 0x30(%rax,%rbp,8),%xmm1
movups %xmm0,0x20(%rbx,%rbp,8)
movups %xmm1,0x30(%rbx,%rbp,8)
movups 0x40(%rax,%rbp,8),%xmm0
movups 0x50(%rax,%rbp,8),%xmm1
movups %xmm0,0x40(%rbx,%rbp,8)
movups %xmm1,0x50(%rbx,%rbp,8)
movups 0x60(%rax,%rbp,8),%xmm0
movups 0x70(%rax,%rbp,8),%xmm1
movups %xmm0,0x60(%rbx,%rbp,8)
movups %xmm1,0x70(%rbx,%rbp,8)
add    $0x10,%rbp
add    $0xfffffffffffffffc,%r10
jne    1210 <copy_double_RT+0x110>
cmpq   $0x0,-0x10(%rsp)
je     12ae <copy_double_RT+0x1ae>
lea    (%rbx,%rbp,8),%r10
add    $0x10,%r10
lea    (%rax,%rbp,8),%rbp
add    $0x10,%rbp
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movups -0x10(%rbp,%rdi,1),%xmm0
movups 0x0(%rbp,%rdi,1),%xmm1
movups %xmm0,-0x10(%r10,%rdi,1)
movups %xmm1,(%r10,%rdi,1)
add    $0x20,%rdi
cmp    %rdi,%r12
jne    1290 <copy_double_RT+0x190>
mov    %r11,%rbp
cmp    %r8,%r11
je     1150 <copy_double_RT+0x50>
jmp    1186 <copy_double_RT+0x86>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @copy_double_RT(i32 %0, i32 %1, double** %2, double** %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double**
%8 = alloca double**
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store double** %2, double*** %7
store double** %3, double*** %8
store i32 0, i32* %9
br label %11
11: ; preds = %42, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %5
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %45
15: ; preds = %11
store i32 0, i32* %10
br label %16
16: ; preds = %38, %15
%17 = load i32, i32* %10
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %41
20: ; preds = %16
%21 = load double**, double*** %7
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double*, double** %21, i64 %23
%25 = load double*, double** %24
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = load double**, double*** %8
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double*, double** %30, i64 %32
%34 = load double*, double** %33
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
store double %29, double* %37
br label %38
38: ; preds = %20
%39 = load i32, i32* %10
%40 = add nsw i32 %39, 1
store i32 %40, i32* %10
br label %16
41: ; preds = %16
br label %42
42: ; preds = %41
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
store i32 %44, i32* %9
br label %11
45: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @copy_double_RT(i32 %0, i32 %1, double** nocapture %2, double** nocapture %3) {
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %143
6: ; preds = %4
%7 = icmp sgt i32 %1, 0
%8 = zext i32 %0 to i64
%9 = zext i32 %1 to i64
%10 = and i64 %9, 4294967292
%11 = add nsw i64 %10, -4
%12 = lshr exact i64 %11, 2
%13 = add nuw nsw i64 %12, 1
%14 = icmp ult i32 %1, 4
%15 = and i64 %9, 4294967292
%16 = and i64 %13, 3
%17 = icmp ult i64 %11, 12
%18 = and i64 %13, 9223372036854775804
%19 = icmp eq i64 %16, 0
%20 = icmp eq i64 %15, %9
%21 = and i64 %9, 3
%22 = icmp eq i64 %21, 0
br label %23
23: ; preds = %6, %140
%24 = phi i64 [ 0, %6 ], [ %141, %140 ]
br i1 %7, label %25, label %140
25: ; preds = %23
%26 = getelementptr inbounds double*, double** %2, i64 %24
%27 = load double*, double** %26
%28 = getelementptr inbounds double*, double** %3, i64 %24
%29 = load double*, double** %28
br i1 %14, label %105, label %30
30: ; preds = %25
%31 = getelementptr double, double* %29, i64 %9
%32 = getelementptr double, double* %27, i64 %9
%33 = icmp ult double* %29, %32
%34 = icmp ult double* %27, %31
%35 = and i1 %33, %34
br i1 %35, label %105, label %36
36: ; preds = %30
br i1 %17, label %86, label %37
37: ; preds = %36, %37
%38 = phi i64 [ %83, %37 ], [ 0, %36 ]
%39 = phi i64 [ %84, %37 ], [ 0, %36 ]
%40 = getelementptr inbounds double, double* %27, i64 %38
%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* %29, i64 %38
%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 %38, 4
%51 = getelementptr inbounds double, double* %27, 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* %29, 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 %38, 8
%62 = getelementptr inbounds double, double* %27, 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* %29, 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 = or i64 %38, 12
%73 = getelementptr inbounds double, double* %27, i64 %72
%74 = bitcast double* %73 to <2 x double>*
%75 = load <2 x double>, <2 x double>* %74
%76 = getelementptr inbounds double, double* %73, i64 2
%77 = bitcast double* %76 to <2 x double>*
%78 = load <2 x double>, <2 x double>* %77
%79 = getelementptr inbounds double, double* %29, i64 %72
%80 = bitcast double* %79 to <2 x double>*
store <2 x double> %75, <2 x double>* %80
%81 = getelementptr inbounds double, double* %79, i64 2
%82 = bitcast double* %81 to <2 x double>*
store <2 x double> %78, <2 x double>* %82
%83 = add nuw i64 %38, 16
%84 = add nuw i64 %39, 4
%85 = icmp eq i64 %84, %18
br i1 %85, label %86, label %37
86: ; preds = %37, %36
%87 = phi i64 [ 0, %36 ], [ %83, %37 ]
br i1 %19, label %104, label %88
88: ; preds = %86, %88
%89 = phi i64 [ %101, %88 ], [ %87, %86 ]
%90 = phi i64 [ %102, %88 ], [ 0, %86 ]
%91 = getelementptr inbounds double, double* %27, i64 %89
%92 = bitcast double* %91 to <2 x double>*
%93 = load <2 x double>, <2 x double>* %92
%94 = getelementptr inbounds double, double* %91, i64 2
%95 = bitcast double* %94 to <2 x double>*
%96 = load <2 x double>, <2 x double>* %95
%97 = getelementptr inbounds double, double* %29, i64 %89
%98 = bitcast double* %97 to <2 x double>*
store <2 x double> %93, <2 x double>* %98
%99 = getelementptr inbounds double, double* %97, i64 2
%100 = bitcast double* %99 to <2 x double>*
store <2 x double> %96, <2 x double>* %100
%101 = add nuw i64 %89, 4
%102 = add i64 %90, 1
%103 = icmp eq i64 %102, %16
br i1 %103, label %104, label %88
104: ; preds = %88, %86
br i1 %20, label %140, label %105
105: ; preds = %30, %25, %104
%106 = phi i64 [ 0, %30 ], [ 0, %25 ], [ %15, %104 ]
%107 = xor i64 %106, -1
%108 = add nsw i64 %107, %9
br i1 %22, label %118, label %109
109: ; preds = %105, %109
%110 = phi i64 [ %115, %109 ], [ %106, %105 ]
%111 = phi i64 [ %116, %109 ], [ 0, %105 ]
%112 = getelementptr inbounds double, double* %27, i64 %110
%113 = load double, double* %112
%114 = getelementptr inbounds double, double* %29, i64 %110
store double %113, double* %114
%115 = add nuw nsw i64 %110, 1
%116 = add i64 %111, 1
%117 = icmp eq i64 %116, %21
br i1 %117, label %118, label %109
118: ; preds = %109, %105
%119 = phi i64 [ %106, %105 ], [ %115, %109 ]
%120 = icmp ult i64 %108, 3
br i1 %120, label %140, label %121
121: ; preds = %118, %121
%122 = phi i64 [ %138, %121 ], [ %119, %118 ]
%123 = getelementptr inbounds double, double* %27, i64 %122
%124 = load double, double* %123
%125 = getelementptr inbounds double, double* %29, i64 %122
store double %124, double* %125
%126 = add nuw nsw i64 %122, 1
%127 = getelementptr inbounds double, double* %27, i64 %126
%128 = load double, double* %127
%129 = getelementptr inbounds double, double* %29, i64 %126
store double %128, double* %129
%130 = add nuw nsw i64 %122, 2
%131 = getelementptr inbounds double, double* %27, i64 %130
%132 = load double, double* %131
%133 = getelementptr inbounds double, double* %29, i64 %130
store double %132, double* %133
%134 = add nuw nsw i64 %122, 3
%135 = getelementptr inbounds double, double* %27, i64 %134
%136 = load double, double* %135
%137 = getelementptr inbounds double, double* %29, i64 %134
store double %136, double* %137
%138 = add nuw nsw i64 %122, 4
%139 = icmp eq i64 %138, %9
br i1 %139, label %140, label %121
140: ; preds = %118, %121, %104, %23
%141 = add nuw nsw i64 %24, 1
%142 = icmp eq i64 %141, %8
br i1 %142, label %143, label %23
143: ; preds = %140, %4
ret void
}