#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 rotmatrix(double M[3][3], double rot[3]) {
  double c[3] = {cos(rot[0]), cos(rot[1]), cos(rot[2])};
  double s[3] = {sin(rot[0]), sin(rot[1]), sin(rot[2])};
  M[0][0] = c[2] * c[1];
  M[0][1] = c[2] * s[1] * s[0] - s[2] * c[0];
  M[0][2] = c[2] * s[1] * c[0] + s[2] * s[0];
  M[1][0] = s[2] * c[1];
  M[1][1] = s[2] * s[1] * s[0] + c[2] * c[0];
  M[1][2] = s[2] * s[1] * c[0] - c[2] * s[0];
  M[2][0] = -s[2];
  M[2][1] = c[1] * s[0];
  M[2][2] = c[2] * c[0];
}


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

x86 assembly (clang, -O2):
<rotmatrix>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movsd  (%rsi),%xmm0
call   1040 <cos@plt>
movaps %xmm0,0x40(%rsp)
movsd  0x8(%rbx),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rbx),%xmm0
call   1040 <cos@plt>
movaps %xmm0,0x20(%rsp)
movsd  (%rbx),%xmm0
call   1030 <sin@plt>
movaps %xmm0,0x30(%rsp)
movsd  0x8(%rbx),%xmm0
call   1030 <sin@plt>
movaps %xmm0,0x10(%rsp)
movsd  0x10(%rbx),%xmm0
call   1030 <sin@plt>
movsd  0x8(%rsp),%xmm6
movapd %xmm6,%xmm1
movapd 0x20(%rsp),%xmm3
mulsd  %xmm3,%xmm1
movsd  %xmm1,(%r14)
movapd %xmm3,%xmm2
movapd %xmm3,%xmm9
movapd 0x10(%rsp),%xmm10
mulsd  %xmm10,%xmm2
movapd 0xe49(%rip),%xmm3
movapd %xmm0,%xmm1
xorpd  %xmm3,%xmm1
movapd 0x30(%rsp),%xmm5
movapd %xmm5,%xmm4
movapd 0x40(%rsp),%xmm7
unpcklpd %xmm7,%xmm4
unpcklpd %xmm5,%xmm7
movapd %xmm5,%xmm8
movapd %xmm1,%xmm5
unpcklpd %xmm0,%xmm5
mulpd  %xmm7,%xmm5
unpcklpd %xmm2,%xmm2
mulpd  %xmm4,%xmm2
addpd  %xmm5,%xmm2
movupd %xmm2,0x8(%r14)
movapd %xmm6,%xmm2
mulsd  %xmm0,%xmm2
movsd  %xmm2,0x18(%r14)
movapd %xmm10,%xmm5
mulsd  %xmm0,%xmm5
movapd %xmm9,%xmm0
xorpd  %xmm9,%xmm3
unpcklpd %xmm3,%xmm0
mulpd  %xmm7,%xmm0
unpcklpd %xmm5,%xmm5
mulpd  %xmm4,%xmm5
addpd  %xmm0,%xmm5
movapd %xmm0,%xmm2
movupd %xmm5,0x20(%r14)
movlpd %xmm1,0x30(%r14)
movapd %xmm6,%xmm0
mulsd  %xmm8,%xmm0
movsd  %xmm0,0x38(%r14)
movlpd %xmm2,0x40(%r14)
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @rotmatrix([3 x double]* %0, double* %1) {
%3 = alloca [3 x double]*
%4 = alloca double*
%5 = alloca [3 x double]
%6 = alloca [3 x double]
store [3 x double]* %0, [3 x double]** %3
store double* %1, double** %4
%7 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%8 = load double*, double** %4
%9 = getelementptr inbounds double, double* %8, i64 0
%10 = load double, double* %9
%11 = call double @cos(double %10)
store double %11, double* %7
%12 = getelementptr inbounds double, double* %7, i64 1
%13 = load double*, double** %4
%14 = getelementptr inbounds double, double* %13, i64 1
%15 = load double, double* %14
%16 = call double @cos(double %15)
store double %16, double* %12
%17 = getelementptr inbounds double, double* %12, i64 1
%18 = load double*, double** %4
%19 = getelementptr inbounds double, double* %18, i64 2
%20 = load double, double* %19
%21 = call double @cos(double %20)
store double %21, double* %17
%22 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%23 = load double*, double** %4
%24 = getelementptr inbounds double, double* %23, i64 0
%25 = load double, double* %24
%26 = call double @sin(double %25)
store double %26, double* %22
%27 = getelementptr inbounds double, double* %22, i64 1
%28 = load double*, double** %4
%29 = getelementptr inbounds double, double* %28, i64 1
%30 = load double, double* %29
%31 = call double @sin(double %30)
store double %31, double* %27
%32 = getelementptr inbounds double, double* %27, i64 1
%33 = load double*, double** %4
%34 = getelementptr inbounds double, double* %33, i64 2
%35 = load double, double* %34
%36 = call double @sin(double %35)
store double %36, double* %32
%37 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%38 = load double, double* %37
%39 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
%40 = load double, double* %39
%41 = fmul double %38, %40
%42 = load [3 x double]*, [3 x double]** %3
%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 0
store double %41, double* %44
%45 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%46 = load double, double* %45
%47 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 1
%48 = load double, double* %47
%49 = fmul double %46, %48
%50 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%51 = load double, double* %50
%52 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
%53 = load double, double* %52
%54 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%55 = load double, double* %54
%56 = fmul double %53, %55
%57 = fneg double %56
%58 = call double @llvm.fmuladd.f64(double %49, double %51, double %57)
%59 = load [3 x double]*, [3 x double]** %3
%60 = getelementptr inbounds [3 x double], [3 x double]* %59, i64 0
%61 = getelementptr inbounds [3 x double], [3 x double]* %60, i64 0, i64 1
store double %58, double* %61
%62 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%63 = load double, double* %62
%64 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 1
%65 = load double, double* %64
%66 = fmul double %63, %65
%67 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%68 = load double, double* %67
%69 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
%70 = load double, double* %69
%71 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%72 = load double, double* %71
%73 = fmul double %70, %72
%74 = call double @llvm.fmuladd.f64(double %66, double %68, double %73)
%75 = load [3 x double]*, [3 x double]** %3
%76 = getelementptr inbounds [3 x double], [3 x double]* %75, i64 0
%77 = getelementptr inbounds [3 x double], [3 x double]* %76, i64 0, i64 2
store double %74, double* %77
%78 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
%79 = load double, double* %78
%80 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
%81 = load double, double* %80
%82 = fmul double %79, %81
%83 = load [3 x double]*, [3 x double]** %3
%84 = getelementptr inbounds [3 x double], [3 x double]* %83, i64 1
%85 = getelementptr inbounds [3 x double], [3 x double]* %84, i64 0, i64 0
store double %82, double* %85
%86 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
%87 = load double, double* %86
%88 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 1
%89 = load double, double* %88
%90 = fmul double %87, %89
%91 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%92 = load double, double* %91
%93 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%94 = load double, double* %93
%95 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%96 = load double, double* %95
%97 = fmul double %94, %96
%98 = call double @llvm.fmuladd.f64(double %90, double %92, double %97)
%99 = load [3 x double]*, [3 x double]** %3
%100 = getelementptr inbounds [3 x double], [3 x double]* %99, i64 1
%101 = getelementptr inbounds [3 x double], [3 x double]* %100, i64 0, i64 1
store double %98, double* %101
%102 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
%103 = load double, double* %102
%104 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 1
%105 = load double, double* %104
%106 = fmul double %103, %105
%107 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%108 = load double, double* %107
%109 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%110 = load double, double* %109
%111 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%112 = load double, double* %111
%113 = fmul double %110, %112
%114 = fneg double %113
%115 = call double @llvm.fmuladd.f64(double %106, double %108, double %114)
%116 = load [3 x double]*, [3 x double]** %3
%117 = getelementptr inbounds [3 x double], [3 x double]* %116, i64 1
%118 = getelementptr inbounds [3 x double], [3 x double]* %117, i64 0, i64 2
store double %115, double* %118
%119 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
%120 = load double, double* %119
%121 = fneg double %120
%122 = load [3 x double]*, [3 x double]** %3
%123 = getelementptr inbounds [3 x double], [3 x double]* %122, i64 2
%124 = getelementptr inbounds [3 x double], [3 x double]* %123, i64 0, i64 0
store double %121, double* %124
%125 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
%126 = load double, double* %125
%127 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%128 = load double, double* %127
%129 = fmul double %126, %128
%130 = load [3 x double]*, [3 x double]** %3
%131 = getelementptr inbounds [3 x double], [3 x double]* %130, i64 2
%132 = getelementptr inbounds [3 x double], [3 x double]* %131, i64 0, i64 1
store double %129, double* %132
%133 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%134 = load double, double* %133
%135 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%136 = load double, double* %135
%137 = fmul double %134, %136
%138 = load [3 x double]*, [3 x double]** %3
%139 = getelementptr inbounds [3 x double], [3 x double]* %138, i64 2
%140 = getelementptr inbounds [3 x double], [3 x double]* %139, i64 0, i64 2
store double %137, double* %140
ret void
}

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