void matrix_rotation_z(double cos_a, double sin_a, double R[][3]) {
  R[0][0] = cos_a;
  R[0][1] = -sin_a;
  R[0][2] = 0;
  R[1][0] = sin_a;
  R[1][1] = cos_a;
  R[1][2] = 0;
  R[2][0] = 0;
  R[2][1] = 0;
  R[2][2] = 1;
}


x86 assembly (clang, -O0):
<matrix_rotation_z>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x10(%rax)
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x18(%rax)
movsd  -0x8(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x28(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x30(%rax)
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,0x38(%rax)
mov    -0x18(%rbp),%rax
movsd  0xe64(%rip),%xmm0
movsd  %xmm0,0x40(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix_rotation_z>:
movsd  %xmm0,(%rdi)
movaps 0xef5(%rip),%xmm2
xorps  %xmm1,%xmm2
movlps %xmm2,0x8(%rdi)
movq   $0x0,0x10(%rdi)
movsd  %xmm1,0x18(%rdi)
movsd  %xmm0,0x20(%rdi)
xorps  %xmm0,%xmm0
movups %xmm0,0x28(%rdi)
movq   $0x0,0x38(%rdi)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x40(%rdi)
ret

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

LLVM IR (-O2):
define void @matrix_rotation_z(double %0, double %1, [3 x double]* nocapture writeonly %2) {
%4 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
store double %0, double* %4
%5 = fneg double %1
%6 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
store double %5, double* %6
%7 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 2
store double 0.000000e+00, double* %7
%8 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 1, i64 0
store double %1, double* %8
%9 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 1, i64 1
store double %0, double* %9
%10 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 1, i64 2
%11 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 2, i64 2
%12 = bitcast double* %10 to i8*
store double 1.000000e+00, double* %11
ret void
}