#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 init_rotation_matrix(double m[3][3], double yaw, double pitch,
                          double roll) {
  double c1 = cos(roll);
  double s1 = sin(roll);
  double c2 = cos(pitch);
  double s2 = sin(pitch);
  double c3 = cos(yaw);
  double s3 = sin(yaw);
  m[0][0] = c2 * c3;
  m[0][1] = c3 * s1 * s2 - c1 * s3;
  m[0][2] = s1 * s3 + c1 * c3 * s2;
  m[1][0] = c2 * s3;
  m[1][1] = c1 * c3 + s1 * s2 * s3;
  m[1][2] = c1 * s2 * s3 - c3 * s1;
  m[2][0] = -s2;
  m[2][1] = c2 * s1;
  m[2][2] = c1 * c2;
}


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

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

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

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