#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 */
long double cos(long double);
int /*<<< orphan*/ memcpy(double *, double const *, int);
long double sin(long double);
void cmatrix_mrotz_l(double *mdest, const double *morg, long double angle) {
  double temp[3 * 3];
  if (morg == mdest) {
    memcpy(temp, morg, sizeof(temp));
    morg = temp;
  }
  long double cosa = cos(angle);
  long 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_l>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
fldt   0x10(%rbp)
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
fstpt  -0x20(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    1171 <cmatrix_mrotz_l+0x41>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x48,%edx
call   1040 <memcpy@plt>
lea    -0x70(%rbp),%rax
mov    %rax,-0x10(%rbp)
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1050 <cos@plt>
fstpt  -0x80(%rbp)
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <sin@plt>
fstpt  -0x90(%rbp)
movl   $0x1,-0x94(%rbp)
cmpl   $0x3,-0x94(%rbp)
jg     126c <cmatrix_mrotz_l+0x13c>
fldt   -0x80(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x94(%rbp),%ecx
add    $0xffffffff,%ecx
movslq %ecx,%rcx
fldl   (%rax,%rcx,8)
fldt   -0x90(%rbp)
fldl   0x18(%rax,%rcx,8)
fmulp  %st,%st(1)
fxch   %st(2)
fmulp  %st,%st(1)
fsubp  %st,%st(1)
mov    -0x8(%rbp),%rax
fstpl  (%rax,%rcx,8)
fldt   -0x90(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x94(%rbp),%ecx
add    $0xffffffff,%ecx
movslq %ecx,%rcx
fldl   (%rax,%rcx,8)
fldt   -0x80(%rbp)
fldl   0x18(%rax,%rcx,8)
fmulp  %st,%st(1)
fxch   %st(2)
fmulp  %st,%st(1)
faddp  %st,%st(1)
fstpl  -0xa0(%rbp)
movsd  -0xa0(%rbp),%xmm0
ff
mov    -0x8(%rbp),%rax
mov    -0x94(%rbp),%ecx
sub    $0x1,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x94(%rbp),%ecx
sub    $0x1,%ecx
add    $0x6,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x94(%rbp),%ecx
sub    $0x1,%ecx
add    $0x6,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    119e <cmatrix_mrotz_l+0x6e>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmatrix_mrotz_l>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
fldt   0xa0(%rsp)
cmp    %rdi,%rsi
fld    %st(0)
fstpt  0x18(%rsp)
jne    1172 <cmatrix_mrotz_l+0x42>
fstp   %st(0)
lea    0x30(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x48,%edx
call   1040 <memcpy@plt>
fldt   0x18(%rsp)
mov    %r15,%rbx
fstpt  (%rsp)
call   1050 <cos@plt>
fstpt  0x24(%rsp)
fldt   0x18(%rsp)
fstpt  (%rsp)
call   1030 <sin@plt>
fld    %st(0)
fmull  0x18(%rbx)
fldt   0x24(%rsp)
fld    %st(0)
fmull  (%rbx)
fsubp  %st,%st(2)
fxch   %st(1)
fstpl  (%r14)
fld    %st(0)
fmull  0x18(%rbx)
fld    %st(2)
fmull  (%rbx)
faddp  %st,%st(1)
fstpl  0x18(%r14)
movsd  0x30(%rbx),%xmm0
movsd  %xmm0,0x30(%r14)
fld    %st(1)
fmull  0x20(%rbx)
fld    %st(1)
fmull  0x8(%rbx)
fsubp  %st,%st(1)
fstpl  0x8(%r14)
fld    %st(0)
fmull  0x20(%rbx)
fld    %st(2)
fmull  0x8(%rbx)
faddp  %st,%st(1)
fstpl  0x20(%r14)
movsd  0x38(%rbx),%xmm0
movsd  %xmm0,0x38(%r14)
fld    %st(1)
fmull  0x28(%rbx)
fld    %st(1)
fmull  0x10(%rbx)
fsubp  %st,%st(1)
fstpl  0x10(%r14)
fmull  0x28(%rbx)
fxch   %st(1)
fmull  0x10(%rbx)
faddp  %st,%st(1)
fstpl  0x28(%r14)
movsd  0x40(%rbx),%xmm0
movsd  %xmm0,0x40(%r14)
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @cmatrix_mrotz_l(double* %0, double* %1, x86_fp80 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca x86_fp80
%7 = alloca [9 x double]
%8 = alloca x86_fp80
%9 = alloca x86_fp80
%10 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store x86_fp80 %2, x86_fp80* %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 x86_fp80, x86_fp80* %6
%21 = call x86_fp80 @cos(x86_fp80 %20)
store x86_fp80 %21, x86_fp80* %8
%22 = load x86_fp80, x86_fp80* %6
%23 = call x86_fp80 @sin(x86_fp80 %22)
store x86_fp80 %23, x86_fp80* %9
store i32 1, i32* %10
br label %24
24: ; preds = %96, %19
%25 = load i32, i32* %10
%26 = icmp sle i32 %25, 3
br i1 %26, label %27, label %99
27: ; preds = %24
%28 = load x86_fp80, x86_fp80* %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 = fpext double %35 to x86_fp80
%37 = load x86_fp80, x86_fp80* %9
%38 = load double*, double** %5
%39 = load i32, i32* %10
%40 = sub nsw i32 %39, 1
%41 = add nsw i32 3, %40
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %38, i64 %42
%44 = load double, double* %43
%45 = fpext double %44 to x86_fp80
%46 = fmul x86_fp80 %37, %45
%47 = fneg x86_fp80 %46
%48 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %28, x86_fp80 %36, x86_fp80 %47)
%49 = fptrunc x86_fp80 %48 to double
%50 = load double*, double** %4
%51 = load i32, i32* %10
%52 = sub nsw i32 %51, 1
%53 = add nsw i32 0, %52
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %50, i64 %54
store double %49, double* %55
%56 = load x86_fp80, x86_fp80* %9
%57 = load double*, double** %5
%58 = load i32, i32* %10
%59 = sub nsw i32 %58, 1
%60 = add nsw i32 0, %59
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds double, double* %57, i64 %61
%63 = load double, double* %62
%64 = fpext double %63 to x86_fp80
%65 = load x86_fp80, x86_fp80* %8
%66 = load double*, double** %5
%67 = load i32, i32* %10
%68 = sub nsw i32 %67, 1
%69 = add nsw i32 3, %68
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %66, i64 %70
%72 = load double, double* %71
%73 = fpext double %72 to x86_fp80
%74 = fmul x86_fp80 %65, %73
%75 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %56, x86_fp80 %64, x86_fp80 %74)
%76 = fptrunc x86_fp80 %75 to double
%77 = load double*, double** %4
%78 = load i32, i32* %10
%79 = sub nsw i32 %78, 1
%80 = add nsw i32 3, %79
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds double, double* %77, i64 %81
store double %76, double* %82
%83 = load double*, double** %5
%84 = load i32, i32* %10
%85 = sub nsw i32 %84, 1
%86 = add nsw i32 6, %85
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds double, double* %83, i64 %87
%89 = load double, double* %88
%90 = load double*, double** %4
%91 = load i32, i32* %10
%92 = sub nsw i32 %91, 1
%93 = add nsw i32 6, %92
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds double, double* %90, i64 %94
store double %89, double* %95
br label %96
96: ; preds = %27
%97 = load i32, i32* %10
%98 = add nsw i32 %97, 1
store i32 %98, i32* %10
br label %24
99: ; preds = %24
ret void
}

LLVM IR (-O2):
define void @cmatrix_mrotz_l(double* writeonly %0, double* %1, x86_fp80 %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 x86_fp80 @cos(x86_fp80 %2)
%13 = call x86_fp80 @sin(x86_fp80 %2)
%14 = fneg x86_fp80 %13
%15 = load double, double* %11
%16 = fpext double %15 to x86_fp80
%17 = getelementptr inbounds double, double* %11, i64 3
%18 = load double, double* %17
%19 = fpext double %18 to x86_fp80
%20 = fmul x86_fp80 %14, %19
%21 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %12, x86_fp80 %16, x86_fp80 %20)
%22 = fptrunc x86_fp80 %21 to double
store double %22, double* %0
%23 = load double, double* %11
%24 = fpext double %23 to x86_fp80
%25 = load double, double* %17
%26 = fpext double %25 to x86_fp80
%27 = fmul x86_fp80 %12, %26
%28 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %13, x86_fp80 %24, x86_fp80 %27)
%29 = fptrunc x86_fp80 %28 to double
%30 = getelementptr inbounds double, double* %0, i64 3
store double %29, double* %30
%31 = getelementptr inbounds double, double* %11, i64 6
%32 = load double, double* %31
%33 = getelementptr inbounds double, double* %0, i64 6
store double %32, double* %33
%34 = getelementptr inbounds double, double* %11, i64 1
%35 = load double, double* %34
%36 = fpext double %35 to x86_fp80
%37 = getelementptr inbounds double, double* %11, i64 4
%38 = load double, double* %37
%39 = fpext double %38 to x86_fp80
%40 = fmul x86_fp80 %14, %39
%41 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %12, x86_fp80 %36, x86_fp80 %40)
%42 = fptrunc x86_fp80 %41 to double
%43 = getelementptr inbounds double, double* %0, i64 1
store double %42, double* %43
%44 = load double, double* %34
%45 = fpext double %44 to x86_fp80
%46 = load double, double* %37
%47 = fpext double %46 to x86_fp80
%48 = fmul x86_fp80 %12, %47
%49 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %13, x86_fp80 %45, x86_fp80 %48)
%50 = fptrunc x86_fp80 %49 to double
%51 = getelementptr inbounds double, double* %0, i64 4
store double %50, double* %51
%52 = getelementptr inbounds double, double* %11, i64 7
%53 = load double, double* %52
%54 = getelementptr inbounds double, double* %0, i64 7
store double %53, double* %54
%55 = getelementptr inbounds double, double* %11, i64 2
%56 = load double, double* %55
%57 = fpext double %56 to x86_fp80
%58 = getelementptr inbounds double, double* %11, i64 5
%59 = load double, double* %58
%60 = fpext double %59 to x86_fp80
%61 = fmul x86_fp80 %14, %60
%62 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %12, x86_fp80 %57, x86_fp80 %61)
%63 = fptrunc x86_fp80 %62 to double
%64 = getelementptr inbounds double, double* %0, i64 2
store double %63, double* %64
%65 = load double, double* %55
%66 = fpext double %65 to x86_fp80
%67 = load double, double* %58
%68 = fpext double %67 to x86_fp80
%69 = fmul x86_fp80 %12, %68
%70 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %13, x86_fp80 %66, x86_fp80 %69)
%71 = fptrunc x86_fp80 %70 to double
%72 = getelementptr inbounds double, double* %0, i64 5
store double %71, double* %72
%73 = getelementptr inbounds double, double* %11, i64 8
%74 = load double, double* %73
%75 = getelementptr inbounds double, double* %0, i64 8
store double %74, double* %75
ret void
}