#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 EulerAngles(double *rotM, double phi, double theta, double psi) {
  *(rotM + 0) = cos(psi) * cos(phi) - cos(theta) * sin(phi) * sin(psi);
  *(rotM + 1) = cos(psi) * sin(phi) + cos(theta) * cos(phi) * sin(psi);
  *(rotM + 2) = sin(psi) * sin(theta);
  *(rotM + 3) = -sin(psi) * cos(phi) - cos(theta) * sin(phi) * cos(psi);
  *(rotM + 4) = -sin(psi) * sin(phi) + cos(theta) * cos(phi) * cos(psi);
  *(rotM + 5) = cos(psi) * sin(theta);
  *(rotM + 6) = sin(theta) * sin(phi);
  *(rotM + 7) = -sin(theta) * cos(phi);
  *(rotM + 8) = cos(theta);
  return;
}


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

x86 assembly (clang, -O2):
<EulerAngles>:
push   %rbx
sub    $0x60,%rsp
movsd  %xmm2,0x20(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x10(%rsp)
mov    %rdi,%rbx
movaps %xmm2,%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x40(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x38(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x58(%rsp)
movsd  0x20(%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x58(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x38(%rsp),%xmm0
mulsd  0x40(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rbx)
movsd  0x20(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x40(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x38(%rsp)
movsd  0x18(%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  0x20(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
mulsd  0x40(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rbx)
movsd  0x20(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x40(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x40(%rsp),%xmm0
movsd  %xmm0,0x10(%rbx)
movsd  0x20(%rsp),%xmm0
call   1030 <sin@plt>
xorps  0xdad(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x38(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x58(%rsp)
movsd  0x20(%rsp),%xmm0
call   1040 <cos@plt>
movsd  0x58(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x38(%rsp),%xmm0
mulsd  0x40(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rbx)
movsd  0x20(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x40(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x38(%rsp)
movsd  0x18(%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  0x20(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
mulsd  0x40(%rsp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x20(%rbx)
movsd  0x20(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x28(%rbx)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x30(%rbx)
movsd  0x18(%rsp),%xmm0
call   1030 <sin@plt>
xorps  0xc75(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x38(%rbx)
movsd  0x18(%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x40(%rbx)
add    $0x60,%rsp
pop    %rbx
ret

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

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