void add_mat2D_double(double **mat2D_double_sum, double **mat2D_double_A,
                      double **mat2D_double_B, int x, int y) {
  unsigned int i, j;
  for (i = 0; i < x; ++i)
    for (j = 0; j < y; ++j)
      mat2D_double_sum[i][j] = mat2D_double_A[i][j] + mat2D_double_B[i][j];
}


x86 assembly (clang, -O0):
<add_mat2D_double>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    1197 <add_mat2D_double+0x97>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jae    1184 <add_mat2D_double+0x84>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x28(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x28(%rbp),%ecx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    -0x28(%rbp),%ecx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1131 <add_mat2D_double+0x31>
jmp    1189 <add_mat2D_double+0x89>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    111e <add_mat2D_double+0x1e>
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_mat2D_double>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %ecx,%ecx
je     1372 <add_mat2D_double+0x272>
mov    %ecx,%r10d
mov    %r8d,%r14d
mov    %r14d,%eax
and    $0xfffffffc,%eax
mov    %rax,-0x8(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x10(%rsp)
mov    %rax,%rcx
shr    $0x2,%rcx
add    $0x1,%rcx
mov    %rcx,%rax
mov    %rcx,-0x18(%rsp)
and    $0xfffffffffffffffe,%rcx
mov    %rcx,-0x20(%rsp)
mov    %r14d,%r11d
and    $0x3,%r11d
xor    %r13d,%r13d
mov    %r8d,-0x24(%rsp)
jmp    116d <add_mat2D_double+0x6d>
nopl   0x0(%rax)
add    $0x1,%r13
cmp    %r10,%r13
je     1372 <add_mat2D_double+0x272>
test   %r8d,%r8d
je     1160 <add_mat2D_double+0x60>
mov    (%rsi,%r13,8),%rbx
mov    (%rdx,%r13,8),%rax
mov    (%rdi,%r13,8),%rbp
cmp    $0x4,%r8d
jae    1190 <add_mat2D_double+0x90>
xor    %r9d,%r9d
jmp    12b0 <add_mat2D_double+0x1b0>
nopl   0x0(%rax)
mov    %r10,%r8
lea    0x0(,%r14,8),%rcx
add    %rbp,%rcx
lea    (%rbx,%r14,8),%r9
lea    (%rax,%r14,8),%r10
cmp    %r9,%rbp
setb   %r9b
cmp    %rcx,%rbx
setb   %r15b
cmp    %r10,%rbp
setb   %r10b
cmp    %rcx,%rax
setb   %r12b
test   %r15b,%r9b
jne    12a4 <add_mat2D_double+0x1a4>
mov    $0x0,%r9d
and    %r12b,%r10b
mov    %r8,%r10
mov    -0x24(%rsp),%r8d
jne    12b0 <add_mat2D_double+0x1b0>
cmpq   $0x0,-0x10(%rsp)
je     1360 <add_mat2D_double+0x260>
mov    -0x20(%rsp),%r9
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
movupd (%rbx,%rcx,8),%xmm0
movupd 0x10(%rbx,%rcx,8),%xmm1
movupd (%rax,%rcx,8),%xmm2
addpd  %xmm0,%xmm2
movupd 0x10(%rax,%rcx,8),%xmm0
addpd  %xmm1,%xmm0
movupd %xmm2,0x0(%rbp,%rcx,8)
movupd %xmm0,0x10(%rbp,%rcx,8)
movupd 0x20(%rbx,%rcx,8),%xmm0
movupd 0x30(%rbx,%rcx,8),%xmm1
movupd 0x20(%rax,%rcx,8),%xmm2
addpd  %xmm0,%xmm2
movupd 0x30(%rax,%rcx,8),%xmm0
addpd  %xmm1,%xmm0
movupd %xmm2,0x20(%rbp,%rcx,8)
movupd %xmm0,0x30(%rbp,%rcx,8)
add    $0x8,%rcx
add    $0xfffffffffffffffe,%r9
jne    1200 <add_mat2D_double+0x100>
testb  $0x1,-0x18(%rsp)
je     1291 <add_mat2D_double+0x191>
movupd (%rbx,%rcx,8),%xmm0
movupd 0x10(%rbx,%rcx,8),%xmm1
movupd (%rax,%rcx,8),%xmm2
addpd  %xmm0,%xmm2
movupd 0x10(%rax,%rcx,8),%xmm0
addpd  %xmm1,%xmm0
movupd %xmm2,0x0(%rbp,%rcx,8)
movupd %xmm0,0x10(%rbp,%rcx,8)
mov    -0x8(%rsp),%rcx
mov    %rcx,%r9
cmp    %r14,%rcx
je     1160 <add_mat2D_double+0x60>
jmp    12b0 <add_mat2D_double+0x1b0>
xor    %r9d,%r9d
mov    %r8,%r10
mov    -0x24(%rsp),%r8d
nop
mov    %r9,%rcx
not    %rcx
add    %r14,%rcx
test   %r11,%r11
je     12ed <add_mat2D_double+0x1ed>
mov    %r11,%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%r9,8),%xmm0
addsd  (%rax,%r9,8),%xmm0
movsd  %xmm0,0x0(%rbp,%r9,8)
add    $0x1,%r9
add    $0xffffffffffffffff,%r12
jne    12d0 <add_mat2D_double+0x1d0>
cmp    $0x3,%rcx
jb     1160 <add_mat2D_double+0x60>
nopw   0x0(%rax,%rax,1)
movsd  (%rbx,%r9,8),%xmm0
addsd  (%rax,%r9,8),%xmm0
movsd  %xmm0,0x0(%rbp,%r9,8)
movsd  0x8(%rbx,%r9,8),%xmm0
addsd  0x8(%rax,%r9,8),%xmm0
movsd  %xmm0,0x8(%rbp,%r9,8)
movsd  0x10(%rbx,%r9,8),%xmm0
addsd  0x10(%rax,%r9,8),%xmm0
movsd  %xmm0,0x10(%rbp,%r9,8)
movsd  0x18(%rbx,%r9,8),%xmm0
addsd  0x18(%rax,%r9,8),%xmm0
movsd  %xmm0,0x18(%rbp,%r9,8)
add    $0x4,%r9
cmp    %r9,%r14
jne    1300 <add_mat2D_double+0x200>
jmp    1160 <add_mat2D_double+0x60>
xor    %ecx,%ecx
testb  $0x1,-0x18(%rsp)
jne    1267 <add_mat2D_double+0x167>
jmp    1291 <add_mat2D_double+0x191>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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