#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*/ quatgetreciprocal(float *, float const *);
int /*<<< orphan*/ quatrotateabout(float *, float const *, float *);
void quatrotatevector(float *vec3out, const float *quat, const float *vec3in) {
  float tquat[4];
  float vquat[4];
  float qrecp[4];
  vquat[0] = 0;
  vquat[1] = vec3in[0];
  vquat[2] = vec3in[1];
  vquat[3] = vec3in[2];
  quatrotateabout(tquat, quat, vquat);
  quatgetreciprocal(qrecp, quat);
  quatrotateabout(vquat, tquat, qrecp);
  vec3out[0] = vquat[1];
  vec3out[1] = vquat[2];
  vec3out[2] = vquat[3];
}


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

x86 assembly (clang, -O2):
<quatrotatevector>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,(%rsp)
movss  (%rdx),%xmm0
movss  %xmm0,0x4(%rsp)
movss  0x4(%rdx),%xmm0
movss  %xmm0,0x8(%rsp)
movss  0x8(%rdx),%xmm0
movss  %xmm0,0xc(%rsp)
lea    0x20(%rsp),%r15
mov    %rsp,%r12
mov    %r15,%rdi
mov    %r12,%rdx
call   1030 <quatrotateabout@plt>
lea    0x10(%rsp),%r13
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <quatgetreciprocal@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
call   1030 <quatrotateabout@plt>
movss  0x4(%rsp),%xmm0
movss  %xmm0,(%rbx)
movss  0x8(%rsp),%xmm0
movss  %xmm0,0x4(%rbx)
movss  0xc(%rsp),%xmm0
movss  %xmm0,0x8(%rbx)
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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