#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);
int eu2quf(float *eu, float *q, int p) {
  float phi1, phi, phi2, dphi1phi2, sphi1phi2, cphi, sphi, sign = 0.0f;
  float epsijk;
  epsijk = (float)p;
  phi1 = eu[0] / 2.0f;
  phi = eu[1] / 2.0f;
  phi2 = eu[2] / 2.0f;
  dphi1phi2 = phi1 - phi2;
  sphi1phi2 = phi1 + phi2;
  cphi = cosf(phi);
  sphi = -1.0f * sinf(phi);
  q[0] = cphi * cosf(sphi1phi2) + 0.0f;
  sign = ((q[0] >= 0.0) ? 1.0f : -1.0f);
  q[0] *= sign;
  q[1] = epsijk * sign * sphi * cosf(dphi1phi2) + 0.0f;
  q[2] = epsijk * sign * sphi * sinf(dphi1phi2) + 0.0f;
  q[3] = -1.0f * epsijk * sign * cphi * sinf(sphi1phi2) + 0.0f;
  return 1;
}


x86 assembly (clang, -O0):
<eu2quf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movss  0xeb3(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  0xe99(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  0xe7f(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
subss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x18(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1040 <cosf@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1030 <sinf@plt>
movaps %xmm0,%xmm1
movss  0xe2c(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x28(%rbp),%xmm0
call   1040 <cosf@plt>
movaps %xmm0,%xmm1
movss  -0x44(%rbp),%xmm0
mulss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
addss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm2,%xmm2
movss  0xde1(%rip),%xmm0
movss  0xdd5(%rip),%xmm3
movss  %xmm3,-0x40(%rbp)
ucomisd %xmm2,%xmm1
movss  %xmm0,-0x3c(%rbp)
jae    1249 <eu2quf+0x129>
movss  -0x40(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x34(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulss  (%rax),%xmm0
movss  %xmm0,(%rax)
movss  -0x38(%rbp),%xmm0
mulss  -0x34(%rbp),%xmm0
mulss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x50(%rbp)
movss  -0x24(%rbp),%xmm0
call   1040 <cosf@plt>
movaps %xmm0,%xmm1
movss  -0x50(%rbp),%xmm0
mulss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
addss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x38(%rbp),%xmm0
mulss  -0x34(%rbp),%xmm0
mulss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
movss  -0x24(%rbp),%xmm0
call   1030 <sinf@plt>
movaps %xmm0,%xmm1
movss  -0x4c(%rbp),%xmm0
mulss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
addss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  0xd20(%rip),%xmm0
mulss  -0x38(%rbp),%xmm0
mulss  -0x34(%rbp),%xmm0
mulss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
movss  -0x28(%rbp),%xmm0
call   1030 <sinf@plt>
movaps %xmm0,%xmm1
movss  -0x48(%rbp),%xmm0
mulss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
addss  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,0xc(%rax)
mov    $0x1,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eu2quf>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
cvtsi2ss %edx,%xmm0
movss  %xmm0,(%rsp)
movss  0xec7(%rip),%xmm1
movss  (%rdi),%xmm3
mulss  %xmm1,%xmm3
movss  0x4(%rdi),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,0x10(%rsp)
mulss  0x8(%rdi),%xmm1
movaps %xmm3,%xmm2
subss  %xmm1,%xmm2
movss  %xmm2,0x4(%rsp)
addss  %xmm3,%xmm1
movss  %xmm1,0xc(%rsp)
call   1040 <cosf@plt>
movss  %xmm0,0x8(%rsp)
movss  0x10(%rsp),%xmm0
call   1030 <sinf@plt>
xorps  0xe87(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movss  0xc(%rsp),%xmm0
call   1040 <cosf@plt>
mulss  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
addss  %xmm1,%xmm0
xor    %eax,%eax
ucomiss %xmm1,%xmm0
setae  %al
lea    0xe6b(%rip),%rcx
movss  (%rcx,%rax,4),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,(%rbx)
movss  (%rsp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,(%rsp)
movaps 0x10(%rsp),%xmm1
mulss  %xmm0,%xmm1
movaps %xmm1,0x10(%rsp)
movss  0x4(%rsp),%xmm0
call   1040 <cosf@plt>
mulss  0x10(%rsp),%xmm0
addss  0xe0d(%rip),%xmm0
movss  %xmm0,0x4(%rbx)
movss  0x4(%rsp),%xmm0
call   1030 <sinf@plt>
mulss  0x10(%rsp),%xmm0
addss  0xdef(%rip),%xmm0
movss  %xmm0,0x8(%rbx)
movss  (%rsp),%xmm0
mulss  0x8(%rsp),%xmm0
movss  %xmm0,(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <sinf@plt>
mulss  (%rsp),%xmm0
xorps  %xmm1,%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,0xc(%rbx)
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @eu2quf(float* nocapture %0, float* nocapture writeonly %1, i32 %2) {
%4 = sitofp i32 %2 to float
%5 = load float, float* %0
%6 = fmul float %5, 5.000000e-01
%7 = getelementptr inbounds float, float* %0, i64 1
%8 = load float, float* %7
%9 = fmul float %8, 5.000000e-01
%10 = getelementptr inbounds float, float* %0, i64 2
%11 = load float, float* %10
%12 = fmul float %11, 5.000000e-01
%13 = fsub float %6, %12
%14 = fadd float %6, %12
%15 = tail call float @cosf(float %9)
%16 = tail call float @sinf(float %9)
%17 = fneg float %16
%18 = tail call float @cosf(float %14)
%19 = tail call float @llvm.fmuladd.f32(float %15, float %18, float 0.000000e+00)
%20 = fcmp oge float %19, 0.000000e+00
%21 = select i1 %20, float 1.000000e+00, float -1.000000e+00
%22 = fmul float %19, %21
store float %22, float* %1
%23 = fmul float %21, %4
%24 = fmul float %23, %17
%25 = tail call float @cosf(float %13)
%26 = tail call float @llvm.fmuladd.f32(float %24, float %25, float 0.000000e+00)
%27 = getelementptr inbounds float, float* %1, i64 1
store float %26, float* %27
%28 = tail call float @sinf(float %13)
%29 = tail call float @llvm.fmuladd.f32(float %24, float %28, float 0.000000e+00)
%30 = getelementptr inbounds float, float* %1, i64 2
store float %29, float* %30
%31 = fneg float %4
%32 = fmul float %21, %31
%33 = fmul float %15, %32
%34 = tail call float @sinf(float %14)
%35 = tail call float @llvm.fmuladd.f32(float %33, float %34, float 0.000000e+00)
%36 = getelementptr inbounds float, float* %1, i64 3
store float %35, float* %36
ret i32 1
}