#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);
int /*<<< orphan*/ memcpy(double *, double *, int);
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);
  }
  memcpy(v, x, 3 * sizeof(double));
}


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    1200 <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    1140 <MatVecModM+0x20>
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x18,%edx
call   1040 <memcpy@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MatVecModM>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%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,0x10(%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,0x18(%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  %xmm0,0x20(%rsp)
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
mov    $0x18,%edx
call   1040 <memcpy@plt>
add    $0x30,%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
%69 = load double*, double** %7
%70 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%71 = call i32 @memcpy(double* %69, double* %70, i32 24)
ret void
}

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