double det_3d(double *mat) {
  return (mat[0] * mat[4] * mat[8] + mat[1] * mat[5] * mat[6] +
          mat[2] * mat[3] * mat[7] - mat[0] * mat[5] * mat[7] -
          mat[1] * mat[3] * mat[8] - mat[2] * mat[4] * mat[6]);
}


x86 assembly (clang, -O0):
<det_3d>:
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  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x28(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x30(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x18(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x38(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x28(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x38(%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  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x18(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x40(%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  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
pop    %rbp
ret

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

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

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