#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 */
float Round(float);
void MatrixMultiply(float mat1[3][3], float mat2[3][3], float result[3][3]) {
  int i, j, k;
  float sum = 0;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      sum = 0;
      for (k = 0; k < 3; k++)
        sum = Round(sum + mat1[i][k] * mat2[k][j]);
      result[i][j] = sum;
    }
  }
}


x86 assembly (clang, -O0):
<MatrixMultiply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    11fa <MatrixMultiply+0xea>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    11e7 <MatrixMultiply+0xd7>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    11bc <MatrixMultiply+0xac>
movss  -0x28(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <Round@plt>
movss  %xmm0,-0x28(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115d <MatrixMultiply+0x4d>
movss  -0x28(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1144 <MatrixMultiply+0x34>
jmp    11ec <MatrixMultiply+0xdc>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1133 <MatrixMultiply+0x23>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MatrixMultiply>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    $0x8,%ebx
cs nopw 0x0(%rax,%rax,1)
movss  -0x8(%r12,%rbx,1),%xmm0
mulss  (%r15),%xmm0
xorps  %xmm1,%xmm1
addss  %xmm1,%xmm0
call   1030 <Round@plt>
movss  -0x4(%r12,%rbx,1),%xmm1
mulss  0xc(%r15),%xmm1
addss  %xmm1,%xmm0
call   1030 <Round@plt>
movss  (%r12,%rbx,1),%xmm1
mulss  0x18(%r15),%xmm1
addss  %xmm1,%xmm0
call   1030 <Round@plt>
movss  %xmm0,-0x8(%r14,%rbx,1)
movss  -0x8(%r12,%rbx,1),%xmm0
mulss  0x4(%r15),%xmm0
addss  0xe71(%rip),%xmm0
call   1030 <Round@plt>
movss  -0x4(%r12,%rbx,1),%xmm1
mulss  0x10(%r15),%xmm1
addss  %xmm1,%xmm0
call   1030 <Round@plt>
movss  (%r12,%rbx,1),%xmm1
mulss  0x1c(%r15),%xmm1
addss  %xmm1,%xmm0
call   1030 <Round@plt>
movss  %xmm0,-0x4(%r14,%rbx,1)
movss  -0x8(%r12,%rbx,1),%xmm0
mulss  0x8(%r15),%xmm0
addss  0xe25(%rip),%xmm0
call   1030 <Round@plt>
movss  -0x4(%r12,%rbx,1),%xmm1
mulss  0x14(%r15),%xmm1
addss  %xmm1,%xmm0
call   1030 <Round@plt>
movss  (%r12,%rbx,1),%xmm1
mulss  0x20(%r15),%xmm1
addss  %xmm1,%xmm0
call   1030 <Round@plt>
movss  %xmm0,(%r14,%rbx,1)
add    $0xc,%rbx
cmp    $0x2c,%rbx
jne    1130 <MatrixMultiply+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @MatrixMultiply([3 x float]* nocapture %0, [3 x float]* nocapture %1, [3 x float]* nocapture writeonly %2) {
%4 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 0
%5 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 1, i64 0
%6 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 2, i64 0
%7 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 1
%8 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 1, i64 1
%9 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 2, i64 1
%10 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 2
%11 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 1, i64 2
%12 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 2, i64 2
br label %13
13: ; preds = %3, %13
%14 = phi i64 [ 0, %3 ], [ %57, %13 ]
%15 = getelementptr inbounds [3 x float], [3 x float]* %0, i64 %14, i64 0
%16 = load float, float* %15
%17 = load float, float* %4
%18 = tail call float @llvm.fmuladd.f32(float %16, float %17, float 0.000000e+00)
%19 = tail call float @Round(float %18)
%20 = getelementptr inbounds [3 x float], [3 x float]* %0, i64 %14, i64 1
%21 = load float, float* %20
%22 = load float, float* %5
%23 = tail call float @llvm.fmuladd.f32(float %21, float %22, float %19)
%24 = tail call float @Round(float %23)
%25 = getelementptr inbounds [3 x float], [3 x float]* %0, i64 %14, i64 2
%26 = load float, float* %25
%27 = load float, float* %6
%28 = tail call float @llvm.fmuladd.f32(float %26, float %27, float %24)
%29 = tail call float @Round(float %28)
%30 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 %14, i64 0
store float %29, float* %30
%31 = load float, float* %15
%32 = load float, float* %7
%33 = tail call float @llvm.fmuladd.f32(float %31, float %32, float 0.000000e+00)
%34 = tail call float @Round(float %33)
%35 = load float, float* %20
%36 = load float, float* %8
%37 = tail call float @llvm.fmuladd.f32(float %35, float %36, float %34)
%38 = tail call float @Round(float %37)
%39 = load float, float* %25
%40 = load float, float* %9
%41 = tail call float @llvm.fmuladd.f32(float %39, float %40, float %38)
%42 = tail call float @Round(float %41)
%43 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 %14, i64 1
store float %42, float* %43
%44 = load float, float* %15
%45 = load float, float* %10
%46 = tail call float @llvm.fmuladd.f32(float %44, float %45, float 0.000000e+00)
%47 = tail call float @Round(float %46)
%48 = load float, float* %20
%49 = load float, float* %11
%50 = tail call float @llvm.fmuladd.f32(float %48, float %49, float %47)
%51 = tail call float @Round(float %50)
%52 = load float, float* %25
%53 = load float, float* %12
%54 = tail call float @llvm.fmuladd.f32(float %52, float %53, float %51)
%55 = tail call float @Round(float %54)
%56 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 %14, i64 2
store float %55, float* %56
%57 = add nuw nsw i64 %14, 1
%58 = icmp eq i64 %57, 3
br i1 %58, label %59, label %13
59: ; preds = %13
ret void
}