#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 dot(int *, int *);
int /*<<< orphan*/ mRotate(int *, int *);
void mMultiply(int *outputMatrix, int *inputMatrix1, int *inputMatrix2) {
  int i;
  int j;
  int bufferMatrix[9];
  int rotateMatrix[9];
  mRotate(rotateMatrix, inputMatrix1);
  for (j = 0; j < 3; j++) {
    for (i = 0; i < 3; i++) {
      bufferMatrix[i + (j * 3)] =
          dot(&rotateMatrix[i * 3], &inputMatrix2[j * 3]);
    }
  }
  for (i = 0; i < 9; i++) {
    outputMatrix[i] = bufferMatrix[i];
  }
}


x86 assembly (clang, -O0):
<mMultiply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <mRotate@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    11bf <mMultiply+0x9f>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    11ac <mMultiply+0x8c>
imul   $0x3,-0x1c(%rbp),%eax
cltq
lea    -0x80(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
imul   $0x3,-0x20(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <dot@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
imul   $0x3,-0x20(%rbp),%edx
add    %edx,%eax
cltq
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115c <mMultiply+0x3c>
jmp    11b1 <mMultiply+0x91>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114b <mMultiply+0x2b>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x9,-0x1c(%rbp)
jge    11f1 <mMultiply+0xd1>
movslq -0x1c(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c6 <mMultiply+0xa6>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mMultiply>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%rbx
mov    %rdi,%r14
lea    0x10(%rsp),%r15
mov    %r15,%rdi
call   1040 <mRotate@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <dot@plt>
mov    %eax,0xc(%rsp)
lea    0x1c(%rsp),%r13
mov    %r13,%rdi
mov    %rbx,%rsi
call   1030 <dot@plt>
mov    %eax,0x8(%rsp)
lea    0x28(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <dot@plt>
mov    %eax,0x4(%rsp)
lea    0xc(%rbx),%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <dot@plt>
mov    %eax,(%rsp)
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <dot@plt>
mov    %eax,%r13d
mov    %rbp,%rdi
mov    %r12,%rsi
call   1030 <dot@plt>
mov    %eax,%r12d
add    $0x18,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <dot@plt>
mov    %eax,%r15d
lea    0x1c(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <dot@plt>
mov    %eax,%ebp
lea    0x28(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <dot@plt>
mov    0xc(%rsp),%ecx
mov    %ecx,(%r14)
mov    0x8(%rsp),%ecx
mov    %ecx,0x4(%r14)
mov    0x4(%rsp),%ecx
mov    %ecx,0x8(%r14)
mov    (%rsp),%ecx
mov    %ecx,0xc(%r14)
mov    %r13d,0x10(%r14)
mov    %r12d,0x14(%r14)
mov    %r15d,0x18(%r14)
mov    %ebp,0x1c(%r14)
mov    %eax,0x20(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @mMultiply(i32* nocapture writeonly %0, i32* %1, i32* %2) {
%4 = alloca [9 x i32]
%5 = bitcast [9 x i32]* %4 to i8*
%6 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 0
%7 = call i32 @mRotate(i32* %6, i32* %1)
%8 = call i32 @dot(i32* %6, i32* %2)
%9 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 3
%10 = call i32 @dot(i32* %9, i32* %2)
%11 = getelementptr inbounds [9 x i32], [9 x i32]* %4, i64 0, i64 6
%12 = call i32 @dot(i32* %11, i32* %2)
%13 = getelementptr inbounds i32, i32* %2, i64 3
%14 = call i32 @dot(i32* %6, i32* %13)
%15 = call i32 @dot(i32* %9, i32* %13)
%16 = call i32 @dot(i32* %11, i32* %13)
%17 = getelementptr inbounds i32, i32* %2, i64 6
%18 = call i32 @dot(i32* %6, i32* %17)
%19 = call i32 @dot(i32* %9, i32* %17)
%20 = call i32 @dot(i32* %11, i32* %17)
store i32 %8, i32* %0
%21 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %10, i32* %21
%22 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %12, i32* %22
%23 = getelementptr inbounds i32, i32* %0, i64 3
store i32 %14, i32* %23
%24 = getelementptr inbounds i32, i32* %0, i64 4
store i32 %15, i32* %24
%25 = getelementptr inbounds i32, i32* %0, i64 5
store i32 %16, i32* %25
%26 = getelementptr inbounds i32, i32* %0, i64 6
store i32 %18, i32* %26
%27 = getelementptr inbounds i32, i32* %0, i64 7
store i32 %19, i32* %27
%28 = getelementptr inbounds i32, i32* %0, i64 8
store i32 %20, i32* %28
ret void
}