#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ lib3ds_quat_copy(float *, float *);
void lib3ds_quat_mul(float c[4], float a[4], float b[4]) {
  float qa[4], qb[4];
  lib3ds_quat_copy(qa, a);
  lib3ds_quat_copy(qb, b);
  c[0] = qa[3] * qb[0] + qa[0] * qb[3] + qa[1] * qb[2] - qa[2] * qb[1];
  c[1] = qa[3] * qb[1] + qa[1] * qb[3] + qa[2] * qb[0] - qa[0] * qb[2];
  c[2] = qa[3] * qb[2] + qa[2] * qb[3] + qa[0] * qb[1] - qa[1] * qb[0];
  c[3] = qa[3] * qb[3] - qa[0] * qb[0] - qa[1] * qb[1] - qa[2] * qb[2];
}


x86 assembly (clang, -O0):
<lib3ds_quat_mul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <lib3ds_quat_copy@plt>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <lib3ds_quat_copy@plt>
movss  -0x24(%rbp),%xmm0
movss  -0x40(%rbp),%xmm2
movss  -0x30(%rbp),%xmm1
mulss  -0x34(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x2c(%rbp),%xmm1
movss  -0x38(%rbp),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x28(%rbp),%xmm0
movss  -0x3c(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x24(%rbp),%xmm0
movss  -0x3c(%rbp),%xmm2
movss  -0x2c(%rbp),%xmm1
mulss  -0x34(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x28(%rbp),%xmm1
movss  -0x40(%rbp),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x30(%rbp),%xmm0
movss  -0x38(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x24(%rbp),%xmm0
movss  -0x38(%rbp),%xmm2
movss  -0x28(%rbp),%xmm1
mulss  -0x34(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x30(%rbp),%xmm1
movss  -0x3c(%rbp),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
movss  -0x40(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x24(%rbp),%xmm0
movss  -0x34(%rbp),%xmm2
movss  -0x30(%rbp),%xmm1
mulss  -0x40(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x2c(%rbp),%xmm1
movss  -0x3c(%rbp),%xmm2
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x28(%rbp),%xmm0
movss  -0x38(%rbp),%xmm2
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0xc(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lib3ds_quat_mul>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%rbx
mov    %rdi,%r14
mov    %rsp,%rdi
call   1030 <lib3ds_quat_copy@plt>
lea    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <lib3ds_quat_copy@plt>
movaps (%rsp),%xmm1
movsd  0x4(%rsp),%xmm2
movaps 0x10(%rsp),%xmm0
movaps 0xeb8(%rip),%xmm4
movss  (%rsp),%xmm5
movaps %xmm5,%xmm3
xorps  %xmm4,%xmm3
xorps  %xmm2,%xmm4
movaps %xmm0,%xmm6
unpcklps %xmm5,%xmm6
movaps %xmm0,%xmm7
shufps $0x3,%xmm3,%xmm7
shufps $0xf1,%xmm0,%xmm6
shufps $0x78,%xmm6,%xmm6
shufps $0x48,%xmm2,%xmm7
shufps $0x78,%xmm7,%xmm7
mulps  %xmm6,%xmm7
shufps $0xff,%xmm1,%xmm1
mulps  %xmm0,%xmm1
addps  %xmm7,%xmm1
shufps $0xd4,%xmm4,%xmm3
shufps $0x42,%xmm4,%xmm3
movlhps %xmm5,%xmm4
shufps $0x24,%xmm4,%xmm2
movaps %xmm0,%xmm4
shufps $0x52,%xmm0,%xmm4
mulps  %xmm2,%xmm4
addps  %xmm1,%xmm4
shufps $0x89,%xmm0,%xmm0
mulps  %xmm3,%xmm0
addps  %xmm4,%xmm0
movups %xmm0,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @lib3ds_quat_mul(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca [4 x float]
%8 = alloca [4 x float]
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%9 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%10 = load float*, float** %5
%11 = call i32 @lib3ds_quat_copy(float* %9, float* %10)
%12 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%13 = load float*, float** %6
%14 = call i32 @lib3ds_quat_copy(float* %12, float* %13)
%15 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 3
%16 = load float, float* %15
%17 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%18 = load float, float* %17
%19 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%20 = load float, float* %19
%21 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 3
%22 = load float, float* %21
%23 = fmul float %20, %22
%24 = call float @llvm.fmuladd.f32(float %16, float %18, float %23)
%25 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 1
%26 = load float, float* %25
%27 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 2
%28 = load float, float* %27
%29 = call float @llvm.fmuladd.f32(float %26, float %28, float %24)
%30 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 2
%31 = load float, float* %30
%32 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 1
%33 = load float, float* %32
%34 = fneg float %31
%35 = call float @llvm.fmuladd.f32(float %34, float %33, float %29)
%36 = load float*, float** %4
%37 = getelementptr inbounds float, float* %36, i64 0
store float %35, float* %37
%38 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 3
%39 = load float, float* %38
%40 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 1
%41 = load float, float* %40
%42 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 1
%43 = load float, float* %42
%44 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 3
%45 = load float, float* %44
%46 = fmul float %43, %45
%47 = call float @llvm.fmuladd.f32(float %39, float %41, float %46)
%48 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 2
%49 = load float, float* %48
%50 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%51 = load float, float* %50
%52 = call float @llvm.fmuladd.f32(float %49, float %51, float %47)
%53 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%54 = load float, float* %53
%55 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 2
%56 = load float, float* %55
%57 = fneg float %54
%58 = call float @llvm.fmuladd.f32(float %57, float %56, float %52)
%59 = load float*, float** %4
%60 = getelementptr inbounds float, float* %59, i64 1
store float %58, float* %60
%61 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 3
%62 = load float, float* %61
%63 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 2
%64 = load float, float* %63
%65 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 2
%66 = load float, float* %65
%67 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 3
%68 = load float, float* %67
%69 = fmul float %66, %68
%70 = call float @llvm.fmuladd.f32(float %62, float %64, float %69)
%71 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%72 = load float, float* %71
%73 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 1
%74 = load float, float* %73
%75 = call float @llvm.fmuladd.f32(float %72, float %74, float %70)
%76 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 1
%77 = load float, float* %76
%78 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%79 = load float, float* %78
%80 = fneg float %77
%81 = call float @llvm.fmuladd.f32(float %80, float %79, float %75)
%82 = load float*, float** %4
%83 = getelementptr inbounds float, float* %82, i64 2
store float %81, float* %83
%84 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 3
%85 = load float, float* %84
%86 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 3
%87 = load float, float* %86
%88 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%89 = load float, float* %88
%90 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%91 = load float, float* %90
%92 = fmul float %89, %91
%93 = fneg float %92
%94 = call float @llvm.fmuladd.f32(float %85, float %87, float %93)
%95 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 1
%96 = load float, float* %95
%97 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 1
%98 = load float, float* %97
%99 = fneg float %96
%100 = call float @llvm.fmuladd.f32(float %99, float %98, float %94)
%101 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 2
%102 = load float, float* %101
%103 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 2
%104 = load float, float* %103
%105 = fneg float %102
%106 = call float @llvm.fmuladd.f32(float %105, float %104, float %100)
%107 = load float*, float** %4
%108 = getelementptr inbounds float, float* %107, i64 3
store float %106, float* %108
ret void
}

LLVM IR (-O2):
define void @lib3ds_quat_mul(float* nocapture writeonly %0, float* %1, float* %2) {
%4 = alloca <4 x float>
%5 = alloca <4 x float>
%6 = bitcast <4 x float>* %4 to i8*
%7 = bitcast <4 x float>* %5 to i8*
%8 = getelementptr inbounds <4 x float>, <4 x float>* %4, i64 0, i64 0
%9 = call i32 @lib3ds_quat_copy(float* %8, float* %1)
%10 = getelementptr inbounds <4 x float>, <4 x float>* %5, i64 0, i64 0
%11 = call i32 @lib3ds_quat_copy(float* %10, float* %2)
%12 = load <4 x float>, <4 x float>* %4
%13 = load float, float* %8
%14 = getelementptr inbounds <4 x float>, <4 x float>* %4, i64 0, i64 1
%15 = bitcast float* %14 to <2 x float>*
%16 = load <2 x float>, <2 x float>* %15
%17 = load <4 x float>, <4 x float>* %5
%18 = fneg float %13
%19 = fneg <2 x float> %16
%20 = shufflevector <2 x float> %19, <2 x float> poison, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef>
%21 = insertelement <4 x float> %17, float %13, i64 1
%22 = shufflevector <4 x float> %21, <4 x float> %17, <4 x i32> <i32 0, i32 1, i32 7, i32 7>
%23 = insertelement <4 x float> poison, float %18, i64 0
%24 = shufflevector <4 x float> %23, <4 x float> %17, <4 x i32> <i32 0, i32 7, i32 undef, i32 undef>
%25 = shufflevector <2 x float> %16, <2 x float> poison, <4 x i32> <i32 1, i32 0, i32 undef, i32 undef>
%26 = shufflevector <4 x float> %24, <4 x float> %25, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
%27 = fmul <4 x float> %22, %26
%28 = shufflevector <4 x float> %27, <4 x float> poison, <4 x i32> <i32 1, i32 3, i32 2, i32 0>
%29 = shufflevector <4 x float> %12, <4 x float> poison, <4 x i32> <i32 3, i32 3, i32 3, i32 3>
%30 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %29, <4 x float> %17, <4 x float> %28)
%31 = extractelement <2 x float> %16, i64 0
%32 = insertelement <4 x float> poison, float %31, i64 0
%33 = extractelement <2 x float> %16, i64 1
%34 = insertelement <4 x float> %32, float %33, i64 1
%35 = insertelement <4 x float> %34, float %13, i64 2
%36 = shufflevector <4 x float> %35, <4 x float> %20, <4 x i32> <i32 0, i32 1, i32 2, i32 4>
%37 = shufflevector <4 x float> %17, <4 x float> undef, <4 x i32> <i32 2, i32 0, i32 1, i32 1>
%38 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %36, <4 x float> %37, <4 x float> %30)
%39 = extractelement <2 x float> %19, i64 1
%40 = insertelement <4 x float> poison, float %39, i64 0
%41 = insertelement <4 x float> %40, float %18, i64 1
%42 = shufflevector <2 x float> %19, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%43 = shufflevector <4 x float> %41, <4 x float> %42, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
%44 = shufflevector <4 x float> %17, <4 x float> undef, <4 x i32> <i32 1, i32 2, i32 0, i32 2>
%45 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %43, <4 x float> %44, <4 x float> %38)
%46 = bitcast float* %0 to <4 x float>*
store <4 x float> %45, <4 x float>* %46
ret void
}