#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*/ q_mul(float *, float const *, float *);
void q_rot(float v[3], const float r[4], const float w[3]) {
  float a[4], b[4], c[4];
  a[0] = 0.0f;
  a[1] = w[0];
  a[2] = w[1];
  a[3] = w[2];
  q_mul(b, r, a);
  a[0] = r[0];
  a[1] = -r[1];
  a[2] = -r[2];
  a[3] = -r[3];
  q_mul(c, b, a);
  v[0] = c[1];
  v[1] = c[2];
  v[2] = c[3];
}


x86 assembly (clang, -O0):
<q_rot>:
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,-0x30(%rbp)
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x24(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <q_mul@plt>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movss  0xc(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x24(%rbp)
lea    -0x50(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <q_mul@plt>
movss  -0x4c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x48(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x44(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<q_rot>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
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 <q_mul@plt>
movss  (%rbx),%xmm0
movss  %xmm0,(%rsp)
movss  0x4(%rbx),%xmm0
movaps 0xe90(%rip),%xmm1
xorps  %xmm1,%xmm0
movss  %xmm0,0x4(%rsp)
movss  0x8(%rbx),%xmm0
xorps  %xmm1,%xmm0
movss  %xmm0,0x8(%rsp)
movss  0xc(%rbx),%xmm0
xorps  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
lea    0x10(%rsp),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <q_mul@plt>
movss  0x14(%rsp),%xmm0
movss  %xmm0,(%r14)
movss  0x18(%rsp),%xmm0
movss  %xmm0,0x4(%r14)
movss  0x1c(%rsp),%xmm0
movss  %xmm0,0x8(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @q_rot(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]* %7, 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]* %7, 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]* %7, 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]* %7, i64 0, i64 3
store float %21, float* %22
%23 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%24 = load float*, float** %5
%25 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%26 = call i32 @q_mul(float* %23, float* %24, float* %25)
%27 = load float*, float** %5
%28 = getelementptr inbounds float, float* %27, i64 0
%29 = load float, float* %28
%30 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
store float %29, float* %30
%31 = load float*, float** %5
%32 = getelementptr inbounds float, float* %31, i64 1
%33 = load float, float* %32
%34 = fneg float %33
%35 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 1
store float %34, float* %35
%36 = load float*, float** %5
%37 = getelementptr inbounds float, float* %36, i64 2
%38 = load float, float* %37
%39 = fneg float %38
%40 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 2
store float %39, float* %40
%41 = load float*, float** %5
%42 = getelementptr inbounds float, float* %41, i64 3
%43 = load float, float* %42
%44 = fneg float %43
%45 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 3
store float %44, float* %45
%46 = getelementptr inbounds [4 x float], [4 x float]* %9, i64 0, i64 0
%47 = getelementptr inbounds [4 x float], [4 x float]* %8, i64 0, i64 0
%48 = getelementptr inbounds [4 x float], [4 x float]* %7, i64 0, i64 0
%49 = call i32 @q_mul(float* %46, float* %47, float* %48)
%50 = getelementptr inbounds [4 x float], [4 x float]* %9, i64 0, i64 1
%51 = load float, float* %50
%52 = load float*, float** %4
%53 = getelementptr inbounds float, float* %52, i64 0
store float %51, float* %53
%54 = getelementptr inbounds [4 x float], [4 x float]* %9, i64 0, i64 2
%55 = load float, float* %54
%56 = load float*, float** %4
%57 = getelementptr inbounds float, float* %56, i64 1
store float %55, float* %57
%58 = getelementptr inbounds [4 x float], [4 x float]* %9, i64 0, i64 3
%59 = load float, float* %58
%60 = load float*, float** %4
%61 = getelementptr inbounds float, float* %60, i64 2
store float %59, float* %61
ret void
}

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