#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_mrotx_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))] = 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_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_mrotx_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     125d <cmatrix_mrotx_l+0x12d>
mov    -0x10(%rbp),%rax
mov    -0x94(%rbp),%ecx
add    $0xffffffff,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax,%rcx,8)
fldt   -0x80(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x94(%rbp),%ecx
add    $0xffffffff,%ecx
movslq %ecx,%rcx
fldl   0x18(%rax,%rcx,8)
fldt   -0x90(%rbp)
fldl   0x30(%rax,%rcx,8)
fmulp  %st,%st(1)
fxch   %st(2)
fmulp  %st,%st(1)
fsubp  %st,%st(1)
mov    -0x8(%rbp),%rax
fstpl  0x18(%rax,%rcx,8)
fldt   -0x90(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x94(%rbp),%ecx
add    $0xffffffff,%ecx
movslq %ecx,%rcx
fldl   0x18(%rax,%rcx,8)
fldt   -0x80(%rbp)
fldl   0x30(%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    $0x6,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    119e <cmatrix_mrotx_l+0x6e>
add    $0xb0,%rsp
pop    %rbp
ret

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

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