void cofactor2D(double *cofDy, const double *y1, const double *y2,
                const double *yM, double x) {
  x = x / 2.0;
  cofDy[0] = x * (y2[1] - yM[1]);
  cofDy[1] = -x * (y1[1] - yM[1]);
  cofDy[2] = -x * (y2[0] - yM[0]);
  cofDy[3] = x * (y1[0] - yM[0]);
}


x86 assembly (clang, -O0):
<cofactor2D>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xeda(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x20(%rbp),%rax
subsd  0x8(%rax),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x20(%rbp),%rax
subsd  0x8(%rax),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x20(%rbp),%rax
subsd  (%rax),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x20(%rbp),%rax
subsd  (%rax),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cofactor2D>:
mulsd  0xef8(%rip),%xmm0
movsd  0x8(%rdx),%xmm1
subsd  0x8(%rcx),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rdi)
movapd 0xeee(%rip),%xmm1
xorpd  %xmm0,%xmm1
movsd  0x8(%rsi),%xmm2
subsd  0x8(%rcx),%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rdi)
movsd  (%rdx),%xmm2
subsd  (%rcx),%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%rdi)
movsd  (%rsi),%xmm1
subsd  (%rcx),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rdi)
ret

LLVM IR (-O0):
define void @cofactor2D(double* %0, double* %1, double* %2, double* %3, double %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store double %4, double* %10
%11 = load double, double* %10
%12 = fdiv double %11, 2.000000e+00
store double %12, double* %10
%13 = load double, double* %10
%14 = load double*, double** %8
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load double, double* %15
%17 = load double*, double** %9
%18 = getelementptr inbounds double, double* %17, i64 1
%19 = load double, double* %18
%20 = fsub double %16, %19
%21 = fmul double %13, %20
%22 = load double*, double** %6
%23 = getelementptr inbounds double, double* %22, i64 0
store double %21, double* %23
%24 = load double, double* %10
%25 = fneg double %24
%26 = load double*, double** %7
%27 = getelementptr inbounds double, double* %26, i64 1
%28 = load double, double* %27
%29 = load double*, double** %9
%30 = getelementptr inbounds double, double* %29, i64 1
%31 = load double, double* %30
%32 = fsub double %28, %31
%33 = fmul double %25, %32
%34 = load double*, double** %6
%35 = getelementptr inbounds double, double* %34, i64 1
store double %33, double* %35
%36 = load double, double* %10
%37 = fneg double %36
%38 = load double*, double** %8
%39 = getelementptr inbounds double, double* %38, i64 0
%40 = load double, double* %39
%41 = load double*, double** %9
%42 = getelementptr inbounds double, double* %41, i64 0
%43 = load double, double* %42
%44 = fsub double %40, %43
%45 = fmul double %37, %44
%46 = load double*, double** %6
%47 = getelementptr inbounds double, double* %46, i64 2
store double %45, double* %47
%48 = load double, double* %10
%49 = load double*, double** %7
%50 = getelementptr inbounds double, double* %49, i64 0
%51 = load double, double* %50
%52 = load double*, double** %9
%53 = getelementptr inbounds double, double* %52, i64 0
%54 = load double, double* %53
%55 = fsub double %51, %54
%56 = fmul double %48, %55
%57 = load double*, double** %6
%58 = getelementptr inbounds double, double* %57, i64 3
store double %56, double* %58
ret void
}

LLVM IR (-O2):
define void @cofactor2D(double* nocapture writeonly %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double %4) {
%6 = fmul double %4, 5.000000e-01
%7 = getelementptr inbounds double, double* %2, i64 1
%8 = load double, double* %7
%9 = getelementptr inbounds double, double* %3, i64 1
%10 = load double, double* %9
%11 = fsub double %8, %10
%12 = fmul double %6, %11
store double %12, double* %0
%13 = fneg double %6
%14 = getelementptr inbounds double, double* %1, i64 1
%15 = load double, double* %14
%16 = load double, double* %9
%17 = fsub double %15, %16
%18 = fmul double %17, %13
%19 = getelementptr inbounds double, double* %0, i64 1
store double %18, double* %19
%20 = load double, double* %2
%21 = load double, double* %3
%22 = fsub double %20, %21
%23 = fmul double %22, %13
%24 = getelementptr inbounds double, double* %0, i64 2
store double %23, double* %24
%25 = load double, double* %1
%26 = load double, double* %3
%27 = fsub double %25, %26
%28 = fmul double %6, %27
%29 = getelementptr inbounds double, double* %0, i64 3
store double %28, double* %29
ret void
}