#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 */
float cos(float);
int /*<<< orphan*/ floats_normalize(float *, int, float *);
float sin(float);
void floats_angleaxis_to_quat(const float aa[4], float q[4]) {
  float rad = aa[0];
  q[0] = cos(rad / 2.0);
  float s = 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>
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe7c(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <sin@plt>
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>
movss  %xmm0,(%r14)
movss  0x8(%rsp),%xmm0
call   1030 <sin@plt>
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 float @cos(float %14)
%16 = load float*, float** %4
%17 = getelementptr inbounds float, float* %16, i64 0
store float %15, float* %17
%18 = load float, float* %5
%19 = fpext float %18 to double
%20 = fdiv double %19, 2.000000e+00
%21 = fptrunc double %20 to float
%22 = call float @sin(float %21)
store float %22, float* %6
%23 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%24 = load float*, float** %3
%25 = getelementptr inbounds float, float* %24, i64 1
%26 = load float, float* %25
store float %26, float* %23
%27 = getelementptr inbounds float, float* %23, i64 1
%28 = load float*, float** %3
%29 = getelementptr inbounds float, float* %28, i64 2
%30 = load float, float* %29
store float %30, float* %27
%31 = getelementptr inbounds float, float* %27, i64 1
%32 = load float*, float** %3
%33 = getelementptr inbounds float, float* %32, i64 3
%34 = load float, float* %33
store float %34, float* %31
%35 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%36 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%37 = call i32 @floats_normalize(float* %35, i32 3, float* %36)
%38 = load float, float* %6
%39 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%40 = load float, float* %39
%41 = fmul float %38, %40
%42 = load float*, float** %4
%43 = getelementptr inbounds float, float* %42, i64 1
store float %41, float* %43
%44 = load float, float* %6
%45 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 1
%46 = load float, float* %45
%47 = fmul float %44, %46
%48 = load float*, float** %4
%49 = getelementptr inbounds float, float* %48, i64 2
store float %47, float* %49
%50 = load float, float* %6
%51 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 2
%52 = load float, float* %51
%53 = fmul float %50, %52
%54 = load float*, float** %4
%55 = getelementptr inbounds float, float* %54, i64 3
store float %53, float* %55
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 float @cos(float %5)
store float %6, float* %1
%7 = tail call float @sin(float %5)
%8 = bitcast [3 x float]* %3 to i8*
%9 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 0
%10 = getelementptr inbounds float, float* %0, i64 1
%11 = load float, float* %10
store float %11, float* %9
%12 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 1
%13 = getelementptr inbounds float, float* %0, i64 2
%14 = load float, float* %13
store float %14, float* %12
%15 = getelementptr inbounds [3 x float], [3 x float]* %3, i64 0, i64 2
%16 = getelementptr inbounds float, float* %0, i64 3
%17 = load float, float* %16
store float %17, float* %15
%18 = call i32 @floats_normalize(float* %9, i32 3, float* %9)
%19 = load float, float* %9
%20 = fmul float %7, %19
%21 = getelementptr inbounds float, float* %1, i64 1
store float %20, float* %21
%22 = load float, float* %12
%23 = fmul float %7, %22
%24 = getelementptr inbounds float, float* %1, i64 2
store float %23, float* %24
%25 = load float, float* %15
%26 = fmul float %7, %25
%27 = getelementptr inbounds float, float* %1, i64 3
store float %26, float* %27
ret void
}