double *cross_prod3(const double a[], const double b[], double result[]) {
  double tmp[3];
  tmp[0] = (a[1] * b[2] - a[2] * b[1]);
  tmp[1] = -(a[0] * b[2] - a[2] * b[0]);
  tmp[2] = (a[0] * b[1] - a[1] * b[0]);
  result[0] = tmp[0];
  result[1] = tmp[1];
  result[2] = tmp[2];
  return result;
}


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

x86 assembly (clang, -O2):
<cross_prod3>:
mov    %rdx,%rax
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
movsd  0x10(%rsi),%xmm2
movsd  0x10(%rdi),%xmm3
movsd  (%rsi),%xmm4
movsd  0x8(%rsi),%xmm5
movapd %xmm1,%xmm6
mulsd  %xmm2,%xmm6
mulsd  %xmm0,%xmm2
mulsd  %xmm5,%xmm0
mulsd  %xmm3,%xmm5
subsd  %xmm5,%xmm6
mulsd  %xmm4,%xmm3
subsd  %xmm3,%xmm2
xorpd  0xeb9(%rip),%xmm2
mulsd  %xmm1,%xmm4
subsd  %xmm4,%xmm0
movsd  %xmm6,(%rdx)
movlpd %xmm2,0x8(%rdx)
movsd  %xmm0,0x10(%rdx)
ret

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

LLVM IR (-O2):
define double* @cross_prod3(double* nocapture %0, double* nocapture %1, double* returned writeonly %2) {
%4 = getelementptr inbounds double, double* %0, i64 1
%5 = load double, double* %4
%6 = getelementptr inbounds double, double* %1, i64 2
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %0, i64 2
%9 = load double, double* %8
%10 = getelementptr inbounds double, double* %1, i64 1
%11 = load double, double* %10
%12 = fneg double %9
%13 = fmul double %11, %12
%14 = tail call double @llvm.fmuladd.f64(double %5, double %7, double %13)
%15 = load double, double* %0
%16 = load double, double* %1
%17 = fmul double %16, %12
%18 = tail call double @llvm.fmuladd.f64(double %15, double %7, double %17)
%19 = fneg double %18
%20 = fneg double %5
%21 = fmul double %16, %20
%22 = tail call double @llvm.fmuladd.f64(double %15, double %11, double %21)
store double %14, double* %2
%23 = getelementptr inbounds double, double* %2, i64 1
store double %19, double* %23
%24 = getelementptr inbounds double, double* %2, i64 2
store double %22, double* %24
ret double* %2
}