#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 cos(float);
float sin(float);
void floats_rpy_to_quat(const float rpy[3], float quat[4]) {
  float roll = rpy[0], pitch = rpy[1], yaw = rpy[2];
  float halfroll = roll / 2;
  float halfpitch = pitch / 2;
  float halfyaw = yaw / 2;
  float sin_r2 = sin(halfroll);
  float sin_p2 = sin(halfpitch);
  float sin_y2 = sin(halfyaw);
  float cos_r2 = cos(halfroll);
  float cos_p2 = cos(halfpitch);
  float cos_y2 = cos(halfyaw);
  quat[0] = cos_r2 * cos_p2 * cos_y2 + sin_r2 * sin_p2 * sin_y2;
  quat[1] = sin_r2 * cos_p2 * cos_y2 - cos_r2 * sin_p2 * sin_y2;
  quat[2] = cos_r2 * sin_p2 * cos_y2 + sin_r2 * cos_p2 * sin_y2;
  quat[3] = cos_r2 * cos_p2 * sin_y2 - sin_r2 * sin_p2 * cos_y2;
}


x86 assembly (clang, -O0):
<floats_rpy_to_quat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
movss  0xe9a(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
movss  0xe84(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  0xe6e(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x24(%rbp),%xmm0
call   1030 <sin@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x28(%rbp),%xmm0
call   1030 <sin@plt>
movss  %xmm0,-0x34(%rbp)
movss  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movss  %xmm0,-0x38(%rbp)
movss  -0x24(%rbp),%xmm0
call   1040 <cos@plt>
movss  %xmm0,-0x3c(%rbp)
movss  -0x28(%rbp),%xmm0
call   1040 <cos@plt>
movss  %xmm0,-0x40(%rbp)
movss  -0x38(%rbp),%xmm0
mulss  -0x3c(%rbp),%xmm0
movss  -0x40(%rbp),%xmm2
movss  -0x2c(%rbp),%xmm1
mulss  -0x30(%rbp),%xmm1
mulss  -0x34(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x2c(%rbp),%xmm0
mulss  -0x3c(%rbp),%xmm0
movss  -0x40(%rbp),%xmm2
movss  -0x38(%rbp),%xmm1
mulss  -0x30(%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  -0x38(%rbp),%xmm0
mulss  -0x30(%rbp),%xmm0
movss  -0x40(%rbp),%xmm2
movss  -0x2c(%rbp),%xmm1
mulss  -0x3c(%rbp),%xmm1
mulss  -0x34(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  -0x38(%rbp),%xmm0
mulss  -0x3c(%rbp),%xmm0
movss  -0x34(%rbp),%xmm2
movss  -0x2c(%rbp),%xmm1
mulss  -0x30(%rbp),%xmm1
mulss  -0x40(%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)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floats_rpy_to_quat>:
push   %rbx
sub    $0x60,%rsp
mov    %rsi,%rbx
movss  0xed0(%rip),%xmm2
movss  (%rdi),%xmm0
mulss  %xmm2,%xmm0
movss  %xmm0,0x20(%rsp)
movss  0x4(%rdi),%xmm1
mulss  %xmm2,%xmm1
movss  %xmm1,0x10(%rsp)
mulss  0x8(%rdi),%xmm2
movss  %xmm2,0xc(%rsp)
call   1030 <sin@plt>
movaps %xmm0,0x40(%rsp)
movss  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,0x30(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,0x50(%rsp)
movss  0x20(%rsp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,0x20(%rsp)
movss  0x10(%rsp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1040 <cos@plt>
movaps 0x40(%rsp),%xmm2
movaps %xmm2,%xmm1
movaps 0x30(%rsp),%xmm5
mulss  %xmm5,%xmm1
movaps 0x10(%rsp),%xmm3
mulss  %xmm3,%xmm2
movaps %xmm2,%xmm4
movaps 0x20(%rsp),%xmm2
shufps $0x0,%xmm2,%xmm2
unpcklps %xmm3,%xmm5
mulps  %xmm2,%xmm5
movaps 0xe30(%rip),%xmm2
movaps %xmm5,%xmm3
xorps  %xmm2,%xmm3
xorps  %xmm1,%xmm2
unpcklps %xmm3,%xmm1
movaps 0x50(%rsp),%xmm6
movaps %xmm6,%xmm3
unpcklps %xmm0,%xmm3
movlhps %xmm3,%xmm1
movaps %xmm4,%xmm3
unpcklps %xmm2,%xmm3
movaps %xmm6,%xmm2
unpcklps %xmm6,%xmm0
shufps $0x40,%xmm3,%xmm2
mulps  %xmm1,%xmm2
movaps %xmm4,%xmm1
shufps $0xd4,%xmm5,%xmm1
shufps $0x42,%xmm5,%xmm1
shufps $0x40,%xmm0,%xmm0
mulps  %xmm1,%xmm0
addps  %xmm2,%xmm0
movups %xmm0,(%rbx)
add    $0x60,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define void @floats_rpy_to_quat(float* nocapture %0, float* nocapture writeonly %1) {
%3 = load float, float* %0
%4 = getelementptr inbounds float, float* %0, i64 1
%5 = load float, float* %4
%6 = getelementptr inbounds float, float* %0, i64 2
%7 = load float, float* %6
%8 = fmul float %3, 5.000000e-01
%9 = fmul float %5, 5.000000e-01
%10 = fmul float %7, 5.000000e-01
%11 = tail call float @sin(float %8)
%12 = tail call float @sin(float %9)
%13 = tail call float @sin(float %10)
%14 = tail call float @cos(float %8)
%15 = tail call float @cos(float %9)
%16 = tail call float @cos(float %10)
%17 = fmul float %11, %12
%18 = fmul float %11, %15
%19 = insertelement <2 x float> poison, float %14, i64 0
%20 = shufflevector <2 x float> %19, <2 x float> poison, <2 x i32> zeroinitializer
%21 = insertelement <2 x float> poison, float %12, i64 0
%22 = insertelement <2 x float> %21, float %15, i64 1
%23 = fmul <2 x float> %20, %22
%24 = extractelement <2 x float> %23, i64 0
%25 = fneg float %24
%26 = fneg float %17
%27 = insertelement <4 x float> poison, float %17, i64 0
%28 = insertelement <4 x float> %27, float %25, i64 1
%29 = insertelement <4 x float> %28, float %13, i64 2
%30 = insertelement <4 x float> %29, float %16, i64 3
%31 = insertelement <4 x float> poison, float %13, i64 0
%32 = insertelement <4 x float> %31, float %13, i64 1
%33 = insertelement <4 x float> %32, float %18, i64 2
%34 = insertelement <4 x float> %33, float %26, i64 3
%35 = fmul <4 x float> %30, %34
%36 = extractelement <2 x float> %23, i64 1
%37 = insertelement <4 x float> poison, float %36, i64 0
%38 = insertelement <4 x float> %37, float %18, i64 1
%39 = shufflevector <2 x float> %23, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
%40 = shufflevector <4 x float> %38, <4 x float> %39, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
%41 = insertelement <4 x float> poison, float %16, i64 0
%42 = insertelement <4 x float> %41, float %13, i64 1
%43 = shufflevector <4 x float> %42, <4 x float> poison, <4 x i32> <i32 0, i32 0, i32 0, i32 1>
%44 = call <4 x float> @llvm.fmuladd.v4f32(<4 x float> %40, <4 x float> %43, <4 x float> %35)
%45 = bitcast float* %1 to <4 x float>*
store <4 x float> %44, <4 x float>* %45
ret void
}