#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);
int /*<<< orphan*/ quatnormalize(float *, float *);
void quatfromeuler(float *q, const float *euler) {
  float X = euler[0] / 2.0f;
  float Y = euler[1] / 2.0f;
  float Z = euler[2] / 2.0f;
  float cx = cosf(X);
  float sx = cosf(X);
  float cy = cosf(Y);
  float sy = cosf(Y);
  float cz = cosf(Z);
  float sz = cosf(Z);
  q[0] = cx * cy * cz + sx * sy * sz;
  q[1] = sx * cy * cz - cx * sy * sz;
  q[2] = cx * sy * cz + sx * cy * sz;
  q[3] = cx * cy * sz - sx * sy * cz;
  quatnormalize(q, q);
}


x86 assembly (clang, -O0):
<quatfromeuler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movss  0xec0(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  0xea6(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  0xe8c(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
call   1030 <cosf@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
call   1030 <cosf@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x18(%rbp),%xmm0
call   1030 <cosf@plt>
movss  %xmm0,-0x28(%rbp)
movss  -0x18(%rbp),%xmm0
call   1030 <cosf@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1030 <cosf@plt>
movss  %xmm0,-0x30(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1030 <cosf@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    -0x8(%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    -0x8(%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    -0x8(%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    -0x8(%rbp),%rax
movss  %xmm0,0xc(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <quatnormalize@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<quatfromeuler>:
push   %rbx
sub    $0x60,%rsp
mov    %rdi,%rbx
movss  0xed0(%rip),%xmm2
movss  (%rsi),%xmm0
mulss  %xmm2,%xmm0
movss  %xmm0,0x20(%rsp)
movss  0x4(%rsi),%xmm1
mulss  %xmm2,%xmm1
movss  %xmm1,0x10(%rsp)
mulss  0x8(%rsi),%xmm2
movss  %xmm2,0xc(%rsp)
call   1030 <cosf@plt>
movaps %xmm0,0x50(%rsp)
movss  0x20(%rsp),%xmm0
call   1030 <cosf@plt>
movaps %xmm0,0x20(%rsp)
movss  0x10(%rsp),%xmm0
call   1030 <cosf@plt>
movaps %xmm0,0x40(%rsp)
movss  0x10(%rsp),%xmm0
call   1030 <cosf@plt>
movaps %xmm0,0x30(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <cosf@plt>
movaps %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <cosf@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 0xe30(%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)
mov    %rbx,%rdi
mov    %rbx,%rsi
add    $0x60,%rsp
pop    %rbx
jmp    1040 <quatnormalize@plt>

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

LLVM IR (-O2):
define void @quatfromeuler(float* %0, float* nocapture %1) {
%3 = load float, float* %1
%4 = fmul float %3, 5.000000e-01
%5 = getelementptr inbounds float, float* %1, i64 1
%6 = load float, float* %5
%7 = fmul float %6, 5.000000e-01
%8 = getelementptr inbounds float, float* %1, i64 2
%9 = load float, float* %8
%10 = fmul float %9, 5.000000e-01
%11 = tail call float @cosf(float %4)
%12 = tail call float @cosf(float %4)
%13 = tail call float @cosf(float %7)
%14 = tail call float @cosf(float %7)
%15 = tail call float @cosf(float %10)
%16 = tail call float @cosf(float %10)
%17 = fmul float %12, %14
%18 = fmul float %12, %13
%19 = insertelement <2 x float> poison, float %11, i64 0
%20 = shufflevector <2 x float> %19, <2 x float> poison, <2 x i32> zeroinitializer
%21 = insertelement <2 x float> poison, float %14, i64 0
%22 = insertelement <2 x float> %21, float %13, 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 %16, i64 1
%29 = insertelement <4 x float> %28, float %18, i64 2
%30 = insertelement <4 x float> %29, float %15, i64 3
%31 = insertelement <4 x float> poison, float %16, i64 0
%32 = insertelement <4 x float> %31, float %25, i64 1
%33 = insertelement <4 x float> %32, float %16, 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 %15, i64 0
%42 = insertelement <4 x float> %41, float %16, 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* %0 to <4 x float>*
store <4 x float> %44, <4 x float>* %45
%46 = tail call i32 @quatnormalize(float* %0, float* %0)
ret void
}