#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 acos(double const);
scalar_t__ feq(double, int /*<<< orphan*/);
double sin(double);
void bot_quat_to_angle_axis(const double q[4], double *theta, double axis[3]) {
  double halftheta = acos(q[0]);
  *theta = halftheta * 2;
  double sinhalftheta = sin(halftheta);
  if (feq(halftheta, 0)) {
    axis[0] = 0;
    axis[1] = 0;
    axis[2] = 1;
    *theta = 0;
  } else {
    axis[0] = q[1] / sinhalftheta;
    axis[1] = q[2] / sinhalftheta;
    axis[2] = q[3] / sinhalftheta;
  }
}


x86 assembly (clang, -O0):
<bot_quat_to_angle_axis>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <acos@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xea2(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
xor    %edi,%edi
call   1050 <feq@plt>
cmp    $0x0,%rax
je     11c8 <bot_quat_to_angle_axis+0x98>
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
movsd  0xe55(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    120c <bot_quat_to_angle_axis+0xdc>
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bot_quat_to_angle_axis>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
call   1030 <acos@plt>
movsd  %xmm0,0x8(%rsp)
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r15)
call   1040 <sin@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
xor    %edi,%edi
call   1050 <feq@plt>
test   %rax,%rax
je     119a <bot_quat_to_angle_axis+0x6a>
xorpd  %xmm0,%xmm0
movupd %xmm0,(%r14)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x10(%r14)
movq   $0x0,(%r15)
jmp    11cb <bot_quat_to_angle_axis+0x9b>
movsd  0x8(%rbx),%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%r14)
movsd  0x10(%rbx),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%r14)
movsd  0x18(%rbx),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @bot_quat_to_angle_axis(double* nocapture %0, double* nocapture writeonly %1, double* nocapture writeonly %2) {
%4 = load double, double* %0
%5 = tail call double @acos(double %4)
%6 = fmul double %5, 2.000000e+00
store double %6, double* %1
%7 = tail call double @sin(double %5)
%8 = tail call i64 @feq(double %5, i32 0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = getelementptr inbounds double, double* %2, i64 2
%12 = bitcast double* %2 to i8*
store double 1.000000e+00, double* %11
store double 0.000000e+00, double* %1
br label %25
13: ; preds = %3
%14 = getelementptr inbounds double, double* %0, i64 1
%15 = load double, double* %14
%16 = fdiv double %15, %7
store double %16, double* %2
%17 = getelementptr inbounds double, double* %0, i64 2
%18 = load double, double* %17
%19 = fdiv double %18, %7
%20 = getelementptr inbounds double, double* %2, i64 1
store double %19, double* %20
%21 = getelementptr inbounds double, double* %0, i64 3
%22 = load double, double* %21
%23 = fdiv double %22, %7
%24 = getelementptr inbounds double, double* %2, i64 2
store double %23, double* %24
br label %25
25: ; preds = %13, %10
ret void
}