#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 */
scalar_t__ cos(float);
int /*<<< orphan*/ floats_normalize(float *, int, float *);
scalar_t__ sin(float);
void floats_angleaxis_to_quat(const float aa[4], float q[4]) {
  float rad = aa[0];
  q[0] = (float)cos(rad / 2.0);
  float s = (float)sin(rad / 2.0);
  float v[3] = {aa[1], aa[2], aa[3]};
  floats_normalize(v, 3, v);
  q[1] = s * v[0];
  q[2] = s * v[1];
  q[3] = s * v[2];
}


x86 assembly (clang, -O0):
<floats_angleaxis_to_quat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xea2(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <cos@plt>
cvtsi2ss %rax,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe77(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <sin@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
movss  %xmm0,-0x1c(%rbp)
lea    -0x24(%rbp),%rdi
lea    -0x24(%rbp),%rdx
mov    $0x3,%esi
call   1040 <floats_normalize@plt>
movss  -0x18(%rbp),%xmm0
mulss  -0x24(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x18(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x18(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0xc(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floats_angleaxis_to_quat>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movss  (%rdi),%xmm0
mulss  0xeb7(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
call   1050 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,(%r14)
movss  0x8(%rsp),%xmm0
call   1030 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,0x8(%rsp)
movss  0x4(%rbx),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x8(%rbx),%xmm0
movss  %xmm0,0x10(%rsp)
movss  0xc(%rbx),%xmm0
movss  %xmm0,0x14(%rsp)
lea    0xc(%rsp),%rdi
mov    $0x3,%esi
mov    %rdi,%rdx
call   1040 <floats_normalize@plt>
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,0x4(%r14)
movss  0x10(%rsp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,0x8(%r14)
mulss  0x14(%rsp),%xmm1
movss  %xmm1,0xc(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @floats_angleaxis_to_quat(float* %0, float* %1) {
%3 = alloca float*
%4 = alloca float*
%5 = alloca float
%6 = alloca float
%7 = alloca [3 x float]
store float* %0, float** %3
store float* %1, float** %4
%8 = load float*, float** %3
%9 = getelementptr inbounds float, float* %8, i64 0
%10 = load float, float* %9
store float %10, float* %5
%11 = load float, float* %5
%12 = fpext float %11 to double
%13 = fdiv double %12, 2.000000e+00
%14 = fptrunc double %13 to float
%15 = call i64 @cos(float %14)
%16 = sitofp i64 %15 to float
%17 = load float*, float** %4
%18 = getelementptr inbounds float, float* %17, i64 0
store float %16, float* %18
%19 = load float, float* %5
%20 = fpext float %19 to double
%21 = fdiv double %20, 2.000000e+00
%22 = fptrunc double %21 to float
%23 = call i64 @sin(float %22)
%24 = sitofp i64 %23 to float
store float %24, float* %6
%25 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%26 = load float*, float** %3
%27 = getelementptr inbounds float, float* %26, i64 1
%28 = load float, float* %27
store float %28, float* %25
%29 = getelementptr inbounds float, float* %25, i64 1
%30 = load float*, float** %3
%31 = getelementptr inbounds float, float* %30, i64 2
%32 = load float, float* %31
store float %32, float* %29
%33 = getelementptr inbounds float, float* %29, i64 1
%34 = load float*, float** %3
%35 = getelementptr inbounds float, float* %34, i64 3
%36 = load float, float* %35
store float %36, float* %33
%37 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%38 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%39 = call i32 @floats_normalize(float* %37, i32 3, float* %38)
%40 = load float, float* %6
%41 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%42 = load float, float* %41
%43 = fmul float %40, %42
%44 = load float*, float** %4
%45 = getelementptr inbounds float, float* %44, i64 1
store float %43, float* %45
%46 = load float, float* %6
%47 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 1
%48 = load float, float* %47
%49 = fmul float %46, %48
%50 = load float*, float** %4
%51 = getelementptr inbounds float, float* %50, i64 2
store float %49, float* %51
%52 = load float, float* %6
%53 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 2
%54 = load float, float* %53
%55 = fmul float %52, %54
%56 = load float*, float** %4
%57 = getelementptr inbounds float, float* %56, i64 3
store float %55, float* %57
ret void
}

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