#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 eulers_of_quat(double *euler, double *quat) {
  double dcm00 = 1.0 - 2 * (quat[2] * quat[2] + quat[3] * quat[3]);
  double dcm01 = 2 * (quat[1] * quat[2] + quat[0] * quat[3]);
  double dcm02 = 2 * (quat[1] * quat[3] - quat[0] * quat[2]);
  double dcm12 = 2 * (quat[2] * quat[3] + quat[0] * quat[1]);
  double dcm22 = 1.0 - 2 * (quat[1] * quat[1] + quat[2] * quat[2]);
  euler[0] = atan2(dcm12, dcm22);
  euler[1] = -asin(dcm02);
  euler[2] = atan2(dcm01, dcm00);
}


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

x86 assembly (clang, -O2):
<eulers_of_quat>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movsd  0x10(%rsi),%xmm0
movsd  0x18(%rsi),%xmm1
movapd %xmm0,%xmm8
movsd  0x8(%rsi),%xmm3
movapd %xmm1,%xmm9
movapd %xmm3,%xmm5
mulsd  %xmm0,%xmm5
movapd %xmm5,%xmm7
movapd %xmm0,%xmm5
movapd %xmm3,%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm0
movapd %xmm1,%xmm6
mulsd  %xmm1,%xmm6
mulsd  %xmm8,%xmm8
addsd  %xmm8,%xmm6
addsd  %xmm6,%xmm6
movsd  0xe85(%rip),%xmm1
movapd %xmm1,%xmm4
subsd  %xmm6,%xmm4
movsd  %xmm4,0x18(%rsp)
movsd  (%rsi),%xmm6
mulsd  %xmm6,%xmm9
addsd  %xmm9,%xmm7
addsd  %xmm7,%xmm7
movsd  %xmm7,0x10(%rsp)
mulsd  %xmm6,%xmm5
subsd  %xmm5,%xmm2
addsd  %xmm2,%xmm2
movsd  %xmm2,0x8(%rsp)
mulsd  %xmm3,%xmm6
addsd  %xmm6,%xmm0
addsd  %xmm0,%xmm0
mulsd  %xmm3,%xmm3
addsd  %xmm8,%xmm3
addsd  %xmm3,%xmm3
subsd  %xmm3,%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,(%rbx)
movsd  0x8(%rsp),%xmm0
call   1040 <asin@plt>
xorps  0xe25(%rip),%xmm0
movlps %xmm0,0x8(%rbx)
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,0x10(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

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

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