float *mat2_cofactor(float *result, float *m) {
  float adjugate[4];
  adjugate[0] = m[3];
  adjugate[1] = -m[1];
  adjugate[2] = -m[2];
  adjugate[3] = m[0];
  result[0] = adjugate[0];
  result[1] = adjugate[1];
  result[2] = adjugate[2];
  result[3] = adjugate[3];
  return result;
}


x86 assembly (clang, -O0):
<mat2_cofactor>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movss  0xc(%rax),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x1c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x14(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0xc(%rax)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat2_cofactor>:
mov    %rdi,%rax
movss  0xc(%rsi),%xmm0
movss  0x4(%rsi),%xmm1
movaps 0xeec(%rip),%xmm2
xorps  %xmm2,%xmm1
movss  0x8(%rsi),%xmm3
xorps  %xmm2,%xmm3
movss  (%rsi),%xmm2
movss  %xmm0,(%rdi)
movss  %xmm1,0x4(%rdi)
movss  %xmm3,0x8(%rdi)
movss  %xmm2,0xc(%rdi)
ret

LLVM IR (-O0):
define float* @mat2_cofactor(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca [4 x float]
store float* %0, float** %3
store float* %1, float** %4
%6 = load float*, float** %4
%7 = getelementptr inbounds float, float* %6, i64 3
%8 = load float, float* %7
%9 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 0
store float %8, float* %9
%10 = load float*, float** %4
%11 = getelementptr inbounds float, float* %10, i64 1
%12 = load float, float* %11
%13 = fneg float %12
%14 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 1
store float %13, float* %14
%15 = load float*, float** %4
%16 = getelementptr inbounds float, float* %15, i64 2
%17 = load float, float* %16
%18 = fneg float %17
%19 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 2
store float %18, float* %19
%20 = load float*, float** %4
%21 = getelementptr inbounds float, float* %20, i64 0
%22 = load float, float* %21
%23 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 3
store float %22, float* %23
%24 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 0
%25 = load float, float* %24
%26 = load float*, float** %3
%27 = getelementptr inbounds float, float* %26, i64 0
store float %25, float* %27
%28 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 1
%29 = load float, float* %28
%30 = load float*, float** %3
%31 = getelementptr inbounds float, float* %30, i64 1
store float %29, float* %31
%32 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 2
%33 = load float, float* %32
%34 = load float*, float** %3
%35 = getelementptr inbounds float, float* %34, i64 2
store float %33, float* %35
%36 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 3
%37 = load float, float* %36
%38 = load float*, float** %3
%39 = getelementptr inbounds float, float* %38, i64 3
store float %37, float* %39
%40 = load float*, float** %3
ret float* %40
}

LLVM IR (-O2):
define float* @mat2_cofactor(float* returned writeonly %0, float* nocapture %1) {
%3 = getelementptr inbounds float, float* %1, i64 3
%4 = load float, float* %3
%5 = getelementptr inbounds float, float* %1, i64 1
%6 = load float, float* %5
%7 = fneg float %6
%8 = getelementptr inbounds float, float* %1, i64 2
%9 = load float, float* %8
%10 = fneg float %9
%11 = load float, float* %1
store float %4, float* %0
%12 = getelementptr inbounds float, float* %0, i64 1
store float %7, float* %12
%13 = getelementptr inbounds float, float* %0, i64 2
store float %10, float* %13
%14 = getelementptr inbounds float, float* %0, i64 3
store float %11, float* %14
ret float* %0
}