#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*/ memcpy(float *, float *, int);
int /*<<< orphan*/ quaternion_product(float *, float *, float *);
int /*<<< orphan*/ quaternion_vector_product(float const *, float const *,
                                             float *);
void rotate_position(const float orientation[4], const float position[3],
                     float position_out[3]) {
  float temp[4], invQuat[4], quat_out[4];
  invQuat[3] = orientation[3];
  invQuat[0] = -orientation[0];
  invQuat[1] = -orientation[1];
  invQuat[2] = -orientation[2];
  quaternion_vector_product(orientation, position, temp);
  quaternion_product(temp, invQuat, quat_out);
  memcpy(position_out, quat_out, 3 * sizeof(float));
}


x86 assembly (clang, -O0):
<rotate_position>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <quaternion_vector_product@plt>
lea    -0x30(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1040 <quaternion_product@plt>
mov    -0x18(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    $0xc,%edx
call   1050 <memcpy@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotate_position>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdx,%r14
movss  0xc(%rdi),%xmm0
movss  %xmm0,0xc(%rsp)
movss  (%rdi),%xmm0
movaps 0xeae(%rip),%xmm1
xorps  %xmm1,%xmm0
movss  %xmm0,(%rsp)
movss  0x4(%rdi),%xmm0
xorps  %xmm1,%xmm0
movss  %xmm0,0x4(%rsp)
movss  0x8(%rdi),%xmm0
xorps  %xmm1,%xmm0
movss  %xmm0,0x8(%rsp)
lea    0x20(%rsp),%rbx
mov    %rbx,%rdx
call   1030 <quaternion_vector_product@plt>
mov    %rsp,%rsi
lea    0x10(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rdx
call   1040 <quaternion_product@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0xc,%edx
call   1050 <memcpy@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @rotate_position(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** %4
%11 = getelementptr inbounds float, float* %10, i64 3
%12 = load float, float* %11
%13 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 3
store float %12, float* %13
%14 = load float*, float** %4
%15 = getelementptr inbounds float, float* %14, i64 0
%16 = load float, float* %15
%17 = fneg float %16
%18 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
store float %17, float* %18
%19 = load float*, float** %4
%20 = getelementptr inbounds float, float* %19, i64 1
%21 = load float, float* %20
%22 = fneg float %21
%23 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 1
store float %22, float* %23
%24 = load float*, float** %4
%25 = getelementptr inbounds float, float* %24, i64 2
%26 = load float, float* %25
%27 = fneg float %26
%28 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 2
store float %27, float* %28
%29 = load float*, float** %4
%30 = load float*, float** %5
%31 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%32 = call i32 @quaternion_vector_product(float* %29, float* %30, float* %31)
%33 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%34 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%35 = getelementptr inbounds [4 x float], [4 x float]* %9, i64 0, i64 0
%36 = call i32 @quaternion_product(float* %33, float* %34, float* %35)
%37 = load float*, float** %6
%38 = getelementptr inbounds [4 x float], [4 x float]* %9, i64 0, i64 0
%39 = call i32 @memcpy(float* %37, float* %38, i32 12)
ret void
}

LLVM IR (-O2):
define void @rotate_position(float* %0, float* %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 = getelementptr inbounds float, float* %0, i64 3
%11 = load float, float* %10
%12 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 3
store float %11, float* %12
%13 = load float, float* %0
%14 = fneg float %13
%15 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 0
store float %14, float* %15
%16 = getelementptr inbounds float, float* %0, i64 1
%17 = load float, float* %16
%18 = fneg float %17
%19 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 1
store float %18, float* %19
%20 = getelementptr inbounds float, float* %0, i64 2
%21 = load float, float* %20
%22 = fneg float %21
%23 = getelementptr inbounds [4 x float], [4 x float]* %5, i64 0, i64 2
store float %22, float* %23
%24 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 0
%25 = call i32 @quaternion_vector_product(float* %0, float* %1, float* %24)
%26 = getelementptr inbounds [4 x float], [4 x float]* %6, i64 0, i64 0
%27 = call i32 @quaternion_product(float* %24, float* %15, float* %26)
%28 = call i32 @memcpy(float* %2, float* %26, i32 12)
ret void
}