#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 */
typedef scalar_t__ z;
typedef scalar_t__ y;
typedef scalar_t__ x;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
void matprod_mat_vec_n3(double *restrict x, double *restrict y,
                        double *restrict z, int k, int add) {
  assert(((uintptr_t)(x) & (1 - 1)) == 0);
  assert(((uintptr_t)(y) & (1 - 1)) == 0);
  assert(((uintptr_t)(z) & (1 - 1)) == 0);
  x = (x);
  y = (y);
  z = (z);
  {
    double s[3];
    if (add) {
      s[0] = z[0];
      s[1] = z[1];
      s[2] = z[2];
    } else
      s[0] = s[1] = s[2] = 0;
    while (k > 1) {
      s[0] = (s[0] + (x[0] * y[0])) + (x[3] * y[1]);
      s[1] = (s[1] + (x[1] * y[0])) + (x[4] * y[1]);
      s[2] = (s[2] + (x[2] * y[0])) + (x[5] * y[1]);
      x += 6;
      y += 2;
      k -= 2;
    }
    if (k >= 1) {
      s[0] += x[0] * y[0];
      s[1] += x[1] * y[0];
      s[2] += x[2] * y[0];
    }
    z[0] = s[0];
    z[1] = s[1];
    z[2] = s[2];
  }
}


