void inverse_3x3(double **a, double **out) {
  int i, j;
  double det = 0.0;
  for (i = 0; i < 3; i++) {
    det = det + (a[0][i] * (a[1][(i + 1) % 3] * a[2][(i + 2) % 3] -
                            a[1][(i + 2) % 3] * a[2][(i + 1) % 3]));
  }
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++)
      out[j][i] = (a[(i + 1) % 3][(j + 1) % 3] * a[(i + 2) % 3][(j + 2) % 3] -
                   a[(i + 1) % 3][(j + 2) % 3] * a[(i + 2) % 3][(j + 1) % 3]) /
                  det;
  }
}


x86 assembly (clang, -O0):
<inverse_3x3>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    120c <inverse_3x3+0x10c>
movsd  -0x20(%rbp),%xmm1
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x40(%rbp),%rax
movslq %edx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x38(%rbp),%rax
movslq %edx,%rcx
movsd  (%rax,%rcx,8),%xmm4
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x30(%rbp),%rax
movslq %edx,%rcx
movsd  (%rax,%rcx,8),%xmm3
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%rax
movslq %edx,%rcx
mulsd  (%rax,%rcx,8),%xmm3
movq   %xmm3,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    111b <inverse_3x3+0x1b>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1384 <inverse_3x3+0x284>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    1371 <inverse_3x3+0x271>
mov    -0x8(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x80(%rbp),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x78(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x78(%rbp),%rax
movslq %edx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x70(%rbp),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x68(%rbp),%rax
movslq %edx,%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x60(%rbp),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x58(%rbp),%rax
movslq %edx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x8(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x50(%rbp),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x48(%rbp),%rax
movslq %edx,%rcx
mulsd  (%rax,%rcx,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1224 <inverse_3x3+0x124>
jmp    1376 <inverse_3x3+0x276>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1213 <inverse_3x3+0x113>
pop    %rbp
ret

x86 assembly (clang, -O2):
<inverse_3x3>:
mov    (%rdi),%rcx
mov    0x8(%rdi),%rax
mov    0x10(%rdi),%rdx
movsd  (%rax),%xmm0
movsd  0x8(%rax),%xmm2
movsd  0x10(%rdx),%xmm5
movsd  0x10(%rax),%xmm1
movsd  (%rdx),%xmm4
movsd  0x8(%rdx),%xmm6
movapd %xmm2,%xmm3
mulsd  %xmm5,%xmm3
mulsd  %xmm0,%xmm5
mulsd  %xmm6,%xmm0
mulsd  %xmm1,%xmm6
subsd  %xmm6,%xmm3
movsd  (%rcx),%xmm6
mulsd  %xmm3,%xmm6
xorpd  %xmm7,%xmm7
addsd  %xmm6,%xmm7
mulsd  %xmm4,%xmm1
subsd  %xmm5,%xmm1
mulsd  0x8(%rcx),%xmm1
addsd  %xmm7,%xmm1
mulsd  %xmm2,%xmm4
subsd  %xmm4,%xmm0
mulsd  0x10(%rcx),%xmm0
addsd  %xmm1,%xmm0
divsd  %xmm0,%xmm3
mov    (%rsi),%rdi
movsd  %xmm3,(%rdi)
movsd  0x10(%rax),%xmm1
movsd  0x10(%rdx),%xmm2
mulsd  (%rax),%xmm2
mulsd  (%rdx),%xmm1
subsd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
mov    0x8(%rsi),%r8
movsd  %xmm1,(%r8)
movsd  (%rax),%xmm1
movsd  (%rdx),%xmm2
mulsd  0x8(%rax),%xmm2
mulsd  0x8(%rdx),%xmm1
subsd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
mov    0x10(%rsi),%rsi
movsd  %xmm1,(%rsi)
movsd  0x8(%rdx),%xmm1
movsd  0x8(%rcx),%xmm2
mulsd  0x10(%rdx),%xmm2
mulsd  0x10(%rcx),%xmm1
subsd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rdi)
movsd  0x10(%rcx),%xmm1
mulsd  (%rdx),%xmm1
movsd  0x10(%rdx),%xmm2
mulsd  (%rcx),%xmm2
subsd  %xmm1,%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%r8)
movsd  (%rdx),%xmm1
movsd  (%rcx),%xmm2
mulsd  0x8(%rdx),%xmm2
mulsd  0x8(%rcx),%xmm1
subsd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsi)
movsd  0x8(%rcx),%xmm1
movsd  0x8(%rax),%xmm2
mulsd  0x10(%rcx),%xmm2
mulsd  0x10(%rax),%xmm1
subsd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rdi)
movsd  0x10(%rax),%xmm1
mulsd  (%rcx),%xmm1
movsd  0x10(%rcx),%xmm2
mulsd  (%rax),%xmm2
subsd  %xmm1,%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x10(%r8)
movsd  (%rcx),%xmm1
movsd  (%rax),%xmm2
mulsd  0x8(%rcx),%xmm2
mulsd  0x8(%rax),%xmm1
subsd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsi)
ret

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

