#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 /*<<< orphan*/ memcpy(double *, double *, int);
void mat3_mul_vec(double out[3], double M[3][3], const double v[3]) {
  double t[3];
  t[0] = M[0][0] * v[0] + M[0][1] * v[1] + M[0][2] * v[2];
  t[1] = M[1][0] * v[0] + M[1][1] * v[1] + M[1][2] * v[2];
  t[2] = M[2][0] * v[0] + M[2][1] * v[1] + M[2][2] * v[2];
  memcpy(out, t, sizeof(double) * 3);
}


x86 assembly (clang, -O0):
<mat3_mul_vec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x30(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x38(%rax),%xmm0
mov    -0x18(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x10(%rbp),%rax
movsd  0x40(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x18,%edx
call   1030 <memcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mat3_mul_vec>:
sub    $0x18,%rsp
movsd  (%rdx),%xmm0
movsd  0x8(%rdx),%xmm2
movsd  0x10(%rdx),%xmm1
movapd %xmm2,%xmm3
unpcklpd %xmm2,%xmm3
movsd  (%rsi),%xmm4
movsd  0x8(%rsi),%xmm5
movsd  0x10(%rsi),%xmm6
movhpd 0x20(%rsi),%xmm5
movhpd 0x18(%rsi),%xmm4
mulpd  %xmm3,%xmm5
movapd %xmm0,%xmm3
unpcklpd %xmm0,%xmm3
mulpd  %xmm4,%xmm3
addpd  %xmm5,%xmm3
movhpd 0x28(%rsi),%xmm6
movapd %xmm1,%xmm4
unpcklpd %xmm1,%xmm4
mulpd  %xmm6,%xmm4
addpd  %xmm3,%xmm4
movapd %xmm4,(%rsp)
mulsd  0x38(%rsi),%xmm2
mulsd  0x30(%rsi),%xmm0
addsd  %xmm2,%xmm0
mulsd  0x40(%rsi),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
mov    %rsp,%rsi
mov    $0x18,%edx
call   1030 <memcpy@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define void @mat3_mul_vec(double* %0, [3 x double]* %1, double* %2) {
%4 = alloca double*
%5 = alloca [3 x double]*
%6 = alloca double*
%7 = alloca [3 x double]
store double* %0, double** %4
store [3 x double]* %1, [3 x double]** %5
store double* %2, double** %6
%8 = load [3 x double]*, [3 x double]** %5
%9 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0
%10 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%11 = load double, double* %10
%12 = load double*, double** %6
%13 = getelementptr inbounds double, double* %12, i64 0
%14 = load double, double* %13
%15 = load [3 x double]*, [3 x double]** %5
%16 = getelementptr inbounds [3 x double], [3 x double]* %15, i64 0
%17 = getelementptr inbounds [3 x double], [3 x double]* %16, i64 0, i64 1
%18 = load double, double* %17
%19 = load double*, double** %6
%20 = getelementptr inbounds double, double* %19, i64 1
%21 = load double, double* %20
%22 = fmul double %18, %21
%23 = call double @llvm.fmuladd.f64(double %11, double %14, double %22)
%24 = load [3 x double]*, [3 x double]** %5
%25 = getelementptr inbounds [3 x double], [3 x double]* %24, i64 0
%26 = getelementptr inbounds [3 x double], [3 x double]* %25, i64 0, i64 2
%27 = load double, double* %26
%28 = load double*, double** %6
%29 = getelementptr inbounds double, double* %28, i64 2
%30 = load double, double* %29
%31 = call double @llvm.fmuladd.f64(double %27, double %30, double %23)
%32 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
store double %31, double* %32
%33 = load [3 x double]*, [3 x double]** %5
%34 = getelementptr inbounds [3 x double], [3 x double]* %33, i64 1
%35 = getelementptr inbounds [3 x double], [3 x double]* %34, i64 0, i64 0
%36 = load double, double* %35
%37 = load double*, double** %6
%38 = getelementptr inbounds double, double* %37, i64 0
%39 = load double, double* %38
%40 = load [3 x double]*, [3 x double]** %5
%41 = getelementptr inbounds [3 x double], [3 x double]* %40, i64 1
%42 = getelementptr inbounds [3 x double], [3 x double]* %41, i64 0, i64 1
%43 = load double, double* %42
%44 = load double*, double** %6
%45 = getelementptr inbounds double, double* %44, i64 1
%46 = load double, double* %45
%47 = fmul double %43, %46
%48 = call double @llvm.fmuladd.f64(double %36, double %39, double %47)
%49 = load [3 x double]*, [3 x double]** %5
%50 = getelementptr inbounds [3 x double], [3 x double]* %49, i64 1
%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 = call double @llvm.fmuladd.f64(double %52, double %55, double %48)
%57 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 1
store double %56, double* %57
%58 = load [3 x double]*, [3 x double]** %5
%59 = getelementptr inbounds [3 x double], [3 x double]* %58, i64 2
%60 = getelementptr inbounds [3 x double], [3 x double]* %59, i64 0, i64 0
%61 = load double, double* %60
%62 = load double*, double** %6
%63 = getelementptr inbounds double, double* %62, i64 0
%64 = load double, double* %63
%65 = load [3 x double]*, [3 x double]** %5
%66 = getelementptr inbounds [3 x double], [3 x double]* %65, i64 2
%67 = getelementptr inbounds [3 x double], [3 x double]* %66, i64 0, i64 1
%68 = load double, double* %67
%69 = load double*, double** %6
%70 = getelementptr inbounds double, double* %69, i64 1
%71 = load double, double* %70
%72 = fmul double %68, %71
%73 = call double @llvm.fmuladd.f64(double %61, double %64, double %72)
%74 = load [3 x double]*, [3 x double]** %5
%75 = getelementptr inbounds [3 x double], [3 x double]* %74, i64 2
%76 = getelementptr inbounds [3 x double], [3 x double]* %75, i64 0, i64 2
%77 = load double, double* %76
%78 = load double*, double** %6
%79 = getelementptr inbounds double, double* %78, i64 2
%80 = load double, double* %79
%81 = call double @llvm.fmuladd.f64(double %77, double %80, double %73)
%82 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 2
store double %81, double* %82
%83 = load double*, double** %4
%84 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%85 = call i32 @memcpy(double* %83, double* %84, i32 24)
ret void
}

LLVM IR (-O2):
define void @mat3_mul_vec(double* %0, [3 x double]* nocapture %1, double* nocapture %2) {
%4 = alloca [3 x double]
%5 = bitcast [3 x double]* %4 to i8*
%6 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%7 = load double, double* %6
%8 = load double, double* %2
%9 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 1
%10 = load double, double* %9
%11 = getelementptr inbounds double, double* %2, i64 1
%12 = load double, double* %11
%13 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 2
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %2, i64 2
%16 = load double, double* %15
%17 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%18 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 0
%19 = load double, double* %18
%20 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 1
%21 = load double, double* %20
%22 = insertelement <2 x double> poison, double %12, i64 0
%23 = shufflevector <2 x double> %22, <2 x double> poison, <2 x i32> zeroinitializer
%24 = insertelement <2 x double> poison, double %10, i64 0
%25 = insertelement <2 x double> %24, double %21, i64 1
%26 = fmul <2 x double> %23, %25
%27 = insertelement <2 x double> poison, double %7, i64 0
%28 = insertelement <2 x double> %27, double %19, i64 1
%29 = insertelement <2 x double> poison, double %8, i64 0
%30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> zeroinitializer
%31 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %28, <2 x double> %30, <2 x double> %26)
%32 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 1, i64 2
%33 = load double, double* %32
%34 = insertelement <2 x double> poison, double %14, i64 0
%35 = insertelement <2 x double> %34, double %33, i64 1
%36 = insertelement <2 x double> poison, double %16, i64 0
%37 = shufflevector <2 x double> %36, <2 x double> poison, <2 x i32> zeroinitializer
%38 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %35, <2 x double> %37, <2 x double> %31)
%39 = bitcast [3 x double]* %4 to <2 x double>*
store <2 x double> %38, <2 x double>* %39
%40 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 0
%41 = load double, double* %40
%42 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 1
%43 = load double, double* %42
%44 = fmul double %12, %43
%45 = tail call double @llvm.fmuladd.f64(double %41, double %8, double %44)
%46 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 2, i64 2
%47 = load double, double* %46
%48 = tail call double @llvm.fmuladd.f64(double %47, double %16, double %45)
%49 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
store double %48, double* %49
%50 = call i32 @memcpy(double* %0, double* %17, i32 24)
ret void
}