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


x86 assembly (clang, -O0):
<doubles_angleaxis_to_quat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xea6(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <cos@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
movsd  0xe88(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x40(%rbp),%rdx
mov    $0x3,%esi
call   1040 <doubles_normalize@plt>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x18(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doubles_angleaxis_to_quat>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
mulsd  0xeb7(%rip),%xmm0
movsd  %xmm0,(%rsp)
call   1050 <cos@plt>
movsd  %xmm0,(%r14)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,(%rsp)
movups 0x8(%rbx),%xmm0
movaps %xmm0,0x10(%rsp)
movsd  0x18(%rbx),%xmm0
movsd  %xmm0,0x20(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x3,%esi
mov    %rdi,%rdx
call   1040 <doubles_normalize@plt>
movapd (%rsp),%xmm1
movapd %xmm1,%xmm0
unpcklpd %xmm1,%xmm0
mulpd  0x10(%rsp),%xmm0
movupd %xmm0,0x8(%r14)
mulsd  0x20(%rsp),%xmm1
movsd  %xmm1,0x18(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

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