#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);
double sqrt(double);
void bot_quat_to_rodrigues(const double q[4], double r[3]) {
  double halftheta = acos(q[0]);
  double theta = halftheta * 2;
  double sinhalftheta = sin(halftheta);
  if (feq(halftheta, 0)) {
    r[0] = 0;
    r[1] = 0;
    r[2] = 0;
  } else {
    r[0] = q[1] / sinhalftheta;
    r[1] = q[2] / sinhalftheta;
    r[2] = q[3] / sinhalftheta;
    double rmag = sqrt(r[0] * r[0] + r[1] * r[1] + r[2] * r[2]);
    r[0] *= theta / rmag;
    r[1] *= theta / rmag;
    r[2] *= theta / rmag;
  }
}


x86 assembly (clang, -O0):
<bot_quat_to_rodrigues>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <acos@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xe96(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
xor    %edi,%edi
call   1060 <feq@plt>
cmp    $0x0,%rax
je     11c1 <bot_quat_to_rodrigues+0x81>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
jmp    1299 <bot_quat_to_rodrigues+0x159>
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm0
movsd  %xmm0,0x10(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bot_quat_to_rodrigues>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
call   1030 <acos@plt>
movaps %xmm0,(%rsp)
call   1040 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movapd (%rsp),%xmm0
xor    %edi,%edi
call   1060 <feq@plt>
test   %rax,%rax
je     118c <bot_quat_to_rodrigues+0x4c>
xorpd  %xmm0,%xmm0
movupd %xmm0,(%r14)
movq   $0x0,0x10(%r14)
jmp    1224 <bot_quat_to_rodrigues+0xe4>
movapd (%rsp),%xmm3
addsd  %xmm3,%xmm3
movsd  0x8(%rbx),%xmm1
movsd  0x10(%rsp),%xmm4
divsd  %xmm4,%xmm1
movsd  %xmm1,(%r14)
movsd  0x10(%rbx),%xmm2
divsd  %xmm4,%xmm2
movsd  %xmm2,0x8(%r14)
movsd  0x18(%rbx),%xmm0
divsd  %xmm4,%xmm0
movsd  %xmm0,0x10(%r14)
mulsd  %xmm2,%xmm2
mulsd  %xmm1,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
movapd %xmm3,%xmm2
jb     11ef <bot_quat_to_rodrigues+0xaf>
sqrtsd %xmm0,%xmm0
jmp    11fe <bot_quat_to_rodrigues+0xbe>
movapd %xmm2,(%rsp)
call   1050 <sqrt@plt>
movapd (%rsp),%xmm2
divsd  %xmm0,%xmm2
movupd (%r14),%xmm0
movapd %xmm2,%xmm1
unpcklpd %xmm2,%xmm1
mulpd  %xmm0,%xmm1
movupd %xmm1,(%r14)
mulsd  0x10(%r14),%xmm2
movsd  %xmm2,0x10(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @bot_quat_to_rodrigues(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double* %0, double** %3
store double* %1, double** %4
%9 = load double*, double** %3
%10 = getelementptr inbounds double, double* %9, i64 0
%11 = load double, double* %10
%12 = call double @acos(double %11)
store double %12, double* %5
%13 = load double, double* %5
%14 = fmul double %13, 2.000000e+00
store double %14, double* %6
%15 = load double, double* %5
%16 = call double @sin(double %15)
store double %16, double* %7
%17 = load double, double* %5
%18 = call i64 @feq(double %17, i32 0)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %2
%21 = load double*, double** %4
%22 = getelementptr inbounds double, double* %21, i64 0
store double 0.000000e+00, double* %22
%23 = load double*, double** %4
%24 = getelementptr inbounds double, double* %23, i64 1
store double 0.000000e+00, double* %24
%25 = load double*, double** %4
%26 = getelementptr inbounds double, double* %25, i64 2
store double 0.000000e+00, double* %26
br label %92
27: ; preds = %2
%28 = load double*, double** %3
%29 = getelementptr inbounds double, double* %28, i64 1
%30 = load double, double* %29
%31 = load double, double* %7
%32 = fdiv double %30, %31
%33 = load double*, double** %4
%34 = getelementptr inbounds double, double* %33, i64 0
store double %32, double* %34
%35 = load double*, double** %3
%36 = getelementptr inbounds double, double* %35, i64 2
%37 = load double, double* %36
%38 = load double, double* %7
%39 = fdiv double %37, %38
%40 = load double*, double** %4
%41 = getelementptr inbounds double, double* %40, i64 1
store double %39, double* %41
%42 = load double*, double** %3
%43 = getelementptr inbounds double, double* %42, i64 3
%44 = load double, double* %43
%45 = load double, double* %7
%46 = fdiv double %44, %45
%47 = load double*, double** %4
%48 = getelementptr inbounds double, double* %47, i64 2
store double %46, double* %48
%49 = load double*, double** %4
%50 = getelementptr inbounds double, double* %49, i64 0
%51 = load double, double* %50
%52 = load double*, double** %4
%53 = getelementptr inbounds double, double* %52, i64 0
%54 = load double, double* %53
%55 = load double*, double** %4
%56 = getelementptr inbounds double, double* %55, i64 1
%57 = load double, double* %56
%58 = load double*, double** %4
%59 = getelementptr inbounds double, double* %58, i64 1
%60 = load double, double* %59
%61 = fmul double %57, %60
%62 = call double @llvm.fmuladd.f64(double %51, double %54, double %61)
%63 = load double*, double** %4
%64 = getelementptr inbounds double, double* %63, i64 2
%65 = load double, double* %64
%66 = load double*, double** %4
%67 = getelementptr inbounds double, double* %66, i64 2
%68 = load double, double* %67
%69 = call double @llvm.fmuladd.f64(double %65, double %68, double %62)
%70 = call double @sqrt(double %69)
store double %70, double* %8
%71 = load double, double* %6
%72 = load double, double* %8
%73 = fdiv double %71, %72
%74 = load double*, double** %4
%75 = getelementptr inbounds double, double* %74, i64 0
%76 = load double, double* %75
%77 = fmul double %76, %73
store double %77, double* %75
%78 = load double, double* %6
%79 = load double, double* %8
%80 = fdiv double %78, %79
%81 = load double*, double** %4
%82 = getelementptr inbounds double, double* %81, i64 1
%83 = load double, double* %82
%84 = fmul double %83, %80
store double %84, double* %82
%85 = load double, double* %6
%86 = load double, double* %8
%87 = fdiv double %85, %86
%88 = load double*, double** %4
%89 = getelementptr inbounds double, double* %88, i64 2
%90 = load double, double* %89
%91 = fmul double %90, %87
store double %91, double* %89
br label %92
92: ; preds = %27, %20
ret void
}

LLVM IR (-O2):
define void @bot_quat_to_rodrigues(double* nocapture %0, double* nocapture %1) {
%3 = load double, double* %0
%4 = tail call double @acos(double %3)
%5 = tail call double @sin(double %4)
%6 = tail call i64 @feq(double %4, i32 0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = bitcast double* %1 to i8*
br label %36
10: ; preds = %2
%11 = fmul double %4, 2.000000e+00
%12 = getelementptr inbounds double, double* %0, i64 1
%13 = load double, double* %12
%14 = fdiv double %13, %5
store double %14, double* %1
%15 = getelementptr inbounds double, double* %0, i64 2
%16 = load double, double* %15
%17 = fdiv double %16, %5
%18 = getelementptr inbounds double, double* %1, i64 1
store double %17, double* %18
%19 = getelementptr inbounds double, double* %0, i64 3
%20 = load double, double* %19
%21 = fdiv double %20, %5
%22 = getelementptr inbounds double, double* %1, i64 2
store double %21, double* %22
%23 = fmul double %17, %17
%24 = tail call double @llvm.fmuladd.f64(double %14, double %14, double %23)
%25 = tail call double @llvm.fmuladd.f64(double %21, double %21, double %24)
%26 = tail call double @sqrt(double %25)
%27 = fdiv double %11, %26
%28 = bitcast double* %1 to <2 x double>*
%29 = load <2 x double>, <2 x double>* %28
%30 = insertelement <2 x double> poison, double %27, i64 0
%31 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> zeroinitializer
%32 = fmul <2 x double> %29, %31
%33 = bitcast double* %1 to <2 x double>*
store <2 x double> %32, <2 x double>* %33
%34 = load double, double* %22
%35 = fmul double %27, %34
store double %35, double* %22
br label %36
36: ; preds = %10, %8
ret void
}