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


x86 assembly (clang, -O0):
<cmatrix_mroty_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_mroty_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     125c <cmatrix_mroty_l+0x12c>
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   0x30(%rax,%rcx,8)
fmulp  %st,%st(1)
fxch   %st(2)
fmulp  %st,%st(1)
faddp  %st,%st(1)
mov    -0x8(%rbp),%rax
fstpl  (%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x94(%rbp),%ecx
add    $0xffffffff,%ecx
movslq %ecx,%rcx
movsd  0x18(%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,0x18(%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   0x30(%rax,%rcx,8)
fmulp  %st,%st(1)
fxch   %st(2)
fmulp  %st,%st(1)
fsubrp %st,%st(1)
fstpl  -0xa0(%rbp)
movsd  -0xa0(%rbp),%xmm0
ff
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_mroty_l+0x6e>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmatrix_mroty_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_mroty_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  0x30(%rbx)
fldt   0x24(%rsp)
fld    %st(0)
fmull  (%rbx)
faddp  %st,%st(2)
fxch   %st(1)
fstpl  (%r14)
movsd  0x18(%rbx),%xmm0
movsd  %xmm0,0x18(%r14)
fld    %st(0)
fmull  0x30(%rbx)
fld    %st(2)
fmull  (%rbx)
fsubrp %st,%st(1)
fstpl  0x30(%r14)
fld    %st(1)
fmull  0x38(%rbx)
fld    %st(1)
fmull  0x8(%rbx)
faddp  %st,%st(1)
fstpl  0x8(%r14)
movsd  0x20(%rbx),%xmm0
movsd  %xmm0,0x20(%r14)
fld    %st(0)
fmull  0x38(%rbx)
fld    %st(2)
fmull  0x8(%rbx)
fsubrp %st,%st(1)
fstpl  0x38(%r14)
fld    %st(1)
fmull  0x40(%rbx)
fld    %st(1)
fmull  0x10(%rbx)
faddp  %st,%st(1)
fstpl  0x10(%r14)
movsd  0x28(%rbx),%xmm0
movsd  %xmm0,0x28(%r14)
fmull  0x40(%rbx)
fxch   %st(1)
fmull  0x10(%rbx)
fsubrp %st,%st(1)
fstpl  0x40(%r14)
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @cmatrix_mroty_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 6, %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 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %28, x86_fp80 %36, x86_fp80 %46)
%48 = fptrunc x86_fp80 %47 to double
%49 = load double*, double** %4
%50 = load i32, i32* %10
%51 = sub nsw i32 %50, 1
%52 = add nsw i32 0, %51
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %49, i64 %53
store double %48, double* %54
%55 = load double*, double** %5
%56 = load i32, i32* %10
%57 = sub nsw i32 %56, 1
%58 = add nsw i32 3, %57
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %55, i64 %59
%61 = load double, double* %60
%62 = load double*, double** %4
%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
store double %61, double* %67
%68 = load x86_fp80, x86_fp80* %9
%69 = fneg x86_fp80 %68
%70 = load double*, double** %5
%71 = load i32, i32* %10
%72 = sub nsw i32 %71, 1
%73 = add nsw i32 0, %72
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %70, i64 %74
%76 = load double, double* %75
%77 = fpext double %76 to x86_fp80
%78 = load x86_fp80, x86_fp80* %8
%79 = load double*, double** %5
%80 = load i32, i32* %10
%81 = sub nsw i32 %80, 1
%82 = add nsw i32 6, %81
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds double, double* %79, i64 %83
%85 = load double, double* %84
%86 = fpext double %85 to x86_fp80
%87 = fmul x86_fp80 %78, %86
%88 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %69, x86_fp80 %77, x86_fp80 %87)
%89 = fptrunc x86_fp80 %88 to double
%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_mroty_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 6
%18 = load double, double* %17
%19 = fpext double %18 to x86_fp80
%20 = fmul x86_fp80 %13, %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 = getelementptr inbounds double, double* %11, i64 3
%24 = load double, double* %23
%25 = getelementptr inbounds double, double* %0, i64 3
store double %24, double* %25
%26 = load double, double* %11
%27 = fpext double %26 to x86_fp80
%28 = load double, double* %17
%29 = fpext double %28 to x86_fp80
%30 = fmul x86_fp80 %12, %29
%31 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %14, x86_fp80 %27, x86_fp80 %30)
%32 = fptrunc x86_fp80 %31 to double
%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 7
%38 = load double, double* %37
%39 = fpext double %38 to x86_fp80
%40 = fmul x86_fp80 %13, %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 = getelementptr inbounds double, double* %11, i64 4
%45 = load double, double* %44
%46 = getelementptr inbounds double, double* %0, i64 4
store double %45, double* %46
%47 = load double, double* %34
%48 = fpext double %47 to x86_fp80
%49 = load double, double* %37
%50 = fpext double %49 to x86_fp80
%51 = fmul x86_fp80 %12, %50
%52 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %14, x86_fp80 %48, x86_fp80 %51)
%53 = fptrunc x86_fp80 %52 to double
%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 8
%59 = load double, double* %58
%60 = fpext double %59 to x86_fp80
%61 = fmul x86_fp80 %13, %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 = getelementptr inbounds double, double* %11, i64 5
%66 = load double, double* %65
%67 = getelementptr inbounds double, double* %0, i64 5
store double %66, double* %67
%68 = load double, double* %55
%69 = fpext double %68 to x86_fp80
%70 = load double, double* %58
%71 = fpext double %70 to x86_fp80
%72 = fmul x86_fp80 %12, %71
%73 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %14, x86_fp80 %69, x86_fp80 %72)
%74 = fptrunc x86_fp80 %73 to double
%75 = getelementptr inbounds double, double* %0, i64 8
store double %74, double* %75
ret void
}