#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 cosf(float);
float sinf(float);
void QuaternionFromEuler(float pfQOut[4], float fRollDeg, float fPitchDeg,
                         float fYawDeg) {
  float fRoll, fPitch, fYaw;
  float fCOSY, fCOSP, fCOSR;
  float fSINY, fSINP, fSINR;
  fRoll = fRollDeg * 3.14159265358979323846 / 180.0;
  fPitch = fPitchDeg * 3.14159265358979323846 / 180.0;
  fYaw = fYawDeg * 3.14159265358979323846 / 180.0;
  fCOSY = cosf(fYaw / 2.0);
  fCOSP = cosf(fPitch / 2.0);
  fCOSR = cosf(fRoll / 2.0);
  fSINY = sinf(fYaw / 2.0);
  fSINP = sinf(fPitch / 2.0);
  fSINR = sinf(fRoll / 2.0);
  pfQOut[0] = fCOSY * fCOSP * fCOSR - fSINY * fSINP * fSINR;
  pfQOut[1] = fSINY * fSINP * fCOSR + fCOSY * fCOSP * fSINR;
  pfQOut[2] = fCOSY * fSINP * fCOSR - fSINY * fCOSP * fSINR;
  pfQOut[3] = fSINY * fCOSP * fCOSR + fCOSY * fSINP * fSINR;
}


