void matrix_add3(double a[3][3], double b[3][3], double m[3][3]) {
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      m[i][j] = a[i][j] + b[i][j];
    }
  }
}


x86 assembly (clang, -O0):
<matrix_add3>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    119b <matrix_add3+0x9b>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    1188 <matrix_add3+0x88>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x18,%rcx,%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    1128 <matrix_add3+0x28>
jmp    118d <matrix_add3+0x8d>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1117 <matrix_add3+0x17>
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix_add3>:
movsd  (%rdi),%xmm0
addsd  (%rsi),%xmm0
movsd  %xmm0,(%rdx)
movsd  0x8(%rdi),%xmm0
addsd  0x8(%rsi),%xmm0
movsd  %xmm0,0x8(%rdx)
movsd  0x10(%rdi),%xmm0
addsd  0x10(%rsi),%xmm0
movsd  %xmm0,0x10(%rdx)
movsd  0x18(%rdi),%xmm0
addsd  0x18(%rsi),%xmm0
movsd  %xmm0,0x18(%rdx)
movsd  0x20(%rdi),%xmm0
addsd  0x20(%rsi),%xmm0
movsd  %xmm0,0x20(%rdx)
movsd  0x28(%rdi),%xmm0
addsd  0x28(%rsi),%xmm0
movsd  %xmm0,0x28(%rdx)
movsd  0x30(%rdi),%xmm0
addsd  0x30(%rsi),%xmm0
movsd  %xmm0,0x30(%rdx)
movsd  0x38(%rdi),%xmm0
addsd  0x38(%rsi),%xmm0
movsd  %xmm0,0x38(%rdx)
movsd  0x40(%rdi),%xmm0
addsd  0x40(%rsi),%xmm0
movsd  %xmm0,0x40(%rdx)
ret

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

LLVM IR (-O2):
define void @matrix_add3([3 x double]* nocapture %0, [3 x double]* nocapture %1, [3 x double]* nocapture writeonly %2) {
%4 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0
%5 = load double, double* %4
%6 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%7 = load double, double* %6
%8 = fadd double %5, %7
%9 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
store double %8, double* %9
%10 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 1
%11 = load double, double* %10
%12 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 1
%13 = load double, double* %12
%14 = fadd double %11, %13
%15 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
store double %14, double* %15
%16 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2
%17 = load double, double* %16
%18 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 2
%19 = load double, double* %18
%20 = fadd double %17, %19
%21 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 2
store double %20, double* %21
%22 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 0
%23 = load double, double* %22
%24 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 0
%25 = load double, double* %24
%26 = fadd double %23, %25
%27 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 1, i64 0
store double %26, double* %27
%28 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 1
%29 = load double, double* %28
%30 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 1
%31 = load double, double* %30
%32 = fadd double %29, %31
%33 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 1, i64 1
store double %32, double* %33
%34 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 2
%35 = load double, double* %34
%36 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 2
%37 = load double, double* %36
%38 = fadd double %35, %37
%39 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 1, i64 2
store double %38, double* %39
%40 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 0
%41 = load double, double* %40
%42 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 0
%43 = load double, double* %42
%44 = fadd double %41, %43
%45 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 2, i64 0
store double %44, double* %45
%46 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 1
%47 = load double, double* %46
%48 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 1
%49 = load double, double* %48
%50 = fadd double %47, %49
%51 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 2, i64 1
store double %50, double* %51
%52 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
%53 = load double, double* %52
%54 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 2
%55 = load double, double* %54
%56 = fadd double %53, %55
%57 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 2, i64 2
store double %56, double* %57
ret void
}