#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 */
typedef int /*<<< orphan*/ temp;
typedef size_t k;

/* Variables and functions */
double cos(double);
int /*<<< orphan*/ memcpy(double *, double const *, int);
double sin(double);
void cmatrix_mrotz(double *mdest, const double *morg, double angle) {
  double temp[3 * 3];
  if (morg == mdest) {
    memcpy(temp, morg, sizeof(temp));
    morg = temp;
  }
  double cosa = cos(angle);
  double sina = sin(angle);
  for (int k = 1; k <= 3; k++) {
    mdest[((((1) - 1) * 3) + ((k)-1))] =
        cosa * morg[((((1) - 1) * 3) + ((k)-1))] -
        sina * morg[((((2) - 1) * 3) + ((k)-1))];
    mdest[((((2) - 1) * 3) + ((k)-1))] =
        sina * morg[((((1) - 1) * 3) + ((k)-1))] +
        cosa * morg[((((2) - 1) * 3) + ((k)-1))];
    mdest[((((3) - 1) * 3) + ((k)-1))] = morg[((((3) - 1) * 3) + ((k)-1))];
  }
}


x86 assembly (clang, -O0):
<cmatrix_mrotz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    1170 <cmatrix_mrotz+0x40>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x48,%edx
call   1040 <memcpy@plt>
lea    -0x60(%rbp),%rax
mov    %rax,-0x10(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x70(%rbp)
movl   $0x1,-0x74(%rbp)
cmpl   $0x3,-0x74(%rbp)
jg     1290 <cmatrix_mrotz+0x160>
movsd  -0x68(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x70(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x70(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x68(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
add    $0x6,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
add    $0x6,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1195 <cmatrix_mrotz+0x65>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmatrix_mrotz>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
cmp    %rdi,%rsi
movsd  %xmm0,(%rsp)
jne    1166 <cmatrix_mrotz+0x36>
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x48,%edx
call   1040 <memcpy@plt>
movsd  (%rsp),%xmm0
mov    %r15,%rbx
call   1050 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1030 <sin@plt>
movsd  0x18(%rbx),%xmm1
mulsd  %xmm0,%xmm1
movsd  (%rbx),%xmm2
movsd  0x8(%rsp),%xmm3
mulsd  %xmm3,%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,(%r14)
movsd  0x18(%rbx),%xmm1
mulsd  %xmm3,%xmm1
movsd  (%rbx),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x18(%r14)
movsd  0x30(%rbx),%xmm1
movsd  %xmm1,0x30(%r14)
movsd  0x20(%rbx),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x8(%rbx),%xmm2
mulsd  %xmm3,%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%r14)
movsd  0x20(%rbx),%xmm1
mulsd  %xmm3,%xmm1
movsd  0x8(%rbx),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x20(%r14)
movsd  0x38(%rbx),%xmm1
movsd  %xmm1,0x38(%r14)
movsd  0x28(%rbx),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x10(%rbx),%xmm2
mulsd  %xmm3,%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,0x10(%r14)
mulsd  0x28(%rbx),%xmm3
mulsd  0x10(%rbx),%xmm0
addsd  %xmm3,%xmm0
movsd  %xmm0,0x28(%r14)
movsd  0x40(%rbx),%xmm0
movsd  %xmm0,0x40(%r14)
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @cmatrix_mrotz(double* %0, double* %1, double %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double
%7 = alloca [9 x double]
%8 = alloca double
%9 = alloca double
%10 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store double %2, double* %6
%11 = load double*, double** %5
%12 = load double*, double** %4
%13 = icmp eq double* %11, %12
br i1 %13, label %14, label %19
14: ; preds = %3
%15 = getelementptr inbounds [9 x double], [9 x double]* %7, i64 0, i64 0
%16 = load double*, double** %5
%17 = call i32 @memcpy(double* %15, double* %16, i32 72)
%18 = getelementptr inbounds [9 x double], [9 x double]* %7, i64 0, i64 0
store double* %18, double** %5
br label %19
19: ; preds = %14, %3
%20 = load double, double* %6
%21 = call double @cos(double %20)
store double %21, double* %8
%22 = load double, double* %6
%23 = call double @sin(double %22)
store double %23, double* %9
store i32 1, i32* %10
br label %24
24: ; preds = %90, %19
%25 = load i32, i32* %10
%26 = icmp sle i32 %25, 3
br i1 %26, label %27, label %93
27: ; preds = %24
%28 = load double, double* %8
%29 = load double*, double** %5
%30 = load i32, i32* %10
%31 = sub nsw i32 %30, 1
%32 = add nsw i32 0, %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %29, i64 %33
%35 = load double, double* %34
%36 = load double, double* %9
%37 = load double*, double** %5
%38 = load i32, i32* %10
%39 = sub nsw i32 %38, 1
%40 = add nsw i32 3, %39
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %37, i64 %41
%43 = load double, double* %42
%44 = fmul double %36, %43
%45 = fneg double %44
%46 = call double @llvm.fmuladd.f64(double %28, double %35, double %45)
%47 = load double*, double** %4
%48 = load i32, i32* %10
%49 = sub nsw i32 %48, 1
%50 = add nsw i32 0, %49
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %47, i64 %51
store double %46, double* %52
%53 = load double, double* %9
%54 = load double*, double** %5
%55 = load i32, i32* %10
%56 = sub nsw i32 %55, 1
%57 = add nsw i32 0, %56
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %54, i64 %58
%60 = load double, double* %59
%61 = load double, double* %8
%62 = load double*, double** %5
%63 = load i32, i32* %10
%64 = sub nsw i32 %63, 1
%65 = add nsw i32 3, %64
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %62, i64 %66
%68 = load double, double* %67
%69 = fmul double %61, %68
%70 = call double @llvm.fmuladd.f64(double %53, double %60, double %69)
%71 = load double*, double** %4
%72 = load i32, i32* %10
%73 = sub nsw i32 %72, 1
%74 = add nsw i32 3, %73
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %71, i64 %75
store double %70, double* %76
%77 = load double*, double** %5
%78 = load i32, i32* %10
%79 = sub nsw i32 %78, 1
%80 = add nsw i32 6, %79
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double, double* %77, i64 %81
%83 = load double, double* %82
%84 = load double*, double** %4
%85 = load i32, i32* %10
%86 = sub nsw i32 %85, 1
%87 = add nsw i32 6, %86
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds double, double* %84, i64 %88
store double %83, double* %89
br label %90
90: ; preds = %27
%91 = load i32, i32* %10
%92 = add nsw i32 %91, 1
store i32 %92, i32* %10
br label %24
93: ; preds = %24
ret void
}

LLVM IR (-O2):
define void @cmatrix_mrotz(double* writeonly %0, double* %1, double %2) {
%4 = alloca [9 x double]
%5 = bitcast [9 x double]* %4 to i8*
%6 = icmp eq double* %1, %0
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 0
%9 = call i32 @memcpy(double* %8, double* %1, i32 72)
br label %10
10: ; preds = %7, %3
%11 = phi double* [ %8, %7 ], [ %1, %3 ]
%12 = call double @cos(double %2)
%13 = call double @sin(double %2)
%14 = fneg double %13
%15 = load double, double* %11
%16 = getelementptr inbounds double, double* %11, i64 3
%17 = load double, double* %16
%18 = fmul double %17, %14
%19 = call double @llvm.fmuladd.f64(double %12, double %15, double %18)
store double %19, double* %0
%20 = load double, double* %11
%21 = load double, double* %16
%22 = fmul double %12, %21
%23 = call double @llvm.fmuladd.f64(double %13, double %20, double %22)
%24 = getelementptr inbounds double, double* %0, i64 3
store double %23, double* %24
%25 = getelementptr inbounds double, double* %11, i64 6
%26 = load double, double* %25
%27 = getelementptr inbounds double, double* %0, i64 6
store double %26, double* %27
%28 = getelementptr inbounds double, double* %11, i64 1
%29 = load double, double* %28
%30 = getelementptr inbounds double, double* %11, i64 4
%31 = load double, double* %30
%32 = fmul double %31, %14
%33 = call double @llvm.fmuladd.f64(double %12, double %29, double %32)
%34 = getelementptr inbounds double, double* %0, i64 1
store double %33, double* %34
%35 = load double, double* %28
%36 = load double, double* %30
%37 = fmul double %12, %36
%38 = call double @llvm.fmuladd.f64(double %13, double %35, double %37)
%39 = getelementptr inbounds double, double* %0, i64 4
store double %38, double* %39
%40 = getelementptr inbounds double, double* %11, i64 7
%41 = load double, double* %40
%42 = getelementptr inbounds double, double* %0, i64 7
store double %41, double* %42
%43 = getelementptr inbounds double, double* %11, i64 2
%44 = load double, double* %43
%45 = getelementptr inbounds double, double* %11, i64 5
%46 = load double, double* %45
%47 = fmul double %46, %14
%48 = call double @llvm.fmuladd.f64(double %12, double %44, double %47)
%49 = getelementptr inbounds double, double* %0, i64 2
store double %48, double* %49
%50 = load double, double* %43
%51 = load double, double* %45
%52 = fmul double %12, %51
%53 = call double @llvm.fmuladd.f64(double %13, double %50, double %52)
%54 = getelementptr inbounds double, double* %0, i64 5
store double %53, double* %54
%55 = getelementptr inbounds double, double* %11, i64 8
%56 = load double, double* %55
%57 = getelementptr inbounds double, double* %0, i64 8
store double %56, double* %57
ret void
}