int quatMultiply(double *q1, double *q2, double *q1q2, int p) {
  double sign, epsijk;
  epsijk = (double)p;
  q1q2[0] = q1[0] * q2[0] - (q1[1] * q2[1] + q1[2] * q2[2] + q1[3] * q2[3]);
  q1q2[1] =
      q1[0] * q2[1] + q2[0] * q1[1] + epsijk * (q1[2] * q2[3] - q1[3] * q2[2]);
  q1q2[2] =
      q1[0] * q2[2] + q2[0] * q1[2] + epsijk * (q1[3] * q2[1] - q1[1] * q2[3]);
  q1q2[3] =
      q1[0] * q2[3] + q2[0] * q1[3] + epsijk * (q1[1] * q2[2] - q1[2] * q2[1]);
  return 1;
}


x86 assembly (clang, -O0):
<quatMultiply>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm3
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm4
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm1
mulsd  %xmm4,%xmm3
addsd  %xmm1,%xmm3
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm4
mulsd  %xmm4,%xmm1
addsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm4
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm3
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%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
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x10(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm4
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm3
mov    -0x10(%rbp),%rax
mulsd  0x18(%rax),%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
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x18(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm4
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm3
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%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
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x18(%rax)
mov    $0x1,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<quatMultiply>:
cvtsi2sd %ecx,%xmm0
movsd  (%rdi),%xmm1
movsd  0x10(%rdi),%xmm2
mulsd  0x10(%rsi),%xmm2
movsd  0x8(%rdi),%xmm3
mulsd  0x8(%rsi),%xmm3
addsd  %xmm2,%xmm3
movsd  0x18(%rdi),%xmm2
mulsd  0x18(%rsi),%xmm2
addsd  %xmm3,%xmm2
mulsd  (%rsi),%xmm1
subsd  %xmm2,%xmm1
movsd  %xmm1,(%rdx)
movsd  (%rsi),%xmm1
movsd  0x10(%rsi),%xmm2
mulsd  0x8(%rdi),%xmm1
movsd  (%rdi),%xmm3
movsd  0x10(%rdi),%xmm4
mulsd  0x8(%rsi),%xmm3
mulsd  0x18(%rdi),%xmm2
mulsd  0x18(%rsi),%xmm4
addsd  %xmm1,%xmm3
subsd  %xmm2,%xmm4
mulsd  %xmm0,%xmm4
addsd  %xmm3,%xmm4
movsd  %xmm4,0x8(%rdx)
movsd  (%rsi),%xmm1
mulsd  0x10(%rdi),%xmm1
movsd  0x18(%rsi),%xmm2
movsd  (%rdi),%xmm3
mulsd  0x10(%rsi),%xmm3
movsd  0x18(%rdi),%xmm4
addsd  %xmm1,%xmm3
mulsd  0x8(%rdi),%xmm2
mulsd  0x8(%rsi),%xmm4
subsd  %xmm2,%xmm4
mulsd  %xmm0,%xmm4
addsd  %xmm3,%xmm4
movsd  %xmm4,0x10(%rdx)
movsd  (%rsi),%xmm1
movsd  0x8(%rsi),%xmm2
mulsd  0x18(%rdi),%xmm1
movsd  (%rdi),%xmm3
movsd  0x8(%rdi),%xmm4
mulsd  0x18(%rsi),%xmm3
mulsd  0x10(%rdi),%xmm2
addsd  %xmm1,%xmm3
mulsd  0x10(%rsi),%xmm4
subsd  %xmm2,%xmm4
mulsd  %xmm0,%xmm4
addsd  %xmm3,%xmm4
movsd  %xmm4,0x18(%rdx)
mov    $0x1,%eax
ret

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

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