void mat3_add(double out[3][3], double A[3][3], double B[3][3]) {
  int c, r;
  for (c = 0; c < 3; c++) {
    for (r = 0; r < 3; r++) {
      out[r][c] = A[r][c] + B[r][c];
    }
  }
}


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

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

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