#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 */

/* Variables and functions */
int /*<<< orphan*/ MatVecModM(double **, double *, double *, double);
int /*<<< orphan*/ memcpy(double **, double **, int);
void MatMatModM(double A[3][3], double B[3][3], double C[3][3], double m) {
  int i, j;
  double V[3], W[3][3];
  for (i = 0; i < 3; ++i) {
    for (j = 0; j < 3; ++j)
      V[j] = B[j][i];
    MatVecModM(A, V, V, m);
    for (j = 0; j < 3; ++j)
      W[j][i] = V[j];
  }
  memcpy(C, W, 9 * sizeof(double));
}


x86 assembly (clang, -O0):
<MatMatModM>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    11fb <MatMatModM+0xdb>
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    118e <MatMatModM+0x6e>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x28(%rbp),%rax
movsd  %xmm0,-0x40(%rbp,%rax,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1154 <MatMatModM+0x34>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x40(%rbp),%rdx
movsd  -0x20(%rbp),%xmm0
call   1030 <MatVecModM@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    11e8 <MatMatModM+0xc8>
movslq -0x28(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm0
movslq -0x28(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ab <MatMatModM+0x8b>
jmp    11ed <MatMatModM+0xcd>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1143 <MatMatModM+0x23>
mov    -0x18(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    $0x48,%edx
call   1040 <memcpy@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MatMatModM>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
movsd  %xmm0,0x18(%rsp)
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
movsd  (%rsi),%xmm1
movsd  %xmm1,(%rsp)
movsd  0x18(%rsi),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x30(%rsi),%xmm1
movsd  %xmm1,0x10(%rsp)
mov    %rsp,%r12
mov    %r12,%rsi
mov    %r12,%rdx
call   1030 <MatVecModM@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  %xmm0,0x20(%rsp)
movsd  %xmm1,0x38(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x50(%rsp)
movsd  0x8(%rbx),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x20(%rbx),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x38(%rbx),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r12,%rdx
movsd  0x18(%rsp),%xmm0
call   1030 <MatVecModM@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  %xmm0,0x28(%rsp)
movsd  %xmm1,0x40(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x58(%rsp)
movsd  0x10(%rbx),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x28(%rbx),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x40(%rbx),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r12,%rdx
movsd  0x18(%rsp),%xmm0
call   1030 <MatVecModM@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  %xmm0,0x30(%rsp)
movsd  %xmm1,0x48(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x60(%rsp)
lea    0x20(%rsp),%rsi
mov    %r14,%rdi
mov    $0x48,%edx
call   1040 <memcpy@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @MatMatModM([3 x double]* %0, [3 x double]* %1, [3 x double]* %2, double %3) {
%5 = alloca [3 x double]*
%6 = alloca [3 x double]*
%7 = alloca [3 x double]*
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
%11 = alloca [3 x double]
%12 = alloca [3 x [3 x double]]
store [3 x double]* %0, [3 x double]** %5
store [3 x double]* %1, [3 x double]** %6
store [3 x double]* %2, [3 x double]** %7
store double %3, double* %8
store i32 0, i32* %9
br label %13
13: ; preds = %60, %4
%14 = load i32, i32* %9
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %63
16: ; preds = %13
store i32 0, i32* %10
br label %17
17: ; preds = %32, %16
%18 = load i32, i32* %10
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %35
20: ; preds = %17
%21 = load [3 x double]*, [3 x double]** %6
%22 = load i32, i32* %10
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 %23
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [3 x double], [3 x double]* %24, i64 0, i64 %26
%28 = load double, double* %27
%29 = load i32, i32* %10
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 %30
store double %28, double* %31
br label %32
32: ; preds = %20
%33 = load i32, i32* %10
%34 = add nsw i32 %33, 1
store i32 %34, i32* %10
br label %17
35: ; preds = %17
%36 = load [3 x double]*, [3 x double]** %5
%37 = bitcast [3 x double]* %36 to double**
%38 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%39 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%40 = load double, double* %8
%41 = call i32 @MatVecModM(double** %37, double* %38, double* %39, double %40)
store i32 0, i32* %10
br label %42
42: ; preds = %56, %35
%43 = load i32, i32* %10
%44 = icmp slt i32 %43, 3
br i1 %44, label %45, label %59
45: ; preds = %42
%46 = load i32, i32* %10
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 %47
%49 = load double, double* %48
%50 = load i32, i32* %10
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 %51
%53 = load i32, i32* %9
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [3 x double], [3 x double]* %52, i64 0, i64 %54
store double %49, double* %55
br label %56
56: ; preds = %45
%57 = load i32, i32* %10
%58 = add nsw i32 %57, 1
store i32 %58, i32* %10
br label %42
59: ; preds = %42
br label %60
60: ; preds = %59
%61 = load i32, i32* %9
%62 = add nsw i32 %61, 1
store i32 %62, i32* %9
br label %13
63: ; preds = %13
%64 = load [3 x double]*, [3 x double]** %7
%65 = bitcast [3 x double]* %64 to double**
%66 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 0
%67 = bitcast [3 x double]* %66 to double**
%68 = call i32 @memcpy(double** %65, double** %67, i32 72)
ret void
}

LLVM IR (-O2):
define void @MatMatModM([3 x double]* %0, [3 x double]* nocapture %1, [3 x double]* %2, double %3) {
%5 = alloca [3 x double]
%6 = alloca [3 x [3 x double]]
%7 = bitcast [3 x double]* %5 to i8*
%8 = bitcast [3 x [3 x double]]* %6 to i8*
%9 = bitcast [3 x double]* %0 to double**
%10 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%11 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%12 = load double, double* %11
store double %12, double* %10
%13 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 0
%14 = load double, double* %13
%15 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
store double %14, double* %15
%16 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 0
%17 = load double, double* %16
%18 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
store double %17, double* %18
%19 = call i32 @MatVecModM(double** %9, double* %10, double* %10, double %3)
%20 = load double, double* %10
%21 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i64 0, i64 0, i64 0
store double %20, double* %21
%22 = load double, double* %15
%23 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i64 0, i64 1, i64 0
store double %22, double* %23
%24 = load double, double* %18
%25 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i64 0, i64 2, i64 0
store double %24, double* %25
%26 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 1
%27 = load double, double* %26
store double %27, double* %10
%28 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 1
%29 = load double, double* %28
store double %29, double* %15
%30 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 1
%31 = load double, double* %30
store double %31, double* %18
%32 = call i32 @MatVecModM(double** %9, double* %10, double* %10, double %3)
%33 = load double, double* %10
%34 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i64 0, i64 0, i64 1
store double %33, double* %34
%35 = load double, double* %15
%36 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i64 0, i64 1, i64 1
store double %35, double* %36
%37 = load double, double* %18
%38 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i64 0, i64 2, i64 1
store double %37, double* %38
%39 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 2
%40 = load double, double* %39
store double %40, double* %10
%41 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 2
%42 = load double, double* %41
store double %42, double* %15
%43 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 2
%44 = load double, double* %43
store double %44, double* %18
%45 = call i32 @MatVecModM(double** %9, double* %10, double* %10, double %3)
%46 = load double, double* %10
%47 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i64 0, i64 0, i64 2
store double %46, double* %47
%48 = load double, double* %15
%49 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i64 0, i64 1, i64 2
store double %48, double* %49
%50 = load double, double* %18
%51 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %6, i64 0, i64 2, i64 2
store double %50, double* %51
%52 = bitcast [3 x double]* %2 to double**
%53 = bitcast [3 x [3 x double]]* %6 to double**
%54 = call i32 @memcpy(double** %52, double** %53, i32 72)
ret void
}