double mat3_det(double M[3][3]) {
  return M[0][0] * M[1][1] * M[2][2] + M[1][0] * M[2][1] * M[0][2] +
         M[2][0] * M[0][1] * M[1][2] - M[0][2] * M[1][1] * M[2][0] -
         M[0][0] * M[2][1] * M[1][2] - M[1][0] * M[0][1] * M[2][2];
}


x86 assembly (clang, -O0):
<mat3_det>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x20(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x40(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x38(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x10(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  0x30(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x28(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x20(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x30(%rax),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x38(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x28(%rax),%xmm2
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x40(%rax),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat3_det>:
movsd  0x20(%rdi),%xmm2
movsd  (%rdi),%xmm4
movsd  0x8(%rdi),%xmm1
movsd  0x18(%rdi),%xmm5
movsd  0x38(%rdi),%xmm3
movsd  0x30(%rdi),%xmm8
movapd %xmm8,%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm5,%xmm1
mulsd  %xmm3,%xmm5
mulsd  %xmm4,%xmm3
mulsd  %xmm2,%xmm4
movsd  0x40(%rdi),%xmm7
movsd  0x10(%rdi),%xmm6
mulsd  %xmm6,%xmm5
mulsd  %xmm7,%xmm4
addsd  %xmm5,%xmm4
movsd  0x28(%rdi),%xmm5
mulsd  %xmm5,%xmm0
addsd  %xmm4,%xmm0
mulsd  %xmm6,%xmm2
mulsd  %xmm8,%xmm2
subsd  %xmm2,%xmm0
mulsd  %xmm5,%xmm3
subsd  %xmm3,%xmm0
mulsd  %xmm7,%xmm1
subsd  %xmm1,%xmm0
ret

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

LLVM IR (-O2):
define double @mat3_det([3 x double]* nocapture %0) {
%2 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0
%3 = load double, double* %2
%4 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 1
%5 = load double, double* %4
%6 = fmul double %3, %5
%7 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
%8 = load double, double* %7
%9 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 0
%10 = load double, double* %9
%11 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 1
%12 = load double, double* %11
%13 = fmul double %10, %12
%14 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2
%15 = load double, double* %14
%16 = fmul double %13, %15
%17 = tail call double @llvm.fmuladd.f64(double %6, double %8, double %16)
%18 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 0
%19 = load double, double* %18
%20 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 1
%21 = load double, double* %20
%22 = fmul double %19, %21
%23 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 2
%24 = load double, double* %23
%25 = tail call double @llvm.fmuladd.f64(double %22, double %24, double %17)
%26 = fneg double %15
%27 = fmul double %5, %26
%28 = tail call double @llvm.fmuladd.f64(double %27, double %19, double %25)
%29 = fneg double %3
%30 = fmul double %12, %29
%31 = tail call double @llvm.fmuladd.f64(double %30, double %24, double %28)
%32 = fneg double %10
%33 = fmul double %21, %32
%34 = tail call double @llvm.fmuladd.f64(double %33, double %8, double %31)
ret double %34
}