#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 */
double cos(double);
double sin(double);
void eul2quat(double *q, double phi, double the, double psi) {
  phi = phi / 2.0;
  the = the / 2.0;
  psi = psi / 2.0;
  q[0] = cos(psi) * cos(the) * cos(phi) + sin(psi) * sin(the) * sin(phi);
  q[1] = cos(psi) * cos(the) * sin(phi) - sin(psi) * sin(the) * cos(phi);
  q[2] = cos(psi) * sin(the) * cos(phi) + sin(psi) * cos(the) * sin(phi);
  q[3] = sin(psi) * cos(the) * cos(phi) - cos(psi) * sin(the) * sin(phi);
}


x86 assembly (clang, -O0):
<eul2quat>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xeb5(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe9f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe89(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xc0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0xb8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0xb0(%rbp),%xmm1
ff
movsd  -0xa8(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0xa0(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x98(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x90(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  -0x88(%rbp),%xmm1
ff
movsd  -0x80(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x78(%rbp),%xmm0
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x60(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x20(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm3,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%rax)
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eul2quat>:
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%rbx
movsd  0xed0(%rip),%xmm3
mulsd  %xmm3,%xmm0
movsd  %xmm0,0x28(%rsp)
mulsd  %xmm3,%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  %xmm2,%xmm3
movsd  %xmm3,0x20(%rsp)
movapd %xmm3,%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x20(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x28(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x18(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx)
movsd  0x20(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x20(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x38(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <cos@plt>
movsd  0x38(%rsp),%xmm1
mulsd  0x18(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x30(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rbx)
movsd  0x20(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x20(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x28(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x18(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rbx)
movsd  0x20(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x20(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x28(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x10(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x30(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rbx)
add    $0x40,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define void @eul2quat(double* nocapture writeonly %0, double %1, double %2, double %3) {
%5 = fmul double %1, 5.000000e-01
%6 = fmul double %2, 5.000000e-01
%7 = fmul double %3, 5.000000e-01
%8 = tail call double @cos(double %7)
%9 = tail call double @cos(double %6)
%10 = fmul double %8, %9
%11 = tail call double @cos(double %5)
%12 = tail call double @sin(double %7)
%13 = tail call double @sin(double %6)
%14 = fmul double %12, %13
%15 = tail call double @sin(double %5)
%16 = fmul double %14, %15
%17 = tail call double @llvm.fmuladd.f64(double %10, double %11, double %16)
store double %17, double* %0
%18 = tail call double @cos(double %7)
%19 = tail call double @cos(double %6)
%20 = fmul double %18, %19
%21 = tail call double @sin(double %5)
%22 = tail call double @sin(double %7)
%23 = tail call double @sin(double %6)
%24 = tail call double @cos(double %5)
%25 = fneg double %22
%26 = fmul double %23, %25
%27 = fmul double %26, %24
%28 = tail call double @llvm.fmuladd.f64(double %20, double %21, double %27)
%29 = getelementptr inbounds double, double* %0, i64 1
store double %28, double* %29
%30 = tail call double @cos(double %7)
%31 = tail call double @sin(double %6)
%32 = fmul double %30, %31
%33 = tail call double @cos(double %5)
%34 = tail call double @sin(double %7)
%35 = tail call double @cos(double %6)
%36 = fmul double %34, %35
%37 = tail call double @sin(double %5)
%38 = fmul double %36, %37
%39 = tail call double @llvm.fmuladd.f64(double %32, double %33, double %38)
%40 = getelementptr inbounds double, double* %0, i64 2
store double %39, double* %40
%41 = tail call double @sin(double %7)
%42 = tail call double @cos(double %6)
%43 = fmul double %41, %42
%44 = tail call double @cos(double %5)
%45 = tail call double @cos(double %7)
%46 = tail call double @sin(double %6)
%47 = tail call double @sin(double %5)
%48 = fneg double %45
%49 = fmul double %46, %48
%50 = fmul double %49, %47
%51 = tail call double @llvm.fmuladd.f64(double %43, double %44, double %50)
%52 = getelementptr inbounds double, double* %0, i64 3
store double %51, double* %52
ret void
}