#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 */
float asin(float);
float atan2(float, float);
void Quat2Euler(const float *quat, float *angle) {
  float ysqr = (*(quat + 2)) * (*(quat + 2));
  float t0 =
      +2.0f * ((*(quat)) * (*(quat + 1)) + (*(quat + 2)) * (*(quat + 3)));
  float t1 = +1.0f - 2.0f * ((*(quat + 1)) * (*(quat + 1)) + ysqr);
  *angle = atan2(t0, t1);
  float t2 =
      +2.0f * ((*(quat)) * (*(quat + 2)) - (*(quat + 3)) * (*(quat + 1)));
  t2 = t2 > 1.0f ? 1.0f : t2;
  t2 = t2 < -1.0f ? -1.0f : t2;
  *(angle + 1) = asin(t2);
  float t3 =
      +2.0f * ((*(quat)) * (*(quat + 3)) + (*(quat + 1)) * (*(quat + 2)));
  float t4 = +1.0f - 2.0f * (ysqr + (*(quat + 3)) * (*(quat + 3)));
  *(angle + 2) = atan2(t3, t4);
}


x86 assembly (clang, -O0):
<Quat2Euler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulss  0x8(%rax),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulss  0xc(%rax),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  0xe8a(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm1
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm2
movss  -0x14(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
addss  %xmm1,%xmm1
movss  0xe52(%rip),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulss  0x4(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  0xdf6(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
movss  0xddc(%rip),%xmm1
ucomiss %xmm1,%xmm0
jbe    123f <Quat2Euler+0x11f>
movss  0xdcb(%rip),%xmm0
movss  %xmm0,-0x2c(%rbp)
jmp    1249 <Quat2Euler+0x129>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  0xdad(%rip),%xmm0
ucomiss -0x20(%rbp),%xmm0
jbe    1277 <Quat2Euler+0x157>
movss  0xd9b(%rip),%xmm0
movss  %xmm0,-0x30(%rbp)
jmp    1281 <Quat2Euler+0x161>
movss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
call   1040 <asin@plt>
mov    -0x10(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x8(%rbp),%rax
mulss  0x8(%rax),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  0xd33(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x14(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm1
mov    -0x8(%rbp),%rax
movss  0xc(%rax),%xmm2
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
addss  %xmm1,%xmm1
movss  0xcfb(%rip),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x24(%rbp),%xmm0
movss  -0x28(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Quat2Euler>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movss  0x4(%rdi),%xmm2
movss  0x8(%rdi),%xmm1
movaps %xmm1,%xmm0
mulss  %xmm1,%xmm0
movaps %xmm0,%xmm3
movss  %xmm0,0x4(%rsp)
mulss  0xc(%rdi),%xmm1
movss  (%rdi),%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
addss  %xmm0,%xmm0
mulss  %xmm2,%xmm2
addss  %xmm3,%xmm2
addss  %xmm2,%xmm2
movss  0xe93(%rip),%xmm1
subss  %xmm2,%xmm1
call   1030 <atan2@plt>
movss  %xmm0,(%r14)
movss  0x4(%rbx),%xmm0
mulss  0xc(%rbx),%xmm0
movss  (%rbx),%xmm1
mulss  0x8(%rbx),%xmm1
subss  %xmm0,%xmm1
addss  %xmm1,%xmm1
movss  0xe62(%rip),%xmm2
minss  %xmm1,%xmm2
movss  0xe5a(%rip),%xmm0
maxss  %xmm2,%xmm0
call   1040 <asin@plt>
movss  %xmm0,0x4(%r14)
movss  0x4(%rbx),%xmm1
movss  0xc(%rbx),%xmm2
mulss  0x8(%rbx),%xmm1
movss  (%rbx),%xmm0
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
addss  %xmm0,%xmm0
mulss  %xmm2,%xmm2
addss  0x4(%rsp),%xmm2
addss  %xmm2,%xmm2
movss  0xe12(%rip),%xmm1
subss  %xmm2,%xmm1
call   1030 <atan2@plt>
movss  %xmm0,0x8(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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