void vector_vector_outer_product_3d(const double v1[3], const double v2[3],
                                    double result[9]) {
  result[0] = v1[0] * v2[0];
  result[1] = v1[1] * v2[0];
  result[2] = v1[2] * v2[0];
  result[3] = result[1];
  result[4] = v1[1] * v2[1];
  result[5] = v1[2] * v2[1];
  result[6] = result[2];
  result[7] = result[5];
  result[8] = v1[2] * v2[2];
}


x86 assembly (clang, -O0):
<vector_vector_outer_product_3d>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x28(%rax)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x30(%rax)
mov    -0x18(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x38(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x40(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<vector_vector_outer_product_3d>:
movsd  (%rdi),%xmm0
mulsd  (%rsi),%xmm0
movsd  %xmm0,(%rdx)
movsd  0x8(%rdi),%xmm0
mulsd  (%rsi),%xmm0
movsd  %xmm0,0x8(%rdx)
movsd  0x10(%rdi),%xmm1
mulsd  (%rsi),%xmm1
movsd  %xmm1,0x10(%rdx)
movsd  %xmm0,0x18(%rdx)
movsd  0x8(%rdi),%xmm0
mulsd  0x8(%rsi),%xmm0
movsd  %xmm0,0x20(%rdx)
movsd  0x10(%rdi),%xmm0
mulsd  0x8(%rsi),%xmm0
movsd  %xmm0,0x28(%rdx)
movsd  %xmm1,0x30(%rdx)
movsd  %xmm0,0x38(%rdx)
movsd  0x10(%rdi),%xmm0
mulsd  0x10(%rsi),%xmm0
movsd  %xmm0,0x40(%rdx)
ret

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

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