#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_mrotx(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))] = morg[((((1) - 1) * 3) + ((k)-1))];
    mdest[((((2) - 1) * 3) + ((k)-1))] =
        cosa * morg[((((2) - 1) * 3) + ((k)-1))] -
        sina * morg[((((3) - 1) * 3) + ((k)-1))];
    mdest[((((3) - 1) * 3) + ((k)-1))] =
        sina * morg[((((2) - 1) * 3) + ((k)-1))] +
        cosa * morg[((((3) - 1) * 3) + ((k)-1))];
  }
}


x86 assembly (clang, -O0):
<cmatrix_mrotx>:
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_mrotx+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_mrotx+0x160>
mov    -0x10(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x68(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x74(%rbp),%ecx
sub    $0x1,%ecx
add    $0x3,%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    $0x6,%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    $0x3,%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    $0x3,%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    $0x6,%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    $0x6,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1195 <cmatrix_mrotx+0x65>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmatrix_mrotx>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
cmp    %rdi,%rsi
movsd  %xmm0,(%rsp)
jne    1166 <cmatrix_mrotx+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  (%rbx),%xmm1
movsd  %xmm1,(%r14)
movsd  0x30(%rbx),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x18(%rbx),%xmm2
movsd  0x8(%rsp),%xmm3
mulsd  %xmm3,%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,0x18(%r14)
movsd  0x30(%rbx),%xmm1
mulsd  %xmm3,%xmm1
movsd  0x18(%rbx),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x30(%r14)
movsd  0x8(%rbx),%xmm1
movsd  %xmm1,0x8(%r14)
movsd  0x38(%rbx),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x20(%rbx),%xmm2
mulsd  %xmm3,%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,0x20(%r14)
movsd  0x38(%rbx),%xmm1
mulsd  %xmm3,%xmm1
movsd  0x20(%rbx),%xmm2
mulsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x38(%r14)
movsd  0x10(%rbx),%xmm1
movsd  %xmm1,0x10(%r14)
movsd  0x40(%rbx),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x28(%rbx),%xmm2
mulsd  %xmm3,%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,0x28(%r14)
mulsd  0x40(%rbx),%xmm3
mulsd  0x28(%rbx),%xmm0
addsd  %xmm3,%xmm0
movsd  %xmm0,0x40(%r14)
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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