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


x86 assembly (clang, -O0):
<mladd>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x40(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x38(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11cf <mladd+0xcf>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11bc <mladd+0xbc>
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   %rdi,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   %rsi,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1142 <mladd+0x42>
jmp    11c1 <mladd+0xc1>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112f <mladd+0x2f>
pop    %rbp
ret

x86 assembly (clang, -O2):
<mladd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,-0x40(%rsp)
mov    %rdx,-0x48(%rsp)
mov    %rsi,-0x50(%rsp)
test   %edi,%edi
jle    13eb <mladd+0x2eb>
mov    %edi,%r12d
mov    %r12d,%eax
and    $0xfffffffc,%eax
mov    %rax,-0x20(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x28(%rsp)
mov    %rax,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,-0x30(%rsp)
and    $0xfffffffffffffffe,%rcx
mov    %rcx,-0x38(%rsp)
mov    %r12d,%r9d
and    $0x3,%r9d
mov    -0x50(%rsp),%rsi
lea    0x30(%rsi),%r13
lea    0x0(,%r12,8),%r10
mov    -0x48(%rsp),%rdx
lea    0x30(%rdx),%r15
mov    -0x40(%rsp),%rcx
lea    0x30(%rcx),%rbx
xor    %r14d,%r14d
mov    %r10,-0x58(%rsp)
mov    %r9,-0x60(%rsp)
mov    %edi,-0x64(%rsp)
jmp    11bf <mladd+0xbf>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14
add    %r10,%r13
add    %r10,%r15
add    %r10,%rbx
add    %r10,%rcx
add    %r10,%rdx
add    %r10,%rsi
cmp    %r12,%r14
je     13eb <mladd+0x2eb>
cmp    $0x4,%edi
jae    1270 <mladd+0x170>
xor    %r11d,%r11d
mov    %r11,%r8
not    %r8
add    %r12,%r8
test   %r9,%r9
je     11fc <mladd+0xfc>
mov    %r9,%rbp
nopl   0x0(%rax)
movsd  (%rsi,%r11,8),%xmm0
addsd  (%rdx,%r11,8),%xmm0
movsd  %xmm0,(%rcx,%r11,8)
add    $0x1,%r11
add    $0xffffffffffffffff,%rbp
jne    11e0 <mladd+0xe0>
cmp    $0x3,%r8
jb     11a0 <mladd+0xa0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%rsi,%r11,8),%xmm0
addsd  (%rdx,%r11,8),%xmm0
movsd  %xmm0,(%rcx,%r11,8)
movsd  0x8(%rsi,%r11,8),%xmm0
addsd  0x8(%rdx,%r11,8),%xmm0
movsd  %xmm0,0x8(%rcx,%r11,8)
movsd  0x10(%rsi,%r11,8),%xmm0
addsd  0x10(%rdx,%r11,8),%xmm0
movsd  %xmm0,0x10(%rcx,%r11,8)
movsd  0x18(%rsi,%r11,8),%xmm0
addsd  0x18(%rdx,%r11,8),%xmm0
movsd  %xmm0,0x18(%rcx,%r11,8)
add    $0x4,%r11
cmp    %r11,%r12
jne    1210 <mladd+0x110>
jmp    11a0 <mladd+0xa0>
nop
mov    %r14,%rdi
imul   %r12,%rdi
lea    (%rdi,%r12,1),%rbp
mov    -0x40(%rsp),%r9
lea    (%r9,%rdi,8),%r8
lea    (%r9,%rbp,8),%r11
mov    -0x50(%rsp),%r10
lea    (%r10,%rdi,8),%rax
mov    -0x48(%rsp),%r9
lea    (%r9,%rdi,8),%rdi
mov    %rdi,-0x8(%rsp)
lea    (%r9,%rbp,8),%rdi
lea    (%r10,%rbp,8),%rbp
cmp    %rbp,%r8
setb   %r10b
mov    %rax,-0x18(%rsp)
cmp    %r11,%rax
setb   %r9b
mov    %r8,-0x10(%rsp)
cmp    %rdi,%r8
mov    -0x8(%rsp),%r8
setb   %dil
cmp    %r11,%r8
setb   %bpl
test   %r9b,%r10b
jne    13ca <mladd+0x2ca>
mov    $0x0,%r11d
and    %bpl,%dil
mov    -0x64(%rsp),%edi
mov    -0x60(%rsp),%r9
mov    -0x58(%rsp),%r10
jne    11cb <mladd+0xcb>
cmpq   $0x0,-0x28(%rsp)
je     13e0 <mladd+0x2e0>
mov    -0x38(%rsp),%rax
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movupd -0x30(%r13,%rbp,8),%xmm0
movupd -0x20(%r13,%rbp,8),%xmm1
movupd -0x30(%r15,%rbp,8),%xmm2
addpd  %xmm0,%xmm2
movupd -0x20(%r15,%rbp,8),%xmm0
addpd  %xmm1,%xmm0
movupd %xmm2,-0x30(%rbx,%rbp,8)
movupd %xmm0,-0x20(%rbx,%rbp,8)
movupd -0x10(%r13,%rbp,8),%xmm0
movupd 0x0(%r13,%rbp,8),%xmm1
movupd -0x10(%r15,%rbp,8),%xmm2
addpd  %xmm0,%xmm2
movupd (%r15,%rbp,8),%xmm0
addpd  %xmm1,%xmm0
movupd %xmm2,-0x10(%rbx,%rbp,8)
movupd %xmm0,(%rbx,%rbp,8)
add    $0x8,%rbp
add    $0xfffffffffffffffe,%rax
jne    1310 <mladd+0x210>
testb  $0x1,-0x30(%rsp)
je     13b4 <mladd+0x2b4>
mov    -0x18(%rsp),%rax
movupd (%rax,%rbp,8),%xmm0
movupd 0x10(%rax,%rbp,8),%xmm1
movupd (%r8,%rbp,8),%xmm2
addpd  %xmm0,%xmm2
movupd 0x10(%r8,%rbp,8),%xmm0
addpd  %xmm1,%xmm0
mov    -0x10(%rsp),%rax
movupd %xmm2,(%rax,%rbp,8)
movupd %xmm0,0x10(%rax,%rbp,8)
mov    -0x20(%rsp),%rax
mov    %rax,%r11
cmp    %r12,%rax
je     11a0 <mladd+0xa0>
jmp    11cb <mladd+0xcb>
xor    %r11d,%r11d
mov    -0x64(%rsp),%edi
mov    -0x60(%rsp),%r9
mov    -0x58(%rsp),%r10
jmp    11cb <mladd+0xcb>
xor    %ebp,%ebp
testb  $0x1,-0x30(%rsp)
jne    137f <mladd+0x27f>
jmp    13b4 <mladd+0x2b4>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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