#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 build_rotation_matrix(double rot_around_x, double rot_around_y,
                           double *mat) {
  mat[0] = cos(rot_around_y);
  mat[1] = 0;
  mat[2] = -sin(rot_around_y);
  mat[3] = 0;
  mat[4] = cos(rot_around_x);
  mat[5] = -sin(rot_around_x);
  mat[6] = sin(rot_around_y);
  mat[7] = sin(rot_around_x);
  mat[8] = cos(rot_around_x) * cos(rot_around_y);
}


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

x86 assembly (clang, -O2):
<build_rotation_matrix>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
movaps %xmm1,%xmm0
call   1040 <cos@plt>
movsd  %xmm0,(%rbx)
movq   $0x0,0x8(%rbx)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
xorps  0xea7(%rip),%xmm0
movlps %xmm0,0x10(%rbx)
movq   $0x0,0x18(%rbx)
movsd  (%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x20(%rbx)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
xorps  0xe7b(%rip),%xmm0
movlps %xmm0,0x28(%rbx)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x30(%rbx)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x38(%rbx)
movsd  (%rsp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x40(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @build_rotation_matrix(double %0, double %1, double* %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double*
store double %0, double* %4
store double %1, double* %5
store double* %2, double** %6
%7 = load double, double* %5
%8 = call double @cos(double %7)
%9 = load double*, double** %6
%10 = getelementptr inbounds double, double* %9, i64 0
store double %8, double* %10
%11 = load double*, double** %6
%12 = getelementptr inbounds double, double* %11, i64 1
store double 0.000000e+00, double* %12
%13 = load double, double* %5
%14 = call double @sin(double %13)
%15 = fneg double %14
%16 = load double*, double** %6
%17 = getelementptr inbounds double, double* %16, i64 2
store double %15, double* %17
%18 = load double*, double** %6
%19 = getelementptr inbounds double, double* %18, i64 3
store double 0.000000e+00, double* %19
%20 = load double, double* %4
%21 = call double @cos(double %20)
%22 = load double*, double** %6
%23 = getelementptr inbounds double, double* %22, i64 4
store double %21, double* %23
%24 = load double, double* %4
%25 = call double @sin(double %24)
%26 = fneg double %25
%27 = load double*, double** %6
%28 = getelementptr inbounds double, double* %27, i64 5
store double %26, double* %28
%29 = load double, double* %5
%30 = call double @sin(double %29)
%31 = load double*, double** %6
%32 = getelementptr inbounds double, double* %31, i64 6
store double %30, double* %32
%33 = load double, double* %4
%34 = call double @sin(double %33)
%35 = load double*, double** %6
%36 = getelementptr inbounds double, double* %35, i64 7
store double %34, double* %36
%37 = load double, double* %4
%38 = call double @cos(double %37)
%39 = load double, double* %5
%40 = call double @cos(double %39)
%41 = fmul double %38, %40
%42 = load double*, double** %6
%43 = getelementptr inbounds double, double* %42, i64 8
store double %41, double* %43
ret void
}

LLVM IR (-O2):
define void @build_rotation_matrix(double %0, double %1, double* nocapture writeonly %2) {
%4 = tail call double @cos(double %1)
store double %4, double* %2
%5 = getelementptr inbounds double, double* %2, i64 1
store double 0.000000e+00, double* %5
%6 = tail call double @sin(double %1)
%7 = fneg double %6
%8 = getelementptr inbounds double, double* %2, i64 2
store double %7, double* %8
%9 = getelementptr inbounds double, double* %2, i64 3
store double 0.000000e+00, double* %9
%10 = tail call double @cos(double %0)
%11 = getelementptr inbounds double, double* %2, i64 4
store double %10, double* %11
%12 = tail call double @sin(double %0)
%13 = fneg double %12
%14 = getelementptr inbounds double, double* %2, i64 5
store double %13, double* %14
%15 = tail call double @sin(double %1)
%16 = getelementptr inbounds double, double* %2, i64 6
store double %15, double* %16
%17 = tail call double @sin(double %0)
%18 = getelementptr inbounds double, double* %2, i64 7
store double %17, double* %18
%19 = tail call double @cos(double %0)
%20 = tail call double @cos(double %1)
%21 = fmul double %19, %20
%22 = getelementptr inbounds double, double* %2, i64 8
store double %21, double* %22
ret void
}