#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 MatrixScalarMultiply(float x, float mat[3][3], float result[3][3]) {
  int i, j;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      result[i][j] = Round(mat[i][j] * x);
    }
  }
}


x86 assembly (clang, -O0):
<MatrixScalarMultiply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    11a2 <MatrixScalarMultiply+0x92>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    118f <MatrixScalarMultiply+0x7f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mulss  -0x4(%rbp),%xmm0
call   1030 <Round@plt>
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    113d <MatrixScalarMultiply+0x2d>
jmp    1194 <MatrixScalarMultiply+0x84>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112c <MatrixScalarMultiply+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MatrixScalarMultiply>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movaps %xmm0,%xmm1
movss  %xmm0,0x4(%rsp)
movss  (%rdi),%xmm0
mulss  %xmm1,%xmm0
call   1030 <Round@plt>
movss  %xmm0,(%r14)
movss  0x4(%rbx),%xmm0
mulss  0x4(%rsp),%xmm0
call   1030 <Round@plt>
movss  %xmm0,0x4(%r14)
movss  0x8(%rbx),%xmm0
mulss  0x4(%rsp),%xmm0
call   1030 <Round@plt>
movss  %xmm0,0x8(%r14)
movss  0xc(%rbx),%xmm0
mulss  0x4(%rsp),%xmm0
call   1030 <Round@plt>
movss  %xmm0,0xc(%r14)
movss  0x10(%rbx),%xmm0
mulss  0x4(%rsp),%xmm0
call   1030 <Round@plt>
movss  %xmm0,0x10(%r14)
movss  0x14(%rbx),%xmm0
mulss  0x4(%rsp),%xmm0
call   1030 <Round@plt>
movss  %xmm0,0x14(%r14)
movss  0x18(%rbx),%xmm0
mulss  0x4(%rsp),%xmm0
call   1030 <Round@plt>
movss  %xmm0,0x18(%r14)
movss  0x1c(%rbx),%xmm0
mulss  0x4(%rsp),%xmm0
call   1030 <Round@plt>
movss  %xmm0,0x1c(%r14)
movss  0x4(%rsp),%xmm0
mulss  0x20(%rbx),%xmm0
call   1030 <Round@plt>
movss  %xmm0,0x20(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @MatrixScalarMultiply(float %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 = load float, float* %4
%6 = fmul float %5, %0
%7 = tail call float @Round(float %6)
%8 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 0
store float %7, float* %8
%9 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 1
%10 = load float, float* %9
%11 = fmul float %10, %0
%12 = tail call float @Round(float %11)
%13 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 1
store float %12, float* %13
%14 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 0, i64 2
%15 = load float, float* %14
%16 = fmul float %15, %0
%17 = tail call float @Round(float %16)
%18 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 0, i64 2
store float %17, float* %18
%19 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 1, i64 0
%20 = load float, float* %19
%21 = fmul float %20, %0
%22 = tail call float @Round(float %21)
%23 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 1, i64 0
store float %22, float* %23
%24 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 1, i64 1
%25 = load float, float* %24
%26 = fmul float %25, %0
%27 = tail call float @Round(float %26)
%28 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 1, i64 1
store float %27, float* %28
%29 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 1, i64 2
%30 = load float, float* %29
%31 = fmul float %30, %0
%32 = tail call float @Round(float %31)
%33 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 1, i64 2
store float %32, float* %33
%34 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 2, i64 0
%35 = load float, float* %34
%36 = fmul float %35, %0
%37 = tail call float @Round(float %36)
%38 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 2, i64 0
store float %37, float* %38
%39 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 2, i64 1
%40 = load float, float* %39
%41 = fmul float %40, %0
%42 = tail call float @Round(float %41)
%43 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 2, i64 1
store float %42, float* %43
%44 = getelementptr inbounds [3 x float], [3 x float]* %1, i64 2, i64 2
%45 = load float, float* %44
%46 = fmul float %45, %0
%47 = tail call float @Round(float %46)
%48 = getelementptr inbounds [3 x float], [3 x float]* %2, i64 2, i64 2
store float %47, float* %48
ret void
}