void doubles_mat44_inv(const double M[16], double out[16]) {
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      out[4 * i + j] = M[4 * j + i];
  out[4 * 0 + 3] = 0;
  out[4 * 1 + 3] = 0;
  out[4 * 2 + 3] = 0;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      out[4 * i + 3] -= out[4 * i + j] * M[4 * j + 3];
  out[4 * 3 + 0] = 0;
  out[4 * 3 + 1] = 0;
  out[4 * 3 + 2] = 0;
  out[4 * 3 + 3] = 1;
}


x86 assembly (clang, -O0):
<doubles_mat44_inv>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1179 <doubles_mat44_inv+0x79>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    1166 <doubles_mat44_inv+0x66>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
shl    $0x2,%ecx
add    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x2,%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1124 <doubles_mat44_inv+0x24>
jmp    116b <doubles_mat44_inv+0x6b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1113 <doubles_mat44_inv+0x13>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x18(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x38(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x58(%rax)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    1243 <doubles_mat44_inv+0x143>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    1230 <doubles_mat44_inv+0x130>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x2,%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
shl    $0x2,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x2,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
movq   %xmm0,%rdx
movabs $0x8000000000000000,%rsi
xor    %rsi,%rdx
movq   %rdx,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b5 <doubles_mat44_inv+0xb5>
jmp    1235 <doubles_mat44_inv+0x135>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a4 <doubles_mat44_inv+0xa4>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x60(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x68(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x70(%rax)
mov    -0x10(%rbp),%rax
movsd  0xd8d(%rip),%xmm0
movsd  %xmm0,0x78(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<doubles_mat44_inv>:
movsd  (%rdi),%xmm7
movsd  %xmm7,(%rsi)
movsd  0x20(%rdi),%xmm0
movsd  %xmm0,0x8(%rsi)
movsd  0x40(%rdi),%xmm1
movsd  %xmm1,0x10(%rsi)
movsd  0x8(%rdi),%xmm6
movsd  %xmm6,0x20(%rsi)
movsd  0x28(%rdi),%xmm5
movsd  %xmm5,0x28(%rsi)
movsd  0x48(%rdi),%xmm4
movsd  %xmm4,0x30(%rsi)
movsd  0x10(%rdi),%xmm10
movsd  %xmm10,0x40(%rsi)
movsd  0x30(%rdi),%xmm9
movsd  %xmm9,0x48(%rsi)
movsd  0x50(%rdi),%xmm8
movsd  %xmm8,0x50(%rsi)
movq   $0x0,0x18(%rsi)
movq   $0x0,0x38(%rsi)
movq   $0x0,0x58(%rsi)
mulsd  0x18(%rdi),%xmm7
xorpd  %xmm3,%xmm3
xorpd  %xmm2,%xmm2
subsd  %xmm7,%xmm2
movsd  %xmm2,0x18(%rsi)
mulsd  0x38(%rdi),%xmm0
subsd  %xmm0,%xmm2
movsd  %xmm2,0x18(%rsi)
mulsd  0x58(%rdi),%xmm1
subsd  %xmm1,%xmm2
movsd  %xmm2,0x18(%rsi)
mulsd  0x18(%rdi),%xmm6
xorpd  %xmm0,%xmm0
subsd  %xmm6,%xmm0
movsd  %xmm0,0x38(%rsi)
mulsd  0x38(%rdi),%xmm5
subsd  %xmm5,%xmm0
movsd  %xmm0,0x38(%rsi)
mulsd  0x58(%rdi),%xmm4
subsd  %xmm4,%xmm0
movsd  %xmm0,0x38(%rsi)
mulsd  0x18(%rdi),%xmm10
subsd  %xmm10,%xmm3
movsd  %xmm3,0x58(%rsi)
mulsd  0x38(%rdi),%xmm9
subsd  %xmm9,%xmm3
movsd  %xmm3,0x58(%rsi)
mulsd  0x58(%rdi),%xmm8
subsd  %xmm8,%xmm3
movsd  %xmm3,0x58(%rsi)
xorpd  %xmm0,%xmm0
movupd %xmm0,0x60(%rsi)
movq   $0x0,0x70(%rsi)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x78(%rsi)
ret

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

LLVM IR (-O2):
define void @doubles_mat44_inv(double* nocapture %0, double* nocapture %1) {
%3 = load double, double* %0
store double %3, double* %1
%4 = getelementptr inbounds double, double* %0, i64 4
%5 = load double, double* %4
%6 = getelementptr inbounds double, double* %1, i64 1
store double %5, double* %6
%7 = getelementptr inbounds double, double* %0, i64 8
%8 = load double, double* %7
%9 = getelementptr inbounds double, double* %1, i64 2
store double %8, double* %9
%10 = getelementptr inbounds double, double* %0, i64 1
%11 = load double, double* %10
%12 = getelementptr inbounds double, double* %1, i64 4
store double %11, double* %12
%13 = getelementptr inbounds double, double* %0, i64 5
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %1, i64 5
store double %14, double* %15
%16 = getelementptr inbounds double, double* %0, i64 9
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %1, i64 6
store double %17, double* %18
%19 = getelementptr inbounds double, double* %0, i64 2
%20 = load double, double* %19
%21 = getelementptr inbounds double, double* %1, i64 8
store double %20, double* %21
%22 = getelementptr inbounds double, double* %0, i64 6
%23 = load double, double* %22
%24 = getelementptr inbounds double, double* %1, i64 9
store double %23, double* %24
%25 = getelementptr inbounds double, double* %0, i64 10
%26 = load double, double* %25
%27 = getelementptr inbounds double, double* %1, i64 10
store double %26, double* %27
%28 = getelementptr inbounds double, double* %1, i64 3
store double 0.000000e+00, double* %28
%29 = getelementptr inbounds double, double* %1, i64 7
store double 0.000000e+00, double* %29
%30 = getelementptr inbounds double, double* %1, i64 11
store double 0.000000e+00, double* %30
%31 = getelementptr inbounds double, double* %0, i64 3
%32 = load double, double* %31
%33 = fneg double %3
%34 = tail call double @llvm.fmuladd.f64(double %33, double %32, double 0.000000e+00)
store double %34, double* %28
%35 = getelementptr inbounds double, double* %0, i64 7
%36 = load double, double* %35
%37 = fneg double %5
%38 = tail call double @llvm.fmuladd.f64(double %37, double %36, double %34)
store double %38, double* %28
%39 = getelementptr inbounds double, double* %0, i64 11
%40 = load double, double* %39
%41 = fneg double %8
%42 = tail call double @llvm.fmuladd.f64(double %41, double %40, double %38)
store double %42, double* %28
%43 = load double, double* %31
%44 = fneg double %11
%45 = tail call double @llvm.fmuladd.f64(double %44, double %43, double 0.000000e+00)
store double %45, double* %29
%46 = load double, double* %35
%47 = fneg double %14
%48 = tail call double @llvm.fmuladd.f64(double %47, double %46, double %45)
store double %48, double* %29
%49 = load double, double* %39
%50 = fneg double %17
%51 = tail call double @llvm.fmuladd.f64(double %50, double %49, double %48)
store double %51, double* %29
%52 = load double, double* %31
%53 = fneg double %20
%54 = tail call double @llvm.fmuladd.f64(double %53, double %52, double 0.000000e+00)
store double %54, double* %30
%55 = load double, double* %35
%56 = fneg double %23
%57 = tail call double @llvm.fmuladd.f64(double %56, double %55, double %54)
store double %57, double* %30
%58 = load double, double* %39
%59 = fneg double %26
%60 = tail call double @llvm.fmuladd.f64(double %59, double %58, double %57)
store double %60, double* %30
%61 = getelementptr inbounds double, double* %1, i64 12
%62 = getelementptr inbounds double, double* %1, i64 15
%63 = bitcast double* %61 to i8*
store double 1.000000e+00, double* %62
ret void
}