#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 asin(double);
double atan2(double, double);
void bot_quat_to_roll_pitch_yaw(const double q[4], double rpy[3]) {
  double roll_a = 2 * (q[0] * q[1] + q[2] * q[3]);
  double roll_b = 1 - 2 * (q[1] * q[1] + q[2] * q[2]);
  rpy[0] = atan2(roll_a, roll_b);
  double pitch_sin = 2 * (q[0] * q[2] - q[3] * q[1]);
  rpy[1] = asin(pitch_sin);
  double yaw_a = 2 * (q[0] * q[3] + q[1] * q[2]);
  double yaw_b = 1 - 2 * (q[2] * q[2] + q[3] * q[3]);
  rpy[2] = atan2(yaw_a, yaw_b);
}


x86 assembly (clang, -O0):
<bot_quat_to_roll_pitch_yaw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x18(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xea5(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x10(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm1,%xmm1
movsd  0xe5c(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xdfa(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <asin@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x10(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xdab(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x18(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm1,%xmm1
movsd  0xd62(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bot_quat_to_roll_pitch_yaw>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  0x8(%rdi),%xmm2
movsd  0x10(%rdi),%xmm1
movsd  0x18(%rdi),%xmm3
mulsd  %xmm1,%xmm3
movsd  (%rdi),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm3,%xmm0
addsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
mulsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
addsd  %xmm2,%xmm2
movsd  0xe9b(%rip),%xmm1
subsd  %xmm2,%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,(%r14)
movsd  (%rbx),%xmm0
movsd  0x8(%rbx),%xmm1
mulsd  0x18(%rbx),%xmm1
mulsd  0x10(%rbx),%xmm0
subsd  %xmm1,%xmm0
addsd  %xmm0,%xmm0
call   1040 <asin@plt>
movsd  %xmm0,0x8(%r14)
movsd  0x10(%rbx),%xmm4
movsd  0x18(%rbx),%xmm2
movsd  0x8(%rbx),%xmm3
mulsd  %xmm4,%xmm3
movsd  (%rbx),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm3,%xmm0
addsd  %xmm0,%xmm0
mulsd  %xmm2,%xmm2
mulsd  %xmm4,%xmm4
addsd  %xmm2,%xmm4
addsd  %xmm4,%xmm4
movsd  0xe2c(%rip),%xmm1
subsd  %xmm4,%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,0x10(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @bot_quat_to_roll_pitch_yaw(double* nocapture %0, double* nocapture writeonly %1) {
%3 = load double, double* %0
%4 = getelementptr inbounds double, double* %0, i64 1
%5 = load double, double* %4
%6 = getelementptr inbounds double, double* %0, i64 2
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %0, i64 3
%9 = load double, double* %8
%10 = fmul double %7, %9
%11 = tail call double @llvm.fmuladd.f64(double %3, double %5, double %10)
%12 = fmul double %11, 2.000000e+00
%13 = fmul double %7, %7
%14 = tail call double @llvm.fmuladd.f64(double %5, double %5, double %13)
%15 = tail call double @llvm.fmuladd.f64(double %14, double -2.000000e+00, double 1.000000e+00)
%16 = tail call double @atan2(double %12, double %15)
store double %16, double* %1
%17 = load double, double* %0
%18 = load double, double* %6
%19 = load double, double* %8
%20 = load double, double* %4
%21 = fneg double %19
%22 = fmul double %20, %21
%23 = tail call double @llvm.fmuladd.f64(double %17, double %18, double %22)
%24 = fmul double %23, 2.000000e+00
%25 = tail call double @asin(double %24)
%26 = getelementptr inbounds double, double* %1, i64 1
store double %25, double* %26
%27 = load double, double* %0
%28 = load double, double* %8
%29 = load double, double* %4
%30 = load double, double* %6
%31 = fmul double %29, %30
%32 = tail call double @llvm.fmuladd.f64(double %27, double %28, double %31)
%33 = fmul double %32, 2.000000e+00
%34 = fmul double %28, %28
%35 = tail call double @llvm.fmuladd.f64(double %30, double %30, double %34)
%36 = tail call double @llvm.fmuladd.f64(double %35, double -2.000000e+00, double 1.000000e+00)
%37 = tail call double @atan2(double %33, double %36)
%38 = getelementptr inbounds double, double* %1, i64 2
store double %37, double* %38
ret void
}