#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);
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];
  }
  for (i = 0; i < 3; ++i) {
    for (j = 0; j < 3; ++j)
      C[i][j] = W[i][j];
  }
}


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    11eb <MatMatModM+0xdb>
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    117e <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    1144 <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    11d8 <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    119b <MatMatModM+0x8b>
jmp    11dd <MatMatModM+0xcd>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1133 <MatMatModM+0x23>
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    1261 <MatMatModM+0x151>
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    124e <MatMatModM+0x13e>
movslq -0x24(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1203 <MatMatModM+0xf3>
jmp    1253 <MatMatModM+0x143>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f2 <MatMatModM+0xe2>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MatMatModM>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x58,%rsp
movsd  %xmm0,0x20(%rsp)
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
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  %xmm0,0x40(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x48(%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    %r14,%rdi
mov    %r12,%rsi
mov    %r12,%rdx
movsd  0x20(%rsp),%xmm0
call   1030 <MatVecModM@plt>
movsd  (%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x38(%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    %r14,%rdi
mov    %r12,%rsi
mov    %r12,%rdx
movsd  0x20(%rsp),%xmm0
call   1030 <MatVecModM@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x40(%rsp),%xmm3
movsd  %xmm3,(%r15)
movsd  0x28(%rsp),%xmm3
movsd  %xmm3,0x8(%r15)
movsd  %xmm0,0x10(%r15)
movsd  0x48(%rsp),%xmm0
movsd  %xmm0,0x18(%r15)
movsd  0x30(%rsp),%xmm0
movsd  %xmm0,0x20(%r15)
movsd  %xmm1,0x28(%r15)
movsd  0x50(%rsp),%xmm0
movsd  %xmm0,0x30(%r15)
movsd  0x38(%rsp),%xmm0
movsd  %xmm0,0x38(%r15)
movsd  %xmm2,0x40(%r15)
add    $0x58,%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
store i32 0, i32* %9
br label %64
64: ; preds = %90, %63
%65 = load i32, i32* %9
%66 = icmp slt i32 %65, 3
br i1 %66, label %67, label %93
67: ; preds = %64
store i32 0, i32* %10
br label %68
68: ; preds = %86, %67
%69 = load i32, i32* %10
%70 = icmp slt i32 %69, 3
br i1 %70, label %71, label %89
71: ; preds = %68
%72 = load i32, i32* %9
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %12, i64 0, i64 %73
%75 = load i32, i32* %10
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [3 x double], [3 x double]* %74, i64 0, i64 %76
%78 = load double, double* %77
%79 = load [3 x double]*, [3 x double]** %7
%80 = load i32, i32* %9
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [3 x double], [3 x double]* %79, i64 %81
%83 = load i32, i32* %10
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [3 x double], [3 x double]* %82, i64 0, i64 %84
store double %78, double* %85
br label %86
86: ; preds = %71
%87 = load i32, i32* %10
%88 = add nsw i32 %87, 1
store i32 %88, i32* %10
br label %68
89: ; preds = %68
br label %90
90: ; preds = %89
%91 = load i32, i32* %9
%92 = add nsw i32 %91, 1
store i32 %92, i32* %9
br label %64
93: ; preds = %64
ret void
}

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