void matrixCopy(double **ma, double **mb, int dimension) {
  int i, j;
  for (i = 0; i < dimension; i++) {
    for (j = 0; j < dimension; j++) {
      mb[i][j] = ma[i][j];
    }
  }
}


x86 assembly (clang, -O0):
<matrixCopy>:
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
jge    1180 <matrixCopy+0x80>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    116d <matrixCopy+0x6d>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1129 <matrixCopy+0x29>
jmp    1172 <matrixCopy+0x72>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1116 <matrixCopy+0x16>
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrixCopy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
jle    12be <matrixCopy+0x1be>
mov    %edx,%r13d
mov    %r13d,%r11d
and    $0xfffffffc,%r11d
lea    -0x4(%r11),%r9
mov    %r9,-0x8(%rsp)
shr    $0x2,%r9
add    $0x1,%r9
mov    %r9d,%r10d
and    $0x3,%r10d
and    $0xfffffffffffffffc,%r9
mov    %r13d,%r8d
and    $0x3,%r8d
mov    %r10,%r15
shl    $0x5,%r15
xor    %r12d,%r12d
jmp    115d <matrixCopy+0x5d>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    %r13,%r12
je     12be <matrixCopy+0x1be>
mov    (%rdi,%r12,8),%rbx
mov    (%rsi,%r12,8),%rcx
cmp    $0x4,%edx
jb     1184 <matrixCopy+0x84>
lea    (%rbx,%r13,8),%rax
cmp    %rax,%rcx
jae    1200 <matrixCopy+0x100>
lea    (%rcx,%r13,8),%rax
cmp    %rax,%rbx
jae    1200 <matrixCopy+0x100>
xor    %eax,%eax
mov    %rax,%rbp
not    %rbp
add    %r13,%rbp
test   %r8,%r8
je     11b4 <matrixCopy+0xb4>
mov    %r8,%r14
nopw   0x0(%rax,%rax,1)
movsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,(%rcx,%rax,8)
add    $0x1,%rax
add    $0xffffffffffffffff,%r14
jne    11a0 <matrixCopy+0xa0>
cmp    $0x3,%rbp
jb     1150 <matrixCopy+0x50>
nopw   0x0(%rax,%rax,1)
movsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,(%rcx,%rax,8)
movsd  0x8(%rbx,%rax,8),%xmm0
movsd  %xmm0,0x8(%rcx,%rax,8)
movsd  0x10(%rbx,%rax,8),%xmm0
movsd  %xmm0,0x10(%rcx,%rax,8)
movsd  0x18(%rbx,%rax,8),%xmm0
movsd  %xmm0,0x18(%rcx,%rax,8)
add    $0x4,%rax
cmp    %rax,%r13
jne    11c0 <matrixCopy+0xc0>
jmp    1150 <matrixCopy+0x50>
nopl   0x0(%rax)
cmpq   $0xc,-0x8(%rsp)
jae    120c <matrixCopy+0x10c>
xor    %eax,%eax
jmp    1278 <matrixCopy+0x178>
mov    %r9,%rbp
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movups (%rbx,%rax,8),%xmm0
movups 0x10(%rbx,%rax,8),%xmm1
movups %xmm0,(%rcx,%rax,8)
movups %xmm1,0x10(%rcx,%rax,8)
movups 0x20(%rbx,%rax,8),%xmm0
movups 0x30(%rbx,%rax,8),%xmm1
movups %xmm0,0x20(%rcx,%rax,8)
movups %xmm1,0x30(%rcx,%rax,8)
movups 0x40(%rbx,%rax,8),%xmm0
movups 0x50(%rbx,%rax,8),%xmm1
movups %xmm0,0x40(%rcx,%rax,8)
movups %xmm1,0x50(%rcx,%rax,8)
movups 0x60(%rbx,%rax,8),%xmm0
movups 0x70(%rbx,%rax,8),%xmm1
movups %xmm0,0x60(%rcx,%rax,8)
movups %xmm1,0x70(%rcx,%rax,8)
add    $0x10,%rax
add    $0xfffffffffffffffc,%rbp
jne    1220 <matrixCopy+0x120>
test   %r10,%r10
je     12ad <matrixCopy+0x1ad>
lea    (%rcx,%rax,8),%r14
add    $0x10,%r14
lea    (%rbx,%rax,8),%rax
add    $0x10,%rax
xor    %ebp,%ebp
nop
movups -0x10(%rax,%rbp,1),%xmm0
movups (%rax,%rbp,1),%xmm1
movups %xmm0,-0x10(%r14,%rbp,1)
movups %xmm1,(%r14,%rbp,1)
add    $0x20,%rbp
cmp    %rbp,%r15
jne    1290 <matrixCopy+0x190>
mov    %r11,%rax
cmp    %r13,%r11
je     1150 <matrixCopy+0x50>
jmp    1186 <matrixCopy+0x86>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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