void double_add_matrix(unsigned int lines, unsigned int columns,
                       double m1[20][20], double m2[20][20],
                       double result[20][20]) {
  unsigned int i, j;
  for (i = 0; i < lines; i++) {
    for (j = 0; j < columns; j++) {
      result[i][j] = m1[i][j] + m2[i][j];
    }
  }
}


x86 assembly (clang, -O0):
<double_add_matrix>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    11a8 <double_add_matrix+0xa8>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1195 <double_add_matrix+0x95>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   $0xa0,%rcx,%rcx
add    %rcx,%rax
mov    -0x28(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   $0xa0,%rcx,%rcx
add    %rcx,%rax
mov    -0x28(%rbp),%ecx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   $0xa0,%rcx,%rcx
add    %rcx,%rax
mov    -0x28(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1130 <double_add_matrix+0x30>
jmp    119a <double_add_matrix+0x9a>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    111d <double_add_matrix+0x1d>
pop    %rbp
ret

x86 assembly (clang, -O2):
<double_add_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edi,%edi
je     13cb <double_add_matrix+0x2cb>
mov    %edi,%eax
mov    %rax,-0x8(%rsp)
mov    %esi,%r13d
mov    %r13d,%eax
and    $0xfffffffc,%eax
mov    %rax,-0x18(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x20(%rsp)
mov    %rax,%rdi
shr    $0x2,%rdi
add    $0x1,%rdi
mov    %rdi,%rax
mov    %rdi,-0x28(%rsp)
and    $0xfffffffffffffffe,%rdi
mov    %rdi,-0x30(%rsp)
mov    %r13,%rax
neg    %rax
mov    %rax,-0x10(%rsp)
lea    0x30(%rdx),%r9
lea    0x30(%rcx),%rax
lea    0x30(%r8),%rdi
lea    0x8(%rdx),%rbp
lea    0x8(%rcx),%r14
lea    0x8(%r8),%r10
xor    %r11d,%r11d
mov    %r8,-0x40(%rsp)
mov    %rcx,-0x48(%rsp)
mov    %esi,-0x5c(%rsp)
mov    %rdx,-0x50(%rsp)
jmp    11c8 <double_add_matrix+0xc8>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r11
add    $0xa0,%r9
add    $0xa0,%rax
add    $0xa0,%rdi
add    $0xa0,%rbp
add    $0xa0,%r14
add    $0xa0,%r10
cmp    -0x8(%rsp),%r11
je     13cb <double_add_matrix+0x2cb>
test   %esi,%esi
je     1190 <double_add_matrix+0x90>
mov    %r11,%rbx
shl    $0x5,%rbx
lea    (%rbx,%rbx,4),%r15
lea    (%r8,%r15,1),%rbx
lea    (%rdx,%r15,1),%r12
add    %rcx,%r15
cmp    $0x4,%esi
mov    %rbx,-0x58(%rsp)
mov    %r12,-0x38(%rsp)
jae    1200 <double_add_matrix+0x100>
xor    %r12d,%r12d
jmp    1340 <double_add_matrix+0x240>
nopl   0x0(%rax)
lea    (%rbx,%r13,8),%rdx
lea    (%r12,%r13,8),%rcx
lea    (%r15,%r13,8),%r8
cmp    %rcx,%rbx
mov    %r12,%rcx
setb   %r12b
cmp    %rdx,%rcx
setb   %sil
cmp    %r8,%rbx
setb   %cl
cmp    %rdx,%r15
setb   %r8b
test   %sil,%r12b
jne    1323 <double_add_matrix+0x223>
mov    $0x0,%r12d
and    %r8b,%cl
mov    -0x40(%rsp),%r8
mov    -0x48(%rsp),%rcx
mov    -0x50(%rsp),%rdx
mov    -0x5c(%rsp),%esi
jne    1340 <double_add_matrix+0x240>
cmpq   $0x0,-0x20(%rsp)
je     13b4 <double_add_matrix+0x2b4>
mov    -0x30(%rsp),%rsi
xor    %ebx,%ebx
mov    -0x58(%rsp),%r12
nopl   (%rax)
movupd -0x30(%r9,%rbx,8),%xmm0
movupd -0x20(%r9,%rbx,8),%xmm1
movupd -0x30(%rax,%rbx,8),%xmm2
addpd  %xmm0,%xmm2
movupd -0x20(%rax,%rbx,8),%xmm0
addpd  %xmm1,%xmm0
movupd %xmm2,-0x30(%rdi,%rbx,8)
movupd %xmm0,-0x20(%rdi,%rbx,8)
movupd -0x10(%r9,%rbx,8),%xmm0
movupd (%r9,%rbx,8),%xmm1
movupd -0x10(%rax,%rbx,8),%xmm2
addpd  %xmm0,%xmm2
movupd (%rax,%rbx,8),%xmm0
addpd  %xmm1,%xmm0
movupd %xmm2,-0x10(%rdi,%rbx,8)
movupd %xmm0,(%rdi,%rbx,8)
add    $0x8,%rbx
add    $0xfffffffffffffffe,%rsi
jne    1270 <double_add_matrix+0x170>
testb  $0x1,-0x28(%rsp)
je     130c <double_add_matrix+0x20c>
mov    -0x38(%rsp),%rsi
movupd (%rsi,%rbx,8),%xmm0
movupd 0x10(%rsi,%rbx,8),%xmm1
movupd (%r15,%rbx,8),%xmm2
addpd  %xmm0,%xmm2
movupd 0x10(%r15,%rbx,8),%xmm0
addpd  %xmm1,%xmm0
movupd %xmm2,(%r12,%rbx,8)
movupd %xmm0,0x10(%r12,%rbx,8)
mov    -0x18(%rsp),%rsi
mov    %rsi,%r12
cmp    %r13,%rsi
mov    -0x5c(%rsp),%esi
je     1190 <double_add_matrix+0x90>
jmp    1340 <double_add_matrix+0x240>
xor    %r12d,%r12d
mov    -0x40(%rsp),%r8
mov    -0x48(%rsp),%rcx
mov    -0x50(%rsp),%rdx
mov    -0x5c(%rsp),%esi
nopl   0x0(%rax)
mov    %r12,%rbx
test   $0x1,%r13b
je     136c <double_add_matrix+0x26c>
mov    -0x38(%rsp),%rbx
movsd  (%rbx,%r12,8),%xmm0
addsd  (%r15,%r12,8),%xmm0
mov    -0x58(%rsp),%rbx
movsd  %xmm0,(%rbx,%r12,8)
mov    %r12,%rbx
or     $0x1,%rbx
not    %r12
cmp    -0x10(%rsp),%r12
je     1190 <double_add_matrix+0x90>
nopw   0x0(%rax,%rax,1)
movsd  -0x8(%rbp,%rbx,8),%xmm0
addsd  -0x8(%r14,%rbx,8),%xmm0
movsd  %xmm0,-0x8(%r10,%rbx,8)
movsd  0x0(%rbp,%rbx,8),%xmm0
addsd  (%r14,%rbx,8),%xmm0
movsd  %xmm0,(%r10,%rbx,8)
add    $0x2,%rbx
cmp    %rbx,%r13
jne    1380 <double_add_matrix+0x280>
jmp    1190 <double_add_matrix+0x90>
xor    %ebx,%ebx
mov    -0x58(%rsp),%r12
testb  $0x1,-0x28(%rsp)
jne    12da <double_add_matrix+0x1da>
jmp    130c <double_add_matrix+0x20c>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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