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


x86 assembly (clang, -O0):
<matrixrot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x30(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x38(%rax),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x40(%rax),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
movsd  -0x40(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x20(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x40(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrixrot>:
push   %rbx
sub    $0x30,%rsp
mov    %rsi,%rbx
movsd  0x30(%rdi),%xmm2
movapd 0xedb(%rip),%xmm0
xorpd  %xmm2,%xmm0
movapd %xmm0,0x20(%rsp)
movsd  0x18(%rdi),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x38(%rdi),%xmm0
divsd  %xmm1,%xmm0
movsd  (%rdi),%xmm3
movsd  0x8(%rdi),%xmm4
divsd  %xmm1,%xmm3
movsd  %xmm3,0x10(%rsp)
movsd  0x40(%rdi),%xmm1
divsd  %xmm3,%xmm1
mulsd  %xmm1,%xmm2
subsd  %xmm2,%xmm4
divsd  %xmm3,%xmm4
divsd  %xmm0,%xmm4
movsd  %xmm4,0x8(%rsp)
call   1030 <atan2@plt>
movsd  %xmm0,(%rbx)
movsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,0x8(%rbx)
movaps 0x20(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1030 <atan2@plt>
movsd  %xmm0,0x10(%rbx)
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @matrixrot([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 = load [3 x double]*, [3 x double]** %3
%8 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 2
%9 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%10 = load double, double* %9
%11 = fneg double %10
%12 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
store double %11, double* %12
%13 = load [3 x double]*, [3 x double]** %3
%14 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 1
%15 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 0
%16 = load double, double* %15
%17 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
%18 = load double, double* %17
%19 = fdiv double %16, %18
%20 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
store double %19, double* %20
%21 = load [3 x double]*, [3 x double]** %3
%22 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 2
%23 = getelementptr inbounds [3 x double], [3 x double]* %22, i64 0, i64 1
%24 = load double, double* %23
%25 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
%26 = load double, double* %25
%27 = fdiv double %24, %26
%28 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
store double %27, double* %28
%29 = load [3 x double]*, [3 x double]** %3
%30 = getelementptr inbounds [3 x double], [3 x double]* %29, i64 0
%31 = getelementptr inbounds [3 x double], [3 x double]* %30, i64 0, i64 0
%32 = load double, double* %31
%33 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
%34 = load double, double* %33
%35 = fdiv double %32, %34
%36 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
store double %35, double* %36
%37 = load [3 x double]*, [3 x double]** %3
%38 = getelementptr inbounds [3 x double], [3 x double]* %37, i64 2
%39 = getelementptr inbounds [3 x double], [3 x double]* %38, i64 0, i64 2
%40 = load double, double* %39
%41 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%42 = load double, double* %41
%43 = fdiv double %40, %42
%44 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
store double %43, double* %44
%45 = load [3 x double]*, [3 x double]** %3
%46 = getelementptr inbounds [3 x double], [3 x double]* %45, i64 0
%47 = getelementptr inbounds [3 x double], [3 x double]* %46, i64 0, i64 1
%48 = load double, double* %47
%49 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
%50 = load double, double* %49
%51 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%52 = load double, double* %51
%53 = call double @llvm.fmuladd.f64(double %50, double %52, double %48)
%54 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%55 = load double, double* %54
%56 = fdiv double %53, %55
%57 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%58 = load double, double* %57
%59 = fdiv double %56, %58
%60 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 1
store double %59, double* %60
%61 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%62 = load double, double* %61
%63 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%64 = load double, double* %63
%65 = call double @atan2(double %62, double %64)
%66 = load double*, double** %4
%67 = getelementptr inbounds double, double* %66, i64 0
store double %65, double* %67
%68 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 1
%69 = load double, double* %68
%70 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
%71 = load double, double* %70
%72 = call double @atan2(double %69, double %71)
%73 = load double*, double** %4
%74 = getelementptr inbounds double, double* %73, i64 1
store double %72, double* %74
%75 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
%76 = load double, double* %75
%77 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%78 = load double, double* %77
%79 = call double @atan2(double %76, double %78)
%80 = load double*, double** %4
%81 = getelementptr inbounds double, double* %80, i64 2
store double %79, double* %81
ret void
}

LLVM IR (-O2):
define void @matrixrot([3 x double]* nocapture %0, double* nocapture writeonly %1) {
%3 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 0
%4 = load double, double* %3
%5 = fneg double %4
%6 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 0
%7 = load double, double* %6
%8 = fdiv double %7, %5
%9 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 1
%10 = load double, double* %9
%11 = fdiv double %10, %8
%12 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0
%13 = load double, double* %12
%14 = fdiv double %13, %8
%15 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
%16 = load double, double* %15
%17 = fdiv double %16, %14
%18 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 1
%19 = load double, double* %18
%20 = tail call double @llvm.fmuladd.f64(double %5, double %17, double %19)
%21 = fdiv double %20, %14
%22 = fdiv double %21, %11
%23 = tail call double @atan2(double %11, double %17)
store double %23, double* %1
%24 = tail call double @atan2(double %22, double %8)
%25 = getelementptr inbounds double, double* %1, i64 1
store double %24, double* %25
%26 = tail call double @atan2(double %5, double %14)
%27 = getelementptr inbounds double, double* %1, i64 2
store double %26, double* %27
ret void
}