#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 euler(double ang1, double ang2, double ang3, double R[3][3]) {
  double s1, s2, s3, c1, c2, c3;
  c1 = cos(ang1);
  c2 = cos(ang2);
  c3 = cos(ang3);
  s1 = sin(ang1);
  s2 = sin(ang2);
  s3 = sin(ang3);
  R[0][0] = c1 * c2 * c3 - s1 * s3;
  R[0][1] = -c1 * c2 * s3 - s1 * c3;
  R[0][2] = c1 * s2;
  R[1][0] = s1 * c2 * c3 + c1 * s3;
  R[1][1] = -s1 * c2 * s3 + c1 * c3;
  R[1][2] = s1 * s2;
  R[2][0] = -s2 * c3;
  R[2][1] = s2 * s3;
  R[2][2] = c2;
}


x86 assembly (clang, -O0):
<euler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x10(%rax)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x20(%rax)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x28(%rax)
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x50(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x30(%rax)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x38(%rax)
movsd  -0x48(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x40(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<euler>:
push   %rbx
sub    $0x60,%rsp
mov    %rdi,%rbx
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x20(%rsp)
call   1040 <cos@plt>
movaps %xmm0,0x40(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
movaps %xmm0,0x50(%rsp)
movsd  0x20(%rsp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movapd 0xe69(%rip),%xmm1
movapd 0x20(%rsp),%xmm14
movapd %xmm14,%xmm8
xorpd  %xmm1,%xmm8
movapd 0x40(%rsp),%xmm10
movapd %xmm10,%xmm5
xorpd  %xmm1,%xmm5
movapd 0x30(%rsp),%xmm9
movapd %xmm9,%xmm12
unpcklpd %xmm9,%xmm12
movapd %xmm10,%xmm4
unpcklpd %xmm5,%xmm4
mulpd  %xmm12,%xmm4
movapd 0x50(%rsp),%xmm2
movapd %xmm2,%xmm5
unpcklpd %xmm0,%xmm5
movapd %xmm10,%xmm6
movapd 0x10(%rsp),%xmm3
mulsd  %xmm3,%xmm6
xorpd  %xmm3,%xmm1
movapd %xmm3,%xmm7
mulsd  %xmm0,%xmm3
movapd %xmm3,%xmm13
unpcklpd %xmm2,%xmm0
movapd %xmm2,%xmm11
movapd %xmm14,%xmm2
unpcklpd %xmm14,%xmm2
mulpd  %xmm0,%xmm2
mulpd  %xmm5,%xmm4
subpd  %xmm2,%xmm4
movupd %xmm4,(%rbx)
movsd  %xmm6,0x10(%rbx)
movapd %xmm14,%xmm4
movapd %xmm14,%xmm2
unpcklpd %xmm8,%xmm2
mulpd  %xmm12,%xmm2
movapd %xmm10,%xmm3
unpcklpd %xmm10,%xmm3
mulpd  %xmm0,%xmm3
mulpd  %xmm5,%xmm2
addpd  %xmm3,%xmm2
movupd %xmm2,0x18(%rbx)
unpcklpd %xmm11,%xmm4
unpcklpd %xmm1,%xmm7
mulpd  %xmm4,%xmm7
movupd %xmm7,0x28(%rbx)
movsd  %xmm13,0x38(%rbx)
movsd  %xmm9,0x40(%rbx)
add    $0x60,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define void @euler(double %0, double %1, double %2, [3 x double]* nocapture writeonly %3) {
%5 = tail call double @cos(double %0)
%6 = tail call double @cos(double %1)
%7 = tail call double @cos(double %2)
%8 = tail call double @sin(double %0)
%9 = tail call double @sin(double %1)
%10 = tail call double @sin(double %2)
%11 = fneg double %8
%12 = fneg double %5
%13 = insertelement <2 x double> poison, double %6, i64 0
%14 = shufflevector <2 x double> %13, <2 x double> poison, <2 x i32> zeroinitializer
%15 = insertelement <2 x double> poison, double %5, i64 0
%16 = insertelement <2 x double> %15, double %12, i64 1
%17 = fmul <2 x double> %14, %16
%18 = insertelement <2 x double> poison, double %10, i64 0
%19 = insertelement <2 x double> %18, double %7, i64 1
%20 = insertelement <2 x double> poison, double %11, i64 0
%21 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> zeroinitializer
%22 = fmul <2 x double> %19, %21
%23 = insertelement <2 x double> poison, double %7, i64 0
%24 = insertelement <2 x double> %23, double %10, i64 1
%25 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %17, <2 x double> %24, <2 x double> %22)
%26 = bitcast [3 x double]* %3 to <2 x double>*
store <2 x double> %25, <2 x double>* %26
%27 = fmul double %5, %9
%28 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 2
store double %27, double* %28
%29 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 1, i64 0
%30 = insertelement <2 x double> poison, double %8, i64 0
%31 = insertelement <2 x double> %30, double %11, i64 1
%32 = fmul <2 x double> %14, %31
%33 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> zeroinitializer
%34 = fmul <2 x double> %33, %19
%35 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %32, <2 x double> %24, <2 x double> %34)
%36 = bitcast double* %29 to <2 x double>*
store <2 x double> %35, <2 x double>* %36
%37 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 1, i64 2
%38 = fneg double %9
%39 = insertelement <2 x double> %30, double %7, i64 1
%40 = insertelement <2 x double> poison, double %9, i64 0
%41 = insertelement <2 x double> %40, double %38, i64 1
%42 = fmul <2 x double> %39, %41
%43 = bitcast double* %37 to <2 x double>*
store <2 x double> %42, <2 x double>* %43
%44 = fmul double %9, %10
%45 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 2, i64 1
store double %44, double* %45
%46 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 2, i64 2
store double %6, double* %46
ret void
}