void matrix_mult(double vector[4], double matrix[4][4], double result[4]) {
  result[0] = matrix[0][0] * vector[0] + matrix[0][1] * vector[1] +
              matrix[0][2] * vector[2] + matrix[0][3] * vector[3];
  result[1] = matrix[1][0] * vector[0] + matrix[1][1] * vector[1] +
              matrix[1][2] * vector[2] + matrix[1][3] * vector[3];
  result[2] = matrix[2][0] * vector[0] + matrix[2][1] * vector[1] +
              matrix[2][2] * vector[2] + matrix[2][3] * vector[3];
  result[3] = matrix[3][0] * vector[0] + matrix[3][1] * vector[1] +
              matrix[3][2] * vector[2] + matrix[3][3] * vector[3];
}


x86 assembly (clang, -O0):
<matrix_mult>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x30(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x38(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x40(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x48(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x50(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x58(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
movsd  0x60(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x68(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x70(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x78(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x18(%rax)
pop    %rbp
ret

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

LLVM IR (-O0):
define void @matrix_mult(double* %0, [4 x double]* %1, double* %2) {
%4 = alloca double*
%5 = alloca [4 x double]*
%6 = alloca double*
store double* %0, double** %4
store [4 x double]* %1, [4 x double]** %5
store double* %2, double** %6
%7 = load [4 x double]*, [4 x double]** %5
%8 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0
%9 = getelementptr inbounds [4 x double], [4 x double]* %8, i64 0, i64 0
%10 = load double, double* %9
%11 = load double*, double** %4
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
%14 = load [4 x double]*, [4 x double]** %5
%15 = getelementptr inbounds [4 x double], [4 x double]* %14, i64 0
%16 = getelementptr inbounds [4 x double], [4 x double]* %15, i64 0, i64 1
%17 = load double, double* %16
%18 = load double*, double** %4
%19 = getelementptr inbounds double, double* %18, i64 1
%20 = load double, double* %19
%21 = fmul double %17, %20
%22 = call double @llvm.fmuladd.f64(double %10, double %13, double %21)
%23 = load [4 x double]*, [4 x double]** %5
%24 = getelementptr inbounds [4 x double], [4 x double]* %23, i64 0
%25 = getelementptr inbounds [4 x double], [4 x double]* %24, i64 0, i64 2
%26 = load double, double* %25
%27 = load double*, double** %4
%28 = getelementptr inbounds double, double* %27, i64 2
%29 = load double, double* %28
%30 = call double @llvm.fmuladd.f64(double %26, double %29, double %22)
%31 = load [4 x double]*, [4 x double]** %5
%32 = getelementptr inbounds [4 x double], [4 x double]* %31, i64 0
%33 = getelementptr inbounds [4 x double], [4 x double]* %32, i64 0, i64 3
%34 = load double, double* %33
%35 = load double*, double** %4
%36 = getelementptr inbounds double, double* %35, i64 3
%37 = load double, double* %36
%38 = call double @llvm.fmuladd.f64(double %34, double %37, double %30)
%39 = load double*, double** %6
%40 = getelementptr inbounds double, double* %39, i64 0
store double %38, double* %40
%41 = load [4 x double]*, [4 x double]** %5
%42 = getelementptr inbounds [4 x double], [4 x double]* %41, i64 1
%43 = getelementptr inbounds [4 x double], [4 x double]* %42, i64 0, i64 0
%44 = load double, double* %43
%45 = load double*, double** %4
%46 = getelementptr inbounds double, double* %45, i64 0
%47 = load double, double* %46
%48 = load [4 x double]*, [4 x double]** %5
%49 = getelementptr inbounds [4 x double], [4 x double]* %48, i64 1
%50 = getelementptr inbounds [4 x double], [4 x double]* %49, i64 0, i64 1
%51 = load double, double* %50
%52 = load double*, double** %4
%53 = getelementptr inbounds double, double* %52, i64 1
%54 = load double, double* %53
%55 = fmul double %51, %54
%56 = call double @llvm.fmuladd.f64(double %44, double %47, double %55)
%57 = load [4 x double]*, [4 x double]** %5
%58 = getelementptr inbounds [4 x double], [4 x double]* %57, i64 1
%59 = getelementptr inbounds [4 x double], [4 x double]* %58, i64 0, i64 2
%60 = load double, double* %59
%61 = load double*, double** %4
%62 = getelementptr inbounds double, double* %61, i64 2
%63 = load double, double* %62
%64 = call double @llvm.fmuladd.f64(double %60, double %63, double %56)
%65 = load [4 x double]*, [4 x double]** %5
%66 = getelementptr inbounds [4 x double], [4 x double]* %65, i64 1
%67 = getelementptr inbounds [4 x double], [4 x double]* %66, i64 0, i64 3
%68 = load double, double* %67
%69 = load double*, double** %4
%70 = getelementptr inbounds double, double* %69, i64 3
%71 = load double, double* %70
%72 = call double @llvm.fmuladd.f64(double %68, double %71, double %64)
%73 = load double*, double** %6
%74 = getelementptr inbounds double, double* %73, i64 1
store double %72, double* %74
%75 = load [4 x double]*, [4 x double]** %5
%76 = getelementptr inbounds [4 x double], [4 x double]* %75, i64 2
%77 = getelementptr inbounds [4 x double], [4 x double]* %76, i64 0, i64 0
%78 = load double, double* %77
%79 = load double*, double** %4
%80 = getelementptr inbounds double, double* %79, i64 0
%81 = load double, double* %80
%82 = load [4 x double]*, [4 x double]** %5
%83 = getelementptr inbounds [4 x double], [4 x double]* %82, i64 2
%84 = getelementptr inbounds [4 x double], [4 x double]* %83, i64 0, i64 1
%85 = load double, double* %84
%86 = load double*, double** %4
%87 = getelementptr inbounds double, double* %86, i64 1
%88 = load double, double* %87
%89 = fmul double %85, %88
%90 = call double @llvm.fmuladd.f64(double %78, double %81, double %89)
%91 = load [4 x double]*, [4 x double]** %5
%92 = getelementptr inbounds [4 x double], [4 x double]* %91, i64 2
%93 = getelementptr inbounds [4 x double], [4 x double]* %92, i64 0, i64 2
%94 = load double, double* %93
%95 = load double*, double** %4
%96 = getelementptr inbounds double, double* %95, i64 2
%97 = load double, double* %96
%98 = call double @llvm.fmuladd.f64(double %94, double %97, double %90)
%99 = load [4 x double]*, [4 x double]** %5
%100 = getelementptr inbounds [4 x double], [4 x double]* %99, i64 2
%101 = getelementptr inbounds [4 x double], [4 x double]* %100, i64 0, i64 3
%102 = load double, double* %101
%103 = load double*, double** %4
%104 = getelementptr inbounds double, double* %103, i64 3
%105 = load double, double* %104
%106 = call double @llvm.fmuladd.f64(double %102, double %105, double %98)
%107 = load double*, double** %6
%108 = getelementptr inbounds double, double* %107, i64 2
store double %106, double* %108
%109 = load [4 x double]*, [4 x double]** %5
%110 = getelementptr inbounds [4 x double], [4 x double]* %109, i64 3
%111 = getelementptr inbounds [4 x double], [4 x double]* %110, i64 0, i64 0
%112 = load double, double* %111
%113 = load double*, double** %4
%114 = getelementptr inbounds double, double* %113, i64 0
%115 = load double, double* %114
%116 = load [4 x double]*, [4 x double]** %5
%117 = getelementptr inbounds [4 x double], [4 x double]* %116, i64 3
%118 = getelementptr inbounds [4 x double], [4 x double]* %117, i64 0, i64 1
%119 = load double, double* %118
%120 = load double*, double** %4
%121 = getelementptr inbounds double, double* %120, i64 1
%122 = load double, double* %121
%123 = fmul double %119, %122
%124 = call double @llvm.fmuladd.f64(double %112, double %115, double %123)
%125 = load [4 x double]*, [4 x double]** %5
%126 = getelementptr inbounds [4 x double], [4 x double]* %125, i64 3
%127 = getelementptr inbounds [4 x double], [4 x double]* %126, i64 0, i64 2
%128 = load double, double* %127
%129 = load double*, double** %4
%130 = getelementptr inbounds double, double* %129, i64 2
%131 = load double, double* %130
%132 = call double @llvm.fmuladd.f64(double %128, double %131, double %124)
%133 = load [4 x double]*, [4 x double]** %5
%134 = getelementptr inbounds [4 x double], [4 x double]* %133, i64 3
%135 = getelementptr inbounds [4 x double], [4 x double]* %134, i64 0, i64 3
%136 = load double, double* %135
%137 = load double*, double** %4
%138 = getelementptr inbounds double, double* %137, i64 3
%139 = load double, double* %138
%140 = call double @llvm.fmuladd.f64(double %136, double %139, double %132)
%141 = load double*, double** %6
%142 = getelementptr inbounds double, double* %141, i64 3
store double %140, double* %142
ret void
}

LLVM IR (-O2):
define void @matrix_mult(double* nocapture %0, [4 x double]* nocapture %1, double* nocapture writeonly %2) {
%4 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 0
%5 = load double, double* %4
%6 = load double, double* %0
%7 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 1
%8 = load double, double* %7
%9 = getelementptr inbounds double, double* %0, i64 1
%10 = load double, double* %9
%11 = fmul double %8, %10
%12 = tail call double @llvm.fmuladd.f64(double %5, double %6, double %11)
%13 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 2
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %0, i64 2
%16 = load double, double* %15
%17 = tail call double @llvm.fmuladd.f64(double %14, double %16, double %12)
%18 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 0, i64 3
%19 = load double, double* %18
%20 = getelementptr inbounds double, double* %0, i64 3
%21 = load double, double* %20
%22 = tail call double @llvm.fmuladd.f64(double %19, double %21, double %17)
store double %22, double* %2
%23 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 1, i64 0
%24 = load double, double* %23
%25 = load double, double* %0
%26 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 1, i64 1
%27 = load double, double* %26
%28 = load double, double* %9
%29 = fmul double %27, %28
%30 = tail call double @llvm.fmuladd.f64(double %24, double %25, double %29)
%31 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 1, i64 2
%32 = load double, double* %31
%33 = load double, double* %15
%34 = tail call double @llvm.fmuladd.f64(double %32, double %33, double %30)
%35 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 1, i64 3
%36 = load double, double* %35
%37 = load double, double* %20
%38 = tail call double @llvm.fmuladd.f64(double %36, double %37, double %34)
%39 = getelementptr inbounds double, double* %2, i64 1
store double %38, double* %39
%40 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 2, i64 0
%41 = load double, double* %40
%42 = load double, double* %0
%43 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 2, i64 1
%44 = load double, double* %43
%45 = load double, double* %9
%46 = fmul double %44, %45
%47 = tail call double @llvm.fmuladd.f64(double %41, double %42, double %46)
%48 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 2, i64 2
%49 = load double, double* %48
%50 = load double, double* %15
%51 = tail call double @llvm.fmuladd.f64(double %49, double %50, double %47)
%52 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 2, i64 3
%53 = load double, double* %52
%54 = load double, double* %20
%55 = tail call double @llvm.fmuladd.f64(double %53, double %54, double %51)
%56 = getelementptr inbounds double, double* %2, i64 2
store double %55, double* %56
%57 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 3, i64 0
%58 = load double, double* %57
%59 = load double, double* %0
%60 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 3, i64 1
%61 = load double, double* %60
%62 = load double, double* %9
%63 = fmul double %61, %62
%64 = tail call double @llvm.fmuladd.f64(double %58, double %59, double %63)
%65 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 3, i64 2
%66 = load double, double* %65
%67 = load double, double* %15
%68 = tail call double @llvm.fmuladd.f64(double %66, double %67, double %64)
%69 = getelementptr inbounds [4 x double], [4 x double]* %1, i64 3, i64 3
%70 = load double, double* %69
%71 = load double, double* %20
%72 = tail call double @llvm.fmuladd.f64(double %70, double %71, double %68)
%73 = getelementptr inbounds double, double* %2, i64 3
store double %72, double* %73
ret void
}