#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 get_rot_matrix(double dump[3][3], double psi, double theta, double phi) {
  double sin_psi = sin(psi);
  double cos_psi = cos(psi);
  double sin_theta = sin(theta);
  double cos_theta = cos(theta);
  double sin_phi = sin(phi);
  double cos_phi = cos(phi);
  dump[0][0] = cos_psi * cos_phi - cos_theta * sin_phi * sin_psi;
  dump[0][1] = cos_psi * sin_phi + cos_theta * cos_phi * sin_psi;
  dump[0][2] = sin_psi * sin_theta;
  dump[1][0] = -sin_psi * cos_phi - cos_theta * sin_phi * cos_psi;
  dump[1][1] = -sin_psi * sin_phi + cos_theta * cos_phi * cos_psi;
  dump[1][2] = cos_psi * sin_theta;
  dump[2][0] = sin_theta * sin_phi;
  dump[2][1] = -sin_theta * cos_phi;
  dump[2][2] = cos_theta;
}


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

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

LLVM IR (-O0):
define void @get_rot_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* %6
%16 = call double @sin(double %15)
store double %16, double* %9
%17 = load double, double* %6
%18 = call double @cos(double %17)
store double %18, double* %10
%19 = load double, double* %7
%20 = call double @sin(double %19)
store double %20, double* %11
%21 = load double, double* %7
%22 = call double @cos(double %21)
store double %22, double* %12
%23 = load double, double* %8
%24 = call double @sin(double %23)
store double %24, double* %13
%25 = load double, double* %8
%26 = call double @cos(double %25)
store double %26, double* %14
%27 = load double, double* %10
%28 = load double, double* %14
%29 = load double, double* %12
%30 = load double, double* %13
%31 = fmul double %29, %30
%32 = load double, double* %9
%33 = fmul double %31, %32
%34 = fneg double %33
%35 = call double @llvm.fmuladd.f64(double %27, double %28, double %34)
%36 = load [3 x double]*, [3 x double]** %5
%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* %10
%40 = load double, double* %13
%41 = load double, double* %12
%42 = load double, double* %14
%43 = fmul double %41, %42
%44 = load double, double* %9
%45 = fmul double %43, %44
%46 = call double @llvm.fmuladd.f64(double %39, double %40, double %45)
%47 = load [3 x double]*, [3 x double]** %5
%48 = getelementptr inbounds [3 x double], [3 x double]* %47, i64 0
%49 = getelementptr inbounds [3 x double], [3 x double]* %48, i64 0, i64 1
store double %46, double* %49
%50 = load double, double* %9
%51 = load double, double* %11
%52 = fmul double %50, %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* %9
%57 = fneg double %56
%58 = load double, double* %14
%59 = load double, double* %12
%60 = load double, double* %13
%61 = fmul double %59, %60
%62 = load double, double* %10
%63 = fmul double %61, %62
%64 = fneg double %63
%65 = call double @llvm.fmuladd.f64(double %57, double %58, double %64)
%66 = load [3 x double]*, [3 x double]** %5
%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 = load double, double* %12
%73 = load double, double* %14
%74 = fmul double %72, %73
%75 = load double, double* %10
%76 = fmul double %74, %75
%77 = call double @llvm.fmuladd.f64(double %70, double %71, double %76)
%78 = load [3 x double]*, [3 x double]** %5
%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* %10
%82 = load double, double* %11
%83 = fmul double %81, %82
%84 = load [3 x double]*, [3 x double]** %5
%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* %11
%88 = load double, double* %13
%89 = fmul double %87, %88
%90 = load [3 x double]*, [3 x double]** %5
%91 = getelementptr inbounds [3 x double], [3 x double]* %90, i64 2
%92 = getelementptr inbounds [3 x double], [3 x double]* %91, i64 0, i64 0
store double %89, double* %92
%93 = load double, double* %11
%94 = fneg double %93
%95 = load double, double* %14
%96 = fmul double %94, %95
%97 = load [3 x double]*, [3 x double]** %5
%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* %12
%101 = load [3 x double]*, [3 x double]** %5
%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 @get_rot_matrix([3 x double]* nocapture writeonly %0, double %1, double %2, double %3) {
%5 = tail call double @sin(double %1)
%6 = tail call double @cos(double %1)
%7 = tail call double @sin(double %2)
%8 = tail call double @cos(double %2)
%9 = tail call double @sin(double %3)
%10 = tail call double @cos(double %3)
%11 = fneg double %8
%12 = insertelement <2 x double> poison, double %9, i64 0
%13 = insertelement <2 x double> %12, double %8, i64 1
%14 = insertelement <2 x double> poison, double %11, i64 0
%15 = insertelement <2 x double> %14, double %10, i64 1
%16 = fmul <2 x double> %13, %15
%17 = insertelement <2 x double> poison, double %5, i64 0
%18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> zeroinitializer
%19 = fmul <2 x double> %18, %16
%20 = insertelement <2 x double> poison, double %6, i64 0
%21 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> zeroinitializer
%22 = insertelement <2 x double> poison, double %10, i64 0
%23 = insertelement <2 x double> %22, double %9, i64 1
%24 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %21, <2 x double> %23, <2 x double> %19)
%25 = bitcast [3 x double]* %0 to <2 x double>*
store <2 x double> %24, <2 x double>* %25
%26 = fmul double %5, %7
%27 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2
store double %26, double* %27
%28 = fneg double %5
%29 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 0
%30 = fmul <2 x double> %21, %16
%31 = insertelement <2 x double> poison, double %28, i64 0
%32 = shufflevector <2 x double> %31, <2 x double> poison, <2 x i32> zeroinitializer
%33 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %32, <2 x double> %23, <2 x double> %30)
%34 = bitcast double* %29 to <2 x double>*
store <2 x double> %33, <2 x double>* %34
%35 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 2
%36 = insertelement <2 x double> poison, double %7, i64 0
%37 = shufflevector <2 x double> %36, <2 x double> poison, <2 x i32> zeroinitializer
%38 = insertelement <2 x double> %20, double %9, i64 1
%39 = fmul <2 x double> %37, %38
%40 = bitcast double* %35 to <2 x double>*
store <2 x double> %39, <2 x double>* %40
%41 = fneg double %7
%42 = fmul double %10, %41
%43 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 1
store double %42, double* %43
%44 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
store double %8, double* %44
ret void
}