void mlcopy(int l, double A[l][l], double B[l][l]) {
  for (int i = 0; i < l; ++i) {
    for (int j = 0; j < l; ++j) {
      B[i][j] = A[i][j];
    }
  }
}


x86 assembly (clang, -O0):
<mlcopy>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a4 <mlcopy+0xa4>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1191 <mlcopy+0x91>
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   %rsi,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1137 <mlcopy+0x37>
jmp    1196 <mlcopy+0x96>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1124 <mlcopy+0x24>
pop    %rbp
ret

x86 assembly (clang, -O2):
<mlcopy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edi,%edi
jle    1365 <mlcopy+0x265>
mov    %edi,%r9d
mov    %r9d,%eax
and    $0xfffffffc,%eax
mov    %rax,-0x8(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x10(%rsp)
shr    $0x2,%rax
add    $0x1,%rax
mov    %eax,%r12d
and    $0x3,%r12d
and    $0xfffffffffffffffc,%rax
mov    %rax,-0x20(%rsp)
mov    %r9d,%ecx
and    $0x3,%ecx
lea    0x70(%rsi),%r10
lea    0x0(,%r9,8),%r15
lea    0x70(%rdx),%r8
mov    %r12,-0x18(%rsp)
shl    $0x5,%r12
xor    %r13d,%r13d
mov    %rsi,%rbp
mov    %rdx,%r14
mov    %rcx,-0x28(%rsp)
jmp    1189 <mlcopy+0x89>
add    $0x1,%r13
add    %r15,%r10
add    %r15,%r8
add    %r15,%r14
add    %r15,%rbp
cmp    %r9,%r13
je     1365 <mlcopy+0x265>
cmp    $0x4,%edi
jae    11a0 <mlcopy+0xa0>
xor    %r11d,%r11d
jmp    12d0 <mlcopy+0x1d0>
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rax
imul   %r9,%rax
lea    (%rax,%r9,1),%rcx
lea    (%rsi,%rcx,8),%r11
lea    (%rdx,%rax,8),%rbx
cmp    %r11,%rbx
jae    11e0 <mlcopy+0xe0>
lea    (%rsi,%rax,8),%rax
lea    (%rdx,%rcx,8),%rcx
cmp    %rcx,%rax
jae    11e0 <mlcopy+0xe0>
xor    %r11d,%r11d
mov    -0x28(%rsp),%rcx
jmp    12d0 <mlcopy+0x1d0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpq   $0xc,-0x10(%rsp)
jae    11ec <mlcopy+0xec>
xor    %eax,%eax
jmp    1268 <mlcopy+0x168>
mov    -0x20(%rsp),%rbx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movups -0x70(%r10,%rax,8),%xmm0
movups -0x60(%r10,%rax,8),%xmm1
movups %xmm0,-0x70(%r8,%rax,8)
movups %xmm1,-0x60(%r8,%rax,8)
movups -0x50(%r10,%rax,8),%xmm0
movups -0x40(%r10,%rax,8),%xmm1
movups %xmm0,-0x50(%r8,%rax,8)
movups %xmm1,-0x40(%r8,%rax,8)
movups -0x30(%r10,%rax,8),%xmm0
movups -0x20(%r10,%rax,8),%xmm1
movups %xmm0,-0x30(%r8,%rax,8)
movups %xmm1,-0x20(%r8,%rax,8)
movups -0x10(%r10,%rax,8),%xmm0
movups (%r10,%rax,8),%xmm1
movups %xmm0,-0x10(%r8,%rax,8)
movups %xmm1,(%r8,%rax,8)
add    $0x10,%rax
add    $0xfffffffffffffffc,%rbx
jne    1200 <mlcopy+0x100>
cmpq   $0x0,-0x18(%rsp)
je     12ab <mlcopy+0x1ab>
lea    (%r14,%rax,8),%rbx
lea    0x0(,%rax,8),%rax
add    %rbp,%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movups (%rax,%rcx,1),%xmm0
movups 0x10(%rax,%rcx,1),%xmm1
movups %xmm0,(%rbx,%rcx,1)
movups %xmm1,0x10(%rbx,%rcx,1)
add    $0x20,%rcx
cmp    %rcx,%r12
jne    1290 <mlcopy+0x190>
mov    -0x8(%rsp),%rax
mov    %rax,%r11
cmp    %r9,%rax
mov    -0x28(%rsp),%rcx
je     1170 <mlcopy+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r11,%rax
not    %rax
add    %r9,%rax
test   %rcx,%rcx
je     1307 <mlcopy+0x207>
mov    %rcx,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0x0(%rbp,%r11,8),%xmm0
movsd  %xmm0,(%r14,%r11,8)
add    $0x1,%r11
add    $0xffffffffffffffff,%rbx
jne    12f0 <mlcopy+0x1f0>
cmp    $0x3,%rax
jb     1170 <mlcopy+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0x0(%rbp,%r11,8),%xmm0
movsd  %xmm0,(%r14,%r11,8)
movsd  0x8(%rbp,%r11,8),%xmm0
movsd  %xmm0,0x8(%r14,%r11,8)
movsd  0x10(%rbp,%r11,8),%xmm0
movsd  %xmm0,0x10(%r14,%r11,8)
movsd  0x18(%rbp,%r11,8),%xmm0
movsd  %xmm0,0x18(%r14,%r11,8)
add    $0x4,%r11
cmp    %r11,%r9
jne    1320 <mlcopy+0x220>
jmp    1170 <mlcopy+0x70>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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