#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 */
double MultModM(double, double, double, double);
void MatVecModM(double A[3][3], double s[3], double v[3], double m) {
  int i;
  double x[3];
  for (i = 0; i < 3; ++i) {
    x[i] = MultModM(A[i][0], s[0], 0.0, m);
    x[i] = MultModM(A[i][1], s[1], x[i], m);
    x[i] = MultModM(A[i][2], s[2], x[i], m);
  }
  for (i = 0; i < 3; ++i)
    v[i] = x[i];
}


x86 assembly (clang, -O0):
<MatVecModM>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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    11f0 <MatVecModM+0xe0>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x20(%rbp),%xmm3
xorps  %xmm2,%xmm2
call   1030 <MultModM@plt>
movslq -0x24(%rbp),%rax
movsd  %xmm0,-0x40(%rbp,%rax,8)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
movslq -0x24(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm2
movsd  -0x20(%rbp),%xmm3
call   1030 <MultModM@plt>
movslq -0x24(%rbp),%rax
movsd  %xmm0,-0x40(%rbp,%rax,8)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
movslq -0x24(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm2
movsd  -0x20(%rbp),%xmm3
call   1030 <MultModM@plt>
movslq -0x24(%rbp),%rax
movsd  %xmm0,-0x40(%rbp,%rax,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1130 <MatVecModM+0x20>
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    1226 <MatVecModM+0x116>
movslq -0x24(%rbp),%rax
movsd  -0x40(%rbp,%rax,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f7 <MatVecModM+0xe7>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MatVecModM>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movaps %xmm0,%xmm3
movsd  %xmm0,0x8(%rsp)
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
movsd  (%rsi),%xmm1
xorps  %xmm2,%xmm2
call   1030 <MultModM@plt>
movaps %xmm0,%xmm2
movsd  0x8(%rbx),%xmm0
movsd  0x8(%r15),%xmm1
movsd  0x8(%rsp),%xmm3
call   1030 <MultModM@plt>
movaps %xmm0,%xmm2
movsd  0x10(%rbx),%xmm0
movsd  0x10(%r15),%xmm1
movsd  0x8(%rsp),%xmm3
call   1030 <MultModM@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x18(%rbx),%xmm0
movsd  (%r15),%xmm1
xorps  %xmm2,%xmm2
movsd  0x8(%rsp),%xmm3
call   1030 <MultModM@plt>
movaps %xmm0,%xmm2
movsd  0x20(%rbx),%xmm0
movsd  0x8(%r15),%xmm1
movsd  0x8(%rsp),%xmm3
call   1030 <MultModM@plt>
movaps %xmm0,%xmm2
movsd  0x28(%rbx),%xmm0
movsd  0x10(%r15),%xmm1
movsd  0x8(%rsp),%xmm3
call   1030 <MultModM@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x30(%rbx),%xmm0
movsd  (%r15),%xmm1
xorps  %xmm2,%xmm2
movsd  0x8(%rsp),%xmm3
call   1030 <MultModM@plt>
movaps %xmm0,%xmm2
movsd  0x38(%rbx),%xmm0
movsd  0x8(%r15),%xmm1
movsd  0x8(%rsp),%xmm3
call   1030 <MultModM@plt>
movaps %xmm0,%xmm2
movsd  0x40(%rbx),%xmm0
movsd  0x10(%r15),%xmm1
movsd  0x8(%rsp),%xmm3
call   1030 <MultModM@plt>
movsd  0x18(%rsp),%xmm1
movsd  %xmm1,(%r14)
movsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x8(%r14)
movsd  %xmm0,0x10(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @MatVecModM([3 x double]* %0, double* %1, double* %2, double %3) {
%5 = alloca [3 x double]*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double
%9 = alloca i32
%10 = alloca [3 x double]
store [3 x double]* %0, [3 x double]** %5
store double* %1, double** %6
store double* %2, double** %7
store double %3, double* %8
store i32 0, i32* %9
br label %11
11: ; preds = %65, %4
%12 = load i32, i32* %9
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %68
14: ; preds = %11
%15 = load [3 x double]*, [3 x double]** %5
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 %17
%19 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 0, i64 0
%20 = load double, double* %19
%21 = load double*, double** %6
%22 = getelementptr inbounds double, double* %21, i64 0
%23 = load double, double* %22
%24 = load double, double* %8
%25 = call double @MultModM(double %20, double %23, double 0.000000e+00, double %24)
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 %27
store double %25, double* %28
%29 = load [3 x double]*, [3 x double]** %5
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [3 x double], [3 x double]* %29, i64 %31
%33 = getelementptr inbounds [3 x double], [3 x double]* %32, i64 0, i64 1
%34 = load double, double* %33
%35 = load double*, double** %6
%36 = getelementptr inbounds double, double* %35, i64 1
%37 = load double, double* %36
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 %39
%41 = load double, double* %40
%42 = load double, double* %8
%43 = call double @MultModM(double %34, double %37, double %41, double %42)
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 %45
store double %43, double* %46
%47 = load [3 x double]*, [3 x double]** %5
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [3 x double], [3 x double]* %47, i64 %49
%51 = getelementptr inbounds [3 x double], [3 x double]* %50, i64 0, i64 2
%52 = load double, double* %51
%53 = load double*, double** %6
%54 = getelementptr inbounds double, double* %53, i64 2
%55 = load double, double* %54
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 %57
%59 = load double, double* %58
%60 = load double, double* %8
%61 = call double @MultModM(double %52, double %55, double %59, double %60)
%62 = load i32, i32* %9
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 %63
store double %61, double* %64
br label %65
65: ; preds = %14
%66 = load i32, i32* %9
%67 = add nsw i32 %66, 1
store i32 %67, i32* %9
br label %11
68: ; preds = %11
store i32 0, i32* %9
br label %69
69: ; preds = %81, %68
%70 = load i32, i32* %9
%71 = icmp slt i32 %70, 3
br i1 %71, label %72, label %84
72: ; preds = %69
%73 = load i32, i32* %9
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 %74
%76 = load double, double* %75
%77 = load double*, double** %7
%78 = load i32, i32* %9
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %77, i64 %79
store double %76, double* %80
br label %81
81: ; preds = %72
%82 = load i32, i32* %9
%83 = add nsw i32 %82, 1
store i32 %83, i32* %9
br label %69
84: ; preds = %69
ret void
}

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