#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*/ quaternion_conjugate(float *, float const *);
int /*<<< orphan*/ quaternion_multiply(float *, float const *, float *);
void rotateVector(float out[3], const float src[3], const float quat[4]) {
  float posQuat[4];
  float temp[4], conj[4];
  posQuat[0] = src[0];
  posQuat[1] = src[1];
  posQuat[2] = src[2];
  posQuat[3] = 0.0f;
  quaternion_multiply(temp, quat, posQuat);
  quaternion_conjugate(conj, quat);
  quaternion_multiply(temp, temp, conj);
  out[0] = temp[0];
  out[1] = temp[1];
  out[2] = temp[2];
}


x86 assembly (clang, -O0):
<rotateVector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <quaternion_multiply@plt>
lea    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <quaternion_conjugate@plt>
lea    -0x40(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1030 <quaternion_multiply@plt>
movss  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x3c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotateVector>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r14
mov    %rdi,%rbx
movss  (%rsi),%xmm0
movss  %xmm0,(%rsp)
movss  0x4(%rsi),%xmm0
movss  %xmm0,0x4(%rsp)
movss  0x8(%rsi),%xmm0
movss  %xmm0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%r15
mov    %rsp,%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <quaternion_multiply@plt>
lea    0x20(%rsp),%r12
mov    %r12,%rdi
mov    %r14,%rsi
call   1040 <quaternion_conjugate@plt>
mov    %r15,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <quaternion_multiply@plt>
movss  0x10(%rsp),%xmm0
movss  %xmm0,(%rbx)
movss  0x14(%rsp),%xmm0
movss  %xmm0,0x4(%rbx)
movss  0x18(%rsp),%xmm0
movss  %xmm0,0x8(%rbx)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @rotateVector(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]
%9 = alloca [4 x float]
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%10 = load float*, float** %5
%11 = getelementptr inbounds float, float* %10, i64 0
%12 = load float, float* %11
%13 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
store float %12, float* %13
%14 = load float*, float** %5
%15 = getelementptr inbounds float, float* %14, i64 1
%16 = load float, float* %15
%17 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 1
store float %16, float* %17
%18 = load float*, float** %5
%19 = getelementptr inbounds float, float* %18, i64 2
%20 = load float, float* %19
%21 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 2
store float %20, float* %21
%22 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 3
store float 0.000000e+00, float* %22
%23 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%24 = load float*, float** %6
%25 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%26 = call i32 @quaternion_multiply(float* %23, float* %24, float* %25)
%27 = getelementptr inbounds [4 x float], [4 x float]* %9, i64 0, i64 0
%28 = load float*, float** %6
%29 = call i32 @quaternion_conjugate(float* %27, float* %28)
%30 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%31 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%32 = getelementptr inbounds [4 x float], [4 x float]* %9, i64 0, i64 0
%33 = call i32 @quaternion_multiply(float* %30, float* %31, float* %32)
%34 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%35 = load float, float* %34
%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]* %8, i64 0, i64 1
%39 = load float, float* %38
%40 = load float*, float** %4
%41 = getelementptr inbounds float, float* %40, i64 1
store float %39, float* %41
%42 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 2
%43 = load float, float* %42
%44 = load float*, float** %4
%45 = getelementptr inbounds float, float* %44, i64 2
store float %43, float* %45
ret void
}

LLVM IR (-O2):
define void @rotateVector(float* nocapture writeonly %0, float* nocapture %1, float* %2) {
%4 = alloca [4 x float]
%5 = alloca [4 x float]
%6 = alloca [4 x float]
%7 = bitcast [4 x float]* %4 to i8*
%8 = bitcast [4 x float]* %5 to i8*
%9 = bitcast [4 x float]* %6 to i8*
%10 = load float, float* %1
%11 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 0
store float %10, float* %11
%12 = getelementptr inbounds float, float* %1, i64 1
%13 = load float, float* %12
%14 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 1
store float %13, float* %14
%15 = getelementptr inbounds float, float* %1, i64 2
%16 = load float, float* %15
%17 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 2
store float %16, float* %17
%18 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 3
store float 0.000000e+00, float* %18
%19 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 0
%20 = call i32 @quaternion_multiply(float* %19, float* %2, float* %11)
%21 = getelementptr inbounds [4 x float], [4 x float]* %6, i64 0, i64 0
%22 = call i32 @quaternion_conjugate(float* %21, float* %2)
%23 = call i32 @quaternion_multiply(float* %19, float* %19, float* %21)
%24 = load float, float* %19
store float %24, float* %0
%25 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 1
%26 = load float, float* %25
%27 = getelementptr inbounds float, float* %0, i64 1
store float %26, float* %27
%28 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 2
%29 = load float, float* %28
%30 = getelementptr inbounds float, float* %0, i64 2
store float %29, float* %30
ret void
}