#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 RPY2Quaternion(const float rpy[3], float q[4]) {
  float phi, theta, psi;
  float cphi, sphi, ctheta, stheta, cpsi, spsi;
  phi = (3.14159265358979323846f / 180.0f) * rpy[0] / 2;
  theta = (3.14159265358979323846f / 180.0f) * rpy[1] / 2;
  psi = (3.14159265358979323846f / 180.0f) * rpy[2] / 2;
  cphi = cosf(phi);
  sphi = sinf(phi);
  ctheta = cosf(theta);
  stheta = sinf(theta);
  cpsi = cosf(psi);
  spsi = sinf(psi);
  q[0] = cphi * ctheta * cpsi + sphi * stheta * spsi;
  q[1] = sphi * ctheta * cpsi - cphi * stheta * spsi;
  q[2] = cphi * stheta * cpsi + sphi * ctheta * spsi;
  q[3] = cphi * ctheta * spsi - sphi * stheta * cpsi;
  if (q[0] < 0) {
    q[0] = -q[0];
    q[1] = -q[1];
    q[2] = -q[2];
    q[3] = -q[3];
  }
}


x86 assembly (clang, -O0):
<RPY2Quaternion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movss  0xec8(%rip),%xmm0
mulss  (%rax),%xmm0
movss  0xeb8(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movss  0xea7(%rip),%xmm0
mulss  0x4(%rax),%xmm0
movss  0xe96(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  0xe85(%rip),%xmm0
mulss  0x8(%rax),%xmm0
movss  0xe74(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x18(%rbp),%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x28(%rbp)
movss  -0x18(%rbp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x34(%rbp)
movss  -0x20(%rbp),%xmm0
mulss  -0x28(%rbp),%xmm0
movss  -0x30(%rbp),%xmm2
movss  -0x24(%rbp),%xmm1
mulss  -0x2c(%rbp),%xmm1
mulss  -0x34(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x24(%rbp),%xmm0
mulss  -0x28(%rbp),%xmm0
movss  -0x30(%rbp),%xmm2
movss  -0x20(%rbp),%xmm1
mulss  -0x2c(%rbp),%xmm1
mulss  -0x34(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x20(%rbp),%xmm0
mulss  -0x2c(%rbp),%xmm0
movss  -0x30(%rbp),%xmm2
movss  -0x24(%rbp),%xmm1
mulss  -0x28(%rbp),%xmm1
mulss  -0x34(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x20(%rbp),%xmm0
mulss  -0x28(%rbp),%xmm0
movss  -0x34(%rbp),%xmm2
movss  -0x24(%rbp),%xmm1
mulss  -0x2c(%rbp),%xmm1
mulss  -0x30(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0xc(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
ucomiss (%rax),%xmm0
jbe    134e <RPY2Quaternion+0x22e>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movss  0xc(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0xc(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RPY2Quaternion>:
push   %rbx
sub    $0x60,%rsp
mov    %rsi,%rbx
movss  0xed0(%rip),%xmm1
movss  (%rdi),%xmm2
mulss  %xmm1,%xmm2
movss  0xec4(%rip),%xmm3
mulss  %xmm3,%xmm2
movaps %xmm2,%xmm0
movss  %xmm2,0x20(%rsp)
movss  0x4(%rdi),%xmm2
mulss  %xmm1,%xmm2
mulss  %xmm3,%xmm2
movss  %xmm2,0x10(%rsp)
mulss  0x8(%rdi),%xmm1
mulss  %xmm3,%xmm1
movss  %xmm1,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   1040 <cosf@plt>
movaps %xmm0,0x40(%rsp)
movss  0x10(%rsp),%xmm0
call   1030 <sinf@plt>
movaps %xmm0,0x30(%rsp)
movss  0xc(%rsp),%xmm0
call   1040 <cosf@plt>
movaps %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <sinf@plt>
movaps 0x20(%rsp),%xmm2
movaps %xmm2,%xmm1
movaps 0x30(%rsp),%xmm4
mulss  %xmm4,%xmm1
movaps 0x40(%rsp),%xmm3
mulss  %xmm3,%xmm2
movaps %xmm2,%xmm5
movaps 0x50(%rsp),%xmm2
shufps $0x0,%xmm2,%xmm2
unpcklps %xmm3,%xmm4
mulps  %xmm2,%xmm4
movaps 0xe19(%rip),%xmm2
movaps %xmm4,%xmm3
movaps %xmm4,%xmm6
xorps  %xmm2,%xmm3
xorps  %xmm1,%xmm2
movaps %xmm5,%xmm4
movaps 0x10(%rsp),%xmm7
unpcklps %xmm7,%xmm4
unpcklps %xmm0,%xmm1
movlhps %xmm4,%xmm1
movaps %xmm0,%xmm4
unpcklps %xmm2,%xmm4
unpcklps %xmm0,%xmm7
movaps %xmm7,%xmm2
unpcklps %xmm3,%xmm0
movlhps %xmm4,%xmm0
mulps  %xmm1,%xmm0
movaps %xmm5,%xmm1
shufps $0xd4,%xmm6,%xmm1
shufps $0x42,%xmm6,%xmm1
shufps $0x40,%xmm7,%xmm2
mulps  %xmm1,%xmm2
addps  %xmm0,%xmm2
movups %xmm2,(%rbx)
xorps  %xmm0,%xmm0
ucomiss %xmm2,%xmm0
jbe    1256 <RPY2Quaternion+0x136>
movaps %xmm2,%xmm0
xorps  0xdbd(%rip),%xmm0
movups %xmm0,(%rbx)
add    $0x60,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define void @RPY2Quaternion(float* nocapture %0, float* nocapture %1) {
%3 = load float, float* %0
%4 = fmul float %3, 0x3F91DF46A0000000
%5 = fmul float %4, 5.000000e-01
%6 = getelementptr inbounds float, float* %0, i64 1
%7 = load float, float* %6
%8 = fmul float %7, 0x3F91DF46A0000000
%9 = fmul float %8, 5.000000e-01
%10 = getelementptr inbounds float, float* %0, i64 2
%11 = load float, float* %10
%12 = fmul float %11, 0x3F91DF46A0000000
%13 = fmul float %12, 5.000000e-01
%14 = tail call float @cosf(float %5)
%15 = tail call float @sinf(float %5)
%16 = tail call float @cosf(float %9)
%17 = tail call float @sinf(float %9)
%18 = tail call float @cosf(float %13)
%19 = tail call float @sinf(float %13)
%20 = fmul float %15, %17
%21 = fmul float %15, %16
%22 = insertelement <2 x float> poison, float %14, i64 0
%23 = shufflevector <2 x float> %22, <2 x float> poison, <2 x i32> zeroinitializer
%24 = insertelement <2 x float> poison, float %17, i64 0
%25 = insertelement <2 x float> %24, float %16, i64 1
%26 = fmul <2 x float> %23, %25
%27 = extractelement <2 x float> %26, i64 0
%28 = fneg float %27
%29 = fneg float %20
%30 = insertelement <4 x float> poison, float %20, i64 0
%31 = insertelement <4 x float> %30, float %19, i64 1
%32 = insertelement <4 x float> %31, float %21, i64 2
%33 = insertelement <4 x float> %32, float %18, i64 3
%34 = insertelement <4 x float> poison, float %19, i64 0
%35 = insertelement <4 x float> %34, float %28, i64 1
%36 = insertelement <4 x float> %35, float %19, i64 2
%37 = insertelement <4 x float> %36, float %29, i64 3
%38 = fmul <4 x float> %33, %37
%39 = extractelement <2 x float> %26, i64 1
%40 = insertelement <4 x float> poison, float %39, i64 0
%41 = insertelement <4 x float> %40, float %21, i64 1
%42 = shufflevector <2 x float> %26, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%43 = shufflevector <4 x float> %41, <4 x float> %42, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
%44 = insertelement <4 x float> poison, float %18, i64 0
%45 = insertelement <4 x float> %44, float %19, i64 1
%46 = shufflevector <4 x float> %45, <4 x float> poison, <4 x i32> <i32 0, i32 0, i32 0, i32 1>
%47 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %43, <4 x float> %46, <4 x float> %38)
%48 = bitcast float* %1 to <4 x float>*
store <4 x float> %47, <4 x float>* %48
%49 = extractelement <4 x float> %47, i64 0
%50 = fcmp olt float %49, 0.000000e+00
br i1 %50, label %51, label %54
51: ; preds = %2
%52 = fneg <4 x float> %47
%53 = bitcast float* %1 to <4 x float>*
store <4 x float> %52, <4 x float>* %53
br label %54
54: ; preds = %51, %2
ret void
}