x86 assembly (clang, -O0):
<QuaternionFromEuler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xec4(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xeb0(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe9a(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe86(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe70(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe5c(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe36(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe13(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x28(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdf0(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdcd(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdaa(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x34(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd87(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x38(%rbp)
movss  -0x24(%rbp),%xmm0
mulss  -0x28(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm2
movss  -0x30(%rbp),%xmm1
mulss  -0x34(%rbp),%xmm1
mulss  -0x38(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x30(%rbp),%xmm0
mulss  -0x34(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm2
movss  -0x24(%rbp),%xmm1
mulss  -0x28(%rbp),%xmm1
mulss  -0x38(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x24(%rbp),%xmm0
mulss  -0x34(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm2
movss  -0x30(%rbp),%xmm1
mulss  -0x28(%rbp),%xmm1
mulss  -0x38(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x30(%rbp),%xmm0
mulss  -0x28(%rbp),%xmm0
movss  -0x2c(%rbp),%xmm2
movss  -0x24(%rbp),%xmm1
mulss  -0x34(%rbp),%xmm1
mulss  -0x38(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0xc(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<QuaternionFromEuler>:
push   %rbx
sub    $0x60,%rsp
cvtss2sd %xmm0,%xmm0
movsd  0xecf(%rip),%xmm3
mulsd  %xmm3,%xmm0
movsd  0xecb(%rip),%xmm4
divsd  %xmm4,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mulsd  %xmm3,%xmm0
divsd  %xmm4,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
mulsd  %xmm3,%xmm0
divsd  %xmm4,%xmm0
cvtsd2ss %xmm0,%xmm0
mulss  0xe8e(%rip),%xmm0
movss  %xmm0,0x20(%rsp)
call   1040 <cosf@plt>
movaps %xmm0,0x40(%rsp)
movss  0x10(%rsp),%xmm0
mulss  0xe70(%rip),%xmm0
movss  %xmm0,0x10(%rsp)
call   1040 <cosf@plt>
movaps %xmm0,0x30(%rsp)
movss  0xc(%rsp),%xmm0
mulss  0xe52(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
call   1040 <cosf@plt>
movaps %xmm0,0x50(%rsp)
movss  0x20(%rsp),%xmm0
call   1030 <sinf@plt>
movaps %xmm0,0x20(%rsp)
movss  0x10(%rsp),%xmm0
call   1030 <sinf@plt>
movaps %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <sinf@plt>
movaps 0x40(%rsp),%xmm2
movaps %xmm2,%xmm1
movaps 0x30(%rsp),%xmm3
unpcklps %xmm3,%xmm1
movaps 0x20(%rsp),%xmm4
unpcklps %xmm4,%xmm2
movlhps %xmm1,%xmm2
movaps 0x10(%rsp),%xmm1
unpcklps %xmm1,%xmm3
unpcklps %xmm4,%xmm1
movlhps %xmm1,%xmm3
mulps  %xmm2,%xmm3
movaps %xmm3,%xmm1
shufps $0x55,%xmm3,%xmm1
xorps  0xded(%rip),%xmm1
movaps %xmm3,%xmm2
unpckhps %xmm0,%xmm2
shufps $0x0,%xmm0,%xmm0
xorps  0xddc(%rip),%xmm2
unpcklps %xmm3,%xmm1
movhlps %xmm3,%xmm2
shufps $0x24,%xmm2,%xmm1
mulps  %xmm0,%xmm1
movaps 0x50(%rsp),%xmm0
shufps $0x0,%xmm0,%xmm0
mulps  %xmm3,%xmm0
addps  %xmm1,%xmm0
movups %xmm0,(%rbx)
add    $0x60,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define void @QuaternionFromEuler(float* nocapture writeonly %0, float %1, float %2, float %3) {
%5 = fpext float %1 to double
%6 = fmul double %5, 0x400921FB54442D18
%7 = fdiv double %6, 1.800000e+02
%8 = fptrunc double %7 to float
%9 = fpext float %2 to double
%10 = fmul double %9, 0x400921FB54442D18
%11 = fdiv double %10, 1.800000e+02
%12 = fptrunc double %11 to float
%13 = fpext float %3 to double
%14 = fmul double %13, 0x400921FB54442D18
%15 = fdiv double %14, 1.800000e+02
%16 = fptrunc double %15 to float
%17 = fmul float %16, 5.000000e-01
%18 = tail call float @cosf(float %17)
%19 = fmul float %12, 5.000000e-01
%20 = tail call float @cosf(float %19)
%21 = fmul float %8, 5.000000e-01
%22 = tail call float @cosf(float %21)
%23 = tail call float @sinf(float %17)
%24 = tail call float @sinf(float %19)
%25 = tail call float @sinf(float %21)
%26 = insertelement <4 x float> poison, float %18, i64 0
%27 = insertelement <4 x float> %26, float %23, i64 1
%28 = insertelement <4 x float> %27, float %18, i64 2
%29 = insertelement <4 x float> %28, float %20, i64 3
%30 = insertelement <4 x float> poison, float %20, i64 0
%31 = insertelement <4 x float> %30, float %24, i64 1
%32 = insertelement <4 x float> %31, float %24, i64 2
%33 = insertelement <4 x float> %32, float %23, i64 3
%34 = fmul <4 x float> %29, %33
%35 = extractelement <4 x float> %34, i64 1
%36 = fneg float %35
%37 = extractelement <4 x float> %34, i64 3
%38 = fneg float %37
%39 = insertelement <4 x float> poison, float %25, i64 0
%40 = shufflevector <4 x float> %39, <4 x float> poison, <4 x i32> zeroinitializer
%41 = insertelement <4 x float> poison, float %36, i64 0
%42 = extractelement <4 x float> %34, i64 0
%43 = insertelement <4 x float> %41, float %42, i64 1
%44 = insertelement <4 x float> %43, float %38, i64 2
%45 = shufflevector <4 x float> %44, <4 x float> %34, <4 x i32> <i32 0, i32 1, i32 2, i32 6>
%46 = fmul <4 x float> %40, %45
%47 = insertelement <4 x float> poison, float %22, i64 0
%48 = shufflevector <4 x float> %47, <4 x float> poison, <4 x i32> zeroinitializer
%49 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %34, <4 x float> %48, <4 x float> %46)
%50 = bitcast float* %0 to <4 x float>*
store <4 x float> %49, <4 x float>* %50
ret void
}