void addmm(double *result, const double *s1, const double *s2) {
  int i;
  for (i = 0; i < 16; i++)
    result[i] = s1[i] + s2[i];
}


x86 assembly (clang, -O0):
<addmm>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x10,-0x1c(%rbp)
jge    1156 <addmm+0x56>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1117 <addmm+0x17>
pop    %rbp
ret

x86 assembly (clang, -O2):
<addmm>:
movsd  (%rsi),%xmm0
addsd  (%rdx),%xmm0
movsd  %xmm0,(%rdi)
movsd  0x8(%rsi),%xmm0
addsd  0x8(%rdx),%xmm0
movsd  %xmm0,0x8(%rdi)
movsd  0x10(%rsi),%xmm0
addsd  0x10(%rdx),%xmm0
movsd  %xmm0,0x10(%rdi)
movsd  0x18(%rsi),%xmm0
addsd  0x18(%rdx),%xmm0
movsd  %xmm0,0x18(%rdi)
movsd  0x20(%rsi),%xmm0
addsd  0x20(%rdx),%xmm0
movsd  %xmm0,0x20(%rdi)
movsd  0x28(%rsi),%xmm0
addsd  0x28(%rdx),%xmm0
movsd  %xmm0,0x28(%rdi)
movsd  0x30(%rsi),%xmm0
addsd  0x30(%rdx),%xmm0
movsd  %xmm0,0x30(%rdi)
movsd  0x38(%rsi),%xmm0
addsd  0x38(%rdx),%xmm0
movsd  %xmm0,0x38(%rdi)
movsd  0x40(%rsi),%xmm0
addsd  0x40(%rdx),%xmm0
movsd  %xmm0,0x40(%rdi)
movsd  0x48(%rsi),%xmm0
addsd  0x48(%rdx),%xmm0
movsd  %xmm0,0x48(%rdi)
movsd  0x50(%rsi),%xmm0
addsd  0x50(%rdx),%xmm0
movsd  %xmm0,0x50(%rdi)
movsd  0x58(%rsi),%xmm0
addsd  0x58(%rdx),%xmm0
movsd  %xmm0,0x58(%rdi)
movsd  0x60(%rsi),%xmm0
addsd  0x60(%rdx),%xmm0
movsd  %xmm0,0x60(%rdi)
movsd  0x68(%rsi),%xmm0
addsd  0x68(%rdx),%xmm0
movsd  %xmm0,0x68(%rdi)
movsd  0x70(%rsi),%xmm0
addsd  0x70(%rdx),%xmm0
movsd  %xmm0,0x70(%rdi)
movsd  0x78(%rsi),%xmm0
addsd  0x78(%rdx),%xmm0
movsd  %xmm0,0x78(%rdi)
ret

