#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*/ MatMatModM(double **, double **, double **, double);
void MatTwoPowModM(double A[3][3], double B[3][3], double m, long e) {
  int i, j;
  if (A != B) {
    for (i = 0; i < 3; i++) {
      for (j = 0; j < 3; ++j)
        B[i][j] = A[i][j];
    }
  }
  for (i = 0; i < e; i++)
    MatMatModM(B, B, B, m);
}


x86 assembly (clang, -O0):
<MatTwoPowModM>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     11af <MatTwoPowModM+0x9f>
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    11aa <MatTwoPowModM+0x9a>
movl   $0x0,-0x28(%rbp)
cmpl   $0x3,-0x28(%rbp)
jge    1197 <MatTwoPowModM+0x87>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%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    114f <MatTwoPowModM+0x3f>
jmp    119c <MatTwoPowModM+0x8c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113e <MatTwoPowModM+0x2e>
jmp    11af <MatTwoPowModM+0x9f>
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    11e8 <MatTwoPowModM+0xd8>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rdx
movsd  -0x18(%rbp),%xmm0
call   1030 <MatMatModM@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b6 <MatTwoPowModM+0xa6>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MatTwoPowModM>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
cmp    %rsi,%rdi
je     1180 <MatTwoPowModM+0x70>
movsd  (%rdi),%xmm1
movsd  %xmm1,(%r14)
movsd  0x8(%rdi),%xmm1
movsd  %xmm1,0x8(%r14)
movsd  0x10(%rdi),%xmm1
movsd  %xmm1,0x10(%r14)
movsd  0x18(%rdi),%xmm1
movsd  %xmm1,0x18(%r14)
movsd  0x20(%rdi),%xmm1
movsd  %xmm1,0x20(%r14)
movsd  0x28(%rdi),%xmm1
movsd  %xmm1,0x28(%r14)
movsd  0x30(%rdi),%xmm1
movsd  %xmm1,0x30(%r14)
movsd  0x38(%rdi),%xmm1
movsd  %xmm1,0x38(%r14)
movsd  0x40(%rdi),%xmm1
movsd  %xmm1,0x40(%r14)
test   %rbx,%rbx
jle    11a9 <MatTwoPowModM+0x99>
movsd  %xmm0,(%rsp)
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r14,%rsi
mov    %r14,%rdx
call   1030 <MatMatModM@plt>
movsd  (%rsp),%xmm0
add    $0xffffffffffffffff,%rbx
jne    1190 <MatTwoPowModM+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @MatTwoPowModM([3 x double]* %0, [3 x double]* %1, double %2, i64 %3) {
%5 = icmp eq [3 x double]* %0, %1
br i1 %5, label %34, label %6
6: ; preds = %4
%7 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0
%8 = load double, double* %7
%9 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
store double %8, double* %9
%10 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 1
%11 = load double, double* %10
%12 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 1
store double %11, double* %12
%13 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 2
%14 = load double, double* %13
%15 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 2
store double %14, double* %15
%16 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 0
%17 = load double, double* %16
%18 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 0
store double %17, double* %18
%19 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 1
%20 = load double, double* %19
%21 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 1
store double %20, double* %21
%22 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 2
%23 = load double, double* %22
%24 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 2
store double %23, double* %24
%25 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 0
%26 = load double, double* %25
%27 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 0
store double %26, double* %27
%28 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 1
%29 = load double, double* %28
%30 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 1
store double %29, double* %30
%31 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
%32 = load double, double* %31
%33 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 2
store double %32, double* %33
br label %34
34: ; preds = %6, %4
%35 = icmp sgt i64 %3, 0
br i1 %35, label %36, label %43
36: ; preds = %34
%37 = bitcast [3 x double]* %1 to double**
br label %38
38: ; preds = %36, %38
%39 = phi i64 [ 0, %36 ], [ %41, %38 ]
%40 = tail call i32 @MatMatModM(double** %37, double** %37, double** %37, double %2)
%41 = add nuw nsw i64 %39, 1
%42 = icmp eq i64 %41, %3
br i1 %42, label %43, label %38
43: ; preds = %38, %34
ret void
}