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