LLVM IR (-O2):
define void @inverse_3x3(double** nocapture %0, double** nocapture %1) {
%3 = load double*, double** %0
%4 = getelementptr inbounds double*, double** %0, i64 1
%5 = load double*, double** %4
%6 = getelementptr inbounds double*, double** %0, i64 2
%7 = load double*, double** %6
%8 = load double, double* %3
%9 = getelementptr inbounds double, double* %5, i64 1
%10 = load double, double* %9
%11 = getelementptr inbounds double, double* %7, i64 2
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %5, i64 2
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %7, i64 1
%16 = load double, double* %15
%17 = fneg double %14
%18 = fmul double %16, %17
%19 = tail call double @llvm.fmuladd.f64(double %10, double %12, double %18)
%20 = tail call double @llvm.fmuladd.f64(double %8, double %19, double 0.000000e+00)
%21 = getelementptr inbounds double, double* %3, i64 1
%22 = load double, double* %21
%23 = load double, double* %7
%24 = load double, double* %5
%25 = fneg double %24
%26 = fmul double %12, %25
%27 = tail call double @llvm.fmuladd.f64(double %14, double %23, double %26)
%28 = tail call double @llvm.fmuladd.f64(double %22, double %27, double %20)
%29 = getelementptr inbounds double, double* %3, i64 2
%30 = load double, double* %29
%31 = fneg double %10
%32 = fmul double %23, %31
%33 = tail call double @llvm.fmuladd.f64(double %24, double %16, double %32)
%34 = tail call double @llvm.fmuladd.f64(double %30, double %33, double %28)
%35 = fdiv double %19, %34
%36 = load double*, double** %1
store double %35, double* %36
%37 = load double, double* %13
%38 = load double, double* %7
%39 = load double, double* %5
%40 = load double, double* %11
%41 = fneg double %39
%42 = fmul double %40, %41
%43 = tail call double @llvm.fmuladd.f64(double %37, double %38, double %42)
%44 = fdiv double %43, %34
%45 = getelementptr inbounds double*, double** %1, i64 1
%46 = load double*, double** %45
store double %44, double* %46
%47 = load double, double* %5
%48 = load double, double* %15
%49 = load double, double* %9
%50 = load double, double* %7
%51 = fneg double %49
%52 = fmul double %50, %51
%53 = tail call double @llvm.fmuladd.f64(double %47, double %48, double %52)
%54 = fdiv double %53, %34
%55 = getelementptr inbounds double*, double** %1, i64 2
%56 = load double*, double** %55
store double %54, double* %56
%57 = load double, double* %15
%58 = load double, double* %29
%59 = load double, double* %11
%60 = load double, double* %21
%61 = fneg double %59
%62 = fmul double %60, %61
%63 = tail call double @llvm.fmuladd.f64(double %57, double %58, double %62)
%64 = fdiv double %63, %34
%65 = getelementptr inbounds double, double* %36, i64 1
store double %64, double* %65
%66 = load double, double* %11
%67 = load double, double* %3
%68 = load double, double* %7
%69 = load double, double* %29
%70 = fneg double %68
%71 = fmul double %69, %70
%72 = tail call double @llvm.fmuladd.f64(double %66, double %67, double %71)
%73 = fdiv double %72, %34
%74 = getelementptr inbounds double, double* %46, i64 1
store double %73, double* %74
%75 = load double, double* %7
%76 = load double, double* %21
%77 = load double, double* %15
%78 = load double, double* %3
%79 = fneg double %77
%80 = fmul double %78, %79
%81 = tail call double @llvm.fmuladd.f64(double %75, double %76, double %80)
%82 = fdiv double %81, %34
%83 = getelementptr inbounds double, double* %56, i64 1
store double %82, double* %83
%84 = load double, double* %21
%85 = load double, double* %13
%86 = load double, double* %29
%87 = load double, double* %9
%88 = fneg double %86
%89 = fmul double %87, %88
%90 = tail call double @llvm.fmuladd.f64(double %84, double %85, double %89)
%91 = fdiv double %90, %34
%92 = getelementptr inbounds double, double* %36, i64 2
store double %91, double* %92
%93 = load double, double* %29
%94 = load double, double* %5
%95 = load double, double* %3
%96 = load double, double* %13
%97 = fneg double %95
%98 = fmul double %96, %97
%99 = tail call double @llvm.fmuladd.f64(double %93, double %94, double %98)
%100 = fdiv double %99, %34
%101 = getelementptr inbounds double, double* %46, i64 2
store double %100, double* %101
%102 = load double, double* %3
%103 = load double, double* %9
%104 = load double, double* %21
%105 = load double, double* %5
%106 = fneg double %104
%107 = fmul double %105, %106
%108 = tail call double @llvm.fmuladd.f64(double %102, double %103, double %107)
%109 = fdiv double %108, %34
%110 = getelementptr inbounds double, double* %56, i64 2
store double %109, double* %110
ret void
}