LLVM IR (-O0):
define void @addmm(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
store i32 0, i32* %7
br label %8
8: ; preds = %27, %3
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 16
br i1 %10, label %11, label %30
11: ; preds = %8
%12 = load double*, double** %5
%13 = load i32, i32* %7
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %12, i64 %14
%16 = load double, double* %15
%17 = load double*, double** %6
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
%21 = load double, double* %20
%22 = fadd double %16, %21
%23 = load double*, double** %4
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
store double %22, double* %26
br label %27
27: ; preds = %11
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %8
30: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @addmm(double* nocapture writeonly %0, double* nocapture %1, double* nocapture %2) {
%4 = load double, double* %1
%5 = load double, double* %2
%6 = fadd double %4, %5
store double %6, double* %0
%7 = getelementptr inbounds double, double* %1, i64 1
%8 = load double, double* %7
%9 = getelementptr inbounds double, double* %2, i64 1
%10 = load double, double* %9
%11 = fadd double %8, %10
%12 = getelementptr inbounds double, double* %0, i64 1
store double %11, double* %12
%13 = getelementptr inbounds double, double* %1, i64 2
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %2, i64 2
%16 = load double, double* %15
%17 = fadd double %14, %16
%18 = getelementptr inbounds double, double* %0, i64 2
store double %17, double* %18
%19 = getelementptr inbounds double, double* %1, i64 3
%20 = load double, double* %19
%21 = getelementptr inbounds double, double* %2, i64 3
%22 = load double, double* %21
%23 = fadd double %20, %22
%24 = getelementptr inbounds double, double* %0, i64 3
store double %23, double* %24
%25 = getelementptr inbounds double, double* %1, i64 4
%26 = load double, double* %25
%27 = getelementptr inbounds double, double* %2, i64 4
%28 = load double, double* %27
%29 = fadd double %26, %28
%30 = getelementptr inbounds double, double* %0, i64 4
store double %29, double* %30
%31 = getelementptr inbounds double, double* %1, i64 5
%32 = load double, double* %31
%33 = getelementptr inbounds double, double* %2, i64 5
%34 = load double, double* %33
%35 = fadd double %32, %34
%36 = getelementptr inbounds double, double* %0, i64 5
store double %35, double* %36
%37 = getelementptr inbounds double, double* %1, i64 6
%38 = load double, double* %37
%39 = getelementptr inbounds double, double* %2, i64 6
%40 = load double, double* %39
%41 = fadd double %38, %40
%42 = getelementptr inbounds double, double* %0, i64 6
store double %41, double* %42
%43 = getelementptr inbounds double, double* %1, i64 7
%44 = load double, double* %43
%45 = getelementptr inbounds double, double* %2, i64 7
%46 = load double, double* %45
%47 = fadd double %44, %46
%48 = getelementptr inbounds double, double* %0, i64 7
store double %47, double* %48
%49 = getelementptr inbounds double, double* %1, i64 8
%50 = load double, double* %49
%51 = getelementptr inbounds double, double* %2, i64 8
%52 = load double, double* %51
%53 = fadd double %50, %52
%54 = getelementptr inbounds double, double* %0, i64 8
store double %53, double* %54
%55 = getelementptr inbounds double, double* %1, i64 9
%56 = load double, double* %55
%57 = getelementptr inbounds double, double* %2, i64 9
%58 = load double, double* %57
%59 = fadd double %56, %58
%60 = getelementptr inbounds double, double* %0, i64 9
store double %59, double* %60
%61 = getelementptr inbounds double, double* %1, i64 10
%62 = load double, double* %61
%63 = getelementptr inbounds double, double* %2, i64 10
%64 = load double, double* %63
%65 = fadd double %62, %64
%66 = getelementptr inbounds double, double* %0, i64 10
store double %65, double* %66
%67 = getelementptr inbounds double, double* %1, i64 11
%68 = load double, double* %67
%69 = getelementptr inbounds double, double* %2, i64 11
%70 = load double, double* %69
%71 = fadd double %68, %70
%72 = getelementptr inbounds double, double* %0, i64 11
store double %71, double* %72
%73 = getelementptr inbounds double, double* %1, i64 12
%74 = load double, double* %73
%75 = getelementptr inbounds double, double* %2, i64 12
%76 = load double, double* %75
%77 = fadd double %74, %76
%78 = getelementptr inbounds double, double* %0, i64 12
store double %77, double* %78
%79 = getelementptr inbounds double, double* %1, i64 13
%80 = load double, double* %79
%81 = getelementptr inbounds double, double* %2, i64 13
%82 = load double, double* %81
%83 = fadd double %80, %82
%84 = getelementptr inbounds double, double* %0, i64 13
store double %83, double* %84
%85 = getelementptr inbounds double, double* %1, i64 14
%86 = load double, double* %85
%87 = getelementptr inbounds double, double* %2, i64 14
%88 = load double, double* %87
%89 = fadd double %86, %88
%90 = getelementptr inbounds double, double* %0, i64 14
store double %89, double* %90
%91 = getelementptr inbounds double, double* %1, i64 15
%92 = load double, double* %91
%93 = getelementptr inbounds double, double* %2, i64 15
%94 = load double, double* %93
%95 = fadd double %92, %94
%96 = getelementptr inbounds double, double* %0, i64 15
store double %95, double* %96
ret void
}