x86 assembly (clang, -O0):
<matprod_mat_vec_n3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x8(%rbp),%rax
and    $0x0,%rax
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
and    $0x0,%rax
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rax
and    $0x0,%rax
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     11c6 <matprod_mat_vec_n3+0xb6>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11de <matprod_mat_vec_n3+0xce>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11e3 <matprod_mat_vec_n3+0xd3>
cmpl   $0x1,-0x1c(%rbp)
jle    12c9 <matprod_mat_vec_n3+0x1b9>
movsd  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x8(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e3 <matprod_mat_vec_n3+0xd3>
cmpl   $0x1,-0x1c(%rbp)
jl     133b <matprod_mat_vec_n3+0x22b>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matprod_mat_vec_n3>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r12d
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
test   %r12d,%r12d
je     1194 <matprod_mat_vec_n3+0x84>
movupd (%r14),%xmm1
movsd  0x10(%r14),%xmm0
cmp    $0x2,%ebp
jge    11b0 <matprod_mat_vec_n3+0xa0>
cmp    $0x1,%ebp
jne    1180 <matprod_mat_vec_n3+0x70>
movsd  (%r15),%xmm2
movupd (%rbx),%xmm3
movapd %xmm2,%xmm4
unpcklpd %xmm2,%xmm4
mulpd  %xmm3,%xmm4
addpd  %xmm4,%xmm1
mulsd  0x10(%rbx),%xmm2
addsd  %xmm2,%xmm0
movupd %xmm1,(%r14)
movsd  %xmm0,0x10(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xorpd  %xmm1,%xmm1
xorpd  %xmm0,%xmm0
cmp    $0x2,%ebp
jl     1159 <matprod_mat_vec_n3+0x49>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%eax
movsd  (%r15),%xmm4
movapd %xmm4,%xmm2
mulsd  0x10(%rbx),%xmm4
addsd  %xmm0,%xmm4
movsd  0x8(%r15),%xmm0
movupd (%rbx),%xmm3
movupd 0x18(%rbx),%xmm5
unpcklpd %xmm2,%xmm2
mulpd  %xmm3,%xmm2
addpd  %xmm1,%xmm2
movapd %xmm0,%xmm3
unpcklpd %xmm0,%xmm3
mulpd  %xmm5,%xmm3
movapd %xmm3,%xmm1
addpd  %xmm2,%xmm1
mulsd  0x28(%rbx),%xmm0
addsd  %xmm4,%xmm0
add    $0x30,%rbx
add    $0x10,%r15
lea    -0x2(%rax),%ebp
cmp    $0x3,%eax
ja     11b0 <matprod_mat_vec_n3+0xa0>
addpd  %xmm2,%xmm3
movapd %xmm3,%xmm1
cmp    $0x1,%ebp
je     115e <matprod_mat_vec_n3+0x4e>
jmp    1180 <matprod_mat_vec_n3+0x70>

LLVM IR (-O0):
define void @matprod_mat_vec_n3(double* noalias %0, double* noalias %1, double* noalias %2, i32 %3, i32 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca [3 x double]
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load double*, double** %6
%13 = ptrtoint double* %12 to i64
%14 = and i64 %13, 0
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load double*, double** %7
%19 = ptrtoint double* %18 to i64
%20 = and i64 %19, 0
%21 = icmp eq i64 %20, 0
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load double*, double** %8
%25 = ptrtoint double* %24 to i64
%26 = and i64 %25, 0
%27 = icmp eq i64 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = load double*, double** %6
store double* %30, double** %6
%31 = load double*, double** %7
store double* %31, double** %7
%32 = load double*, double** %8
store double* %32, double** %8
%33 = load i32, i32* %10
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %48
35: ; preds = %5
%36 = load double*, double** %8
%37 = getelementptr inbounds double, double* %36, i64 0
%38 = load double, double* %37
%39 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
store double %38, double* %39
%40 = load double*, double** %8
%41 = getelementptr inbounds double, double* %40, i64 1
%42 = load double, double* %41
%43 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
store double %42, double* %43
%44 = load double*, double** %8
%45 = getelementptr inbounds double, double* %44, i64 2
%46 = load double, double* %45
%47 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
store double %46, double* %47
br label %52
48: ; preds = %5
%49 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
store double 0.000000e+00, double* %49
%50 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
store double 0.000000e+00, double* %50
%51 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
store double 0.000000e+00, double* %51
br label %52
52: ; preds = %48, %35
br label %53
53: ; preds = %56, %52
%54 = load i32, i32* %9
%55 = icmp sgt i32 %54, 1
br i1 %55, label %56, label %114
56: ; preds = %53
%57 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%58 = load double, double* %57
%59 = load double*, double** %6
%60 = getelementptr inbounds double, double* %59, i64 0
%61 = load double, double* %60
%62 = load double*, double** %7
%63 = getelementptr inbounds double, double* %62, i64 0
%64 = load double, double* %63
%65 = call double @llvm.fmuladd.f64(double %61, double %64, double %58)
%66 = load double*, double** %6
%67 = getelementptr inbounds double, double* %66, i64 3
%68 = load double, double* %67
%69 = load double*, double** %7
%70 = getelementptr inbounds double, double* %69, i64 1
%71 = load double, double* %70
%72 = call double @llvm.fmuladd.f64(double %68, double %71, double %65)
%73 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
store double %72, double* %73
%74 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
%75 = load double, double* %74
%76 = load double*, double** %6
%77 = getelementptr inbounds double, double* %76, i64 1
%78 = load double, double* %77
%79 = load double*, double** %7
%80 = getelementptr inbounds double, double* %79, i64 0
%81 = load double, double* %80
%82 = call double @llvm.fmuladd.f64(double %78, double %81, double %75)
%83 = load double*, double** %6
%84 = getelementptr inbounds double, double* %83, i64 4
%85 = load double, double* %84
%86 = load double*, double** %7
%87 = getelementptr inbounds double, double* %86, i64 1
%88 = load double, double* %87
%89 = call double @llvm.fmuladd.f64(double %85, double %88, double %82)
%90 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
store double %89, double* %90
%91 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
%92 = load double, double* %91
%93 = load double*, double** %6
%94 = getelementptr inbounds double, double* %93, i64 2
%95 = load double, double* %94
%96 = load double*, double** %7
%97 = getelementptr inbounds double, double* %96, i64 0
%98 = load double, double* %97
%99 = call double @llvm.fmuladd.f64(double %95, double %98, double %92)
%100 = load double*, double** %6
%101 = getelementptr inbounds double, double* %100, i64 5
%102 = load double, double* %101
%103 = load double*, double** %7
%104 = getelementptr inbounds double, double* %103, i64 1
%105 = load double, double* %104
%106 = call double @llvm.fmuladd.f64(double %102, double %105, double %99)
%107 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
store double %106, double* %107
%108 = load double*, double** %6
%109 = getelementptr inbounds double, double* %108, i64 6
store double* %109, double** %6
%110 = load double*, double** %7
%111 = getelementptr inbounds double, double* %110, i64 2
store double* %111, double** %7
%112 = load i32, i32* %9
%113 = sub nsw i32 %112, 2
store i32 %113, i32* %9
br label %53
114: ; preds = %53
%115 = load i32, i32* %9
%116 = icmp sge i32 %115, 1
br i1 %116, label %117, label %145
117: ; preds = %114
%118 = load double*, double** %6
%119 = getelementptr inbounds double, double* %118, i64 0
%120 = load double, double* %119
%121 = load double*, double** %7
%122 = getelementptr inbounds double, double* %121, i64 0
%123 = load double, double* %122
%124 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%125 = load double, double* %124
%126 = call double @llvm.fmuladd.f64(double %120, double %123, double %125)
store double %126, double* %124
%127 = load double*, double** %6
%128 = getelementptr inbounds double, double* %127, i64 1
%129 = load double, double* %128
%130 = load double*, double** %7
%131 = getelementptr inbounds double, double* %130, i64 0
%132 = load double, double* %131
%133 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
%134 = load double, double* %133
%135 = call double @llvm.fmuladd.f64(double %129, double %132, double %134)
store double %135, double* %133
%136 = load double*, double** %6
%137 = getelementptr inbounds double, double* %136, i64 2
%138 = load double, double* %137
%139 = load double*, double** %7
%140 = getelementptr inbounds double, double* %139, i64 0
%141 = load double, double* %140
%142 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
%143 = load double, double* %142
%144 = call double @llvm.fmuladd.f64(double %138, double %141, double %143)
store double %144, double* %142
br label %145
145: ; preds = %117, %114
%146 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%147 = load double, double* %146
%148 = load double*, double** %8
%149 = getelementptr inbounds double, double* %148, i64 0
store double %147, double* %149
%150 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
%151 = load double, double* %150
%152 = load double*, double** %8
%153 = getelementptr inbounds double, double* %152, i64 1
store double %151, double* %153
%154 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
%155 = load double, double* %154
%156 = load double*, double** %8
%157 = getelementptr inbounds double, double* %156, i64 2
store double %155, double* %157
ret void
}

LLVM IR (-O2):
define void @matprod_mat_vec_n3(double* noalias nocapture %0, double* noalias nocapture %1, double* noalias nocapture %2, i32 %3, i32 %4) {
%6 = tail call i32 @assert(i32 1)
%7 = tail call i32 @assert(i32 1)
%8 = tail call i32 @assert(i32 1)
%9 = icmp eq i32 %4, 0
br i1 %9, label %15, label %10
10: ; preds = %5
%11 = bitcast double* %2 to <2 x double>*
%12 = load <2 x double>, <2 x double>* %11
%13 = getelementptr inbounds double, double* %2, i64 2
%14 = load double, double* %13
br label %15
15: ; preds = %5, %10
%16 = phi double [ %14, %10 ], [ 0.000000e+00, %5 ]
%17 = phi <2 x double> [ %12, %10 ], [ zeroinitializer, %5 ]
%18 = icmp sgt i32 %3, 1
br i1 %18, label %19, label %52
19: ; preds = %15, %19
%20 = phi double [ %44, %19 ], [ %16, %15 ]
%21 = phi double* [ %45, %19 ], [ %0, %15 ]
%22 = phi i32 [ %47, %19 ], [ %3, %15 ]
%23 = phi double* [ %46, %19 ], [ %1, %15 ]
%24 = phi <2 x double> [ %38, %19 ], [ %17, %15 ]
%25 = load double, double* %23
%26 = getelementptr inbounds double, double* %21, i64 3
%27 = getelementptr inbounds double, double* %23, i64 1
%28 = load double, double* %27
%29 = bitcast double* %21 to <2 x double>*
%30 = load <2 x double>, <2 x double>* %29
%31 = insertelement <2 x double> poison, double %25, i64 0
%32 = shufflevector <2 x double> %31, <2 x double> poison, <2 x i32> zeroinitializer
%33 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %30, <2 x double> %32, <2 x double> %24)
%34 = bitcast double* %26 to <2 x double>*
%35 = load <2 x double>, <2 x double>* %34
%36 = insertelement <2 x double> poison, double %28, 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> %33)
%39 = getelementptr inbounds double, double* %21, i64 2
%40 = load double, double* %39
%41 = tail call double @llvm.fmuladd.f64(double %40, double %25, double %20)
%42 = getelementptr inbounds double, double* %21, i64 5
%43 = load double, double* %42
%44 = tail call double @llvm.fmuladd.f64(double %43, double %28, double %41)
%45 = getelementptr inbounds double, double* %21, i64 6
%46 = getelementptr inbounds double, double* %23, i64 2
%47 = add nsw i32 %22, -2
%48 = icmp ugt i32 %22, 3
br i1 %48, label %19, label %49
49: ; preds = %19
%50 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %30, <2 x double> %32, <2 x double> %24)
%51 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %35, <2 x double> %37, <2 x double> %50)
br label %52
52: ; preds = %49, %15
%53 = phi double* [ %1, %15 ], [ %46, %49 ]
%54 = phi i32 [ %3, %15 ], [ %47, %49 ]
%55 = phi double* [ %0, %15 ], [ %45, %49 ]
%56 = phi double [ %16, %15 ], [ %44, %49 ]
%57 = phi <2 x double> [ %17, %15 ], [ %51, %49 ]
%58 = icmp eq i32 %54, 1
br i1 %58, label %59, label %69
59: ; preds = %52
%60 = load double, double* %53
%61 = bitcast double* %55 to <2 x double>*
%62 = load <2 x double>, <2 x double>* %61
%63 = insertelement <2 x double> poison, double %60, i64 0
%64 = shufflevector <2 x double> %63, <2 x double> poison, <2 x i32> zeroinitializer
%65 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %62, <2 x double> %64, <2 x double> %57)
%66 = getelementptr inbounds double, double* %55, i64 2
%67 = load double, double* %66
%68 = tail call double @llvm.fmuladd.f64(double %67, double %60, double %56)
br label %69
69: ; preds = %59, %52
%70 = phi double [ %68, %59 ], [ %56, %52 ]
%71 = phi <2 x double> [ %65, %59 ], [ %57, %52 ]
%72 = bitcast double* %2 to <2 x double>*
store <2 x double> %71, <2 x double>* %72
%73 = getelementptr inbounds double, double* %2, i64 2
store double %70, double* %73
ret void
}