#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);
float *quat_from_yaw_pitch_roll(float *result, float yaw, float pitch,
                                float roll) {
  float half_roll = roll * 0.5f;
  float half_pitch = pitch * 0.5f;
  float half_yaw = yaw * 0.5f;
  float sin_roll = sinf(half_roll);
  float cos_roll = cosf(half_roll);
  float sin_pitch = sinf(half_pitch);
  float cos_pitch = cosf(half_pitch);
  float sin_yaw = sinf(half_yaw);
  float cos_yaw = cosf(half_yaw);
  result[0] = cos_yaw * sin_pitch * cos_roll + sin_yaw * cos_pitch * sin_roll;
  result[1] = sin_yaw * cos_pitch * cos_roll - cos_yaw * sin_pitch * sin_roll;
  result[2] = cos_yaw * cos_pitch * sin_roll - sin_yaw * sin_pitch * cos_roll;
  result[3] = cos_yaw * cos_pitch * cos_roll + sin_yaw * sin_pitch * sin_roll;
  return result;
}


x86 assembly (clang, -O0):
<quat_from_yaw_pitch_roll>:
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  0xebd(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xeab(%rip),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xe99(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x18(%rbp),%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x28(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x20(%rbp),%xmm0
call   1030 <sinf@plt>
movss  %xmm0,-0x34(%rbp)
movss  -0x20(%rbp),%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
mulss  -0x2c(%rbp),%xmm0
movss  -0x28(%rbp),%xmm2
movss  -0x34(%rbp),%xmm1
mulss  -0x30(%rbp),%xmm1
mulss  -0x24(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x34(%rbp),%xmm0
mulss  -0x30(%rbp),%xmm0
movss  -0x28(%rbp),%xmm2
movss  -0x38(%rbp),%xmm1
mulss  -0x2c(%rbp),%xmm1
mulss  -0x24(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x38(%rbp),%xmm0
mulss  -0x30(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
movss  -0x34(%rbp),%xmm1
mulss  -0x2c(%rbp),%xmm1
mulss  -0x28(%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  -0x38(%rbp),%xmm0
mulss  -0x30(%rbp),%xmm0
movss  -0x28(%rbp),%xmm2
movss  -0x34(%rbp),%xmm1
mulss  -0x2c(%rbp),%xmm1
mulss  -0x24(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0xc(%rax)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quat_from_yaw_pitch_roll>:
push   %rbx
sub    $0x60,%rsp
movaps %xmm2,%xmm3
mov    %rdi,%rbx
movss  0xecd(%rip),%xmm2
mulss  %xmm2,%xmm3
movss  %xmm3,0x20(%rsp)
mulss  %xmm2,%xmm1
movss  %xmm1,0x10(%rsp)
mulss  %xmm2,%xmm0
movss  %xmm0,0xc(%rsp)
movaps %xmm3,%xmm0
call   1030 <sinf@plt>
movaps %xmm0,0x50(%rsp)
movss  0x20(%rsp),%xmm0
call   1040 <cosf@plt>
movaps %xmm0,0x20(%rsp)
movss  0x10(%rsp),%xmm0
call   1030 <sinf@plt>
movaps %xmm0,0x40(%rsp)
movss  0x10(%rsp),%xmm0
call   1040 <cosf@plt>
movaps %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <sinf@plt>
movaps %xmm0,0x30(%rsp)
movss  0xc(%rsp),%xmm0
call   1040 <cosf@plt>
movaps 0x10(%rsp),%xmm2
shufps $0x0,%xmm2,%xmm2
movaps 0x30(%rsp),%xmm3
movaps %xmm3,%xmm1
unpcklps %xmm0,%xmm1
mulps  %xmm2,%xmm1
movaps 0x40(%rsp),%xmm2
shufps $0x0,%xmm2,%xmm2
unpcklps %xmm3,%xmm0
mulps  %xmm2,%xmm0
movaps 0xe3a(%rip),%xmm2
xorps  %xmm0,%xmm2
movaps 0x50(%rsp),%xmm5
movaps %xmm5,%xmm3
movaps 0x20(%rsp),%xmm6
unpcklps %xmm6,%xmm3
shufps $0x10,%xmm3,%xmm3
movaps %xmm0,%xmm4
movlhps %xmm1,%xmm0
shufps $0x58,%xmm1,%xmm0
movlhps %xmm2,%xmm1
shufps $0x55,%xmm2,%xmm4
shufps $0x28,%xmm4,%xmm1
mulps  %xmm3,%xmm1
movaps %xmm6,%xmm2
unpcklps %xmm5,%xmm2
shufps $0x10,%xmm2,%xmm2
mulps  %xmm0,%xmm2
addps  %xmm1,%xmm2
movups %xmm2,(%rbx)
mov    %rbx,%rax
add    $0x60,%rsp
pop    %rbx
ret

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

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