#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 size_t uint32_t;

/* Variables and functions */
void produce_matrix_vector_product(double a[], double x[], double y[],
                                   uint32_t row, uint32_t column) {
  uint32_t i = 0;
  uint32_t j = 0;
  for (i = 0; i < row; i++) {
    y[i] = 0.0;
    for (j = 0; j < column; j++)
      y[i] += a[i * column + j] * x[j];
  }
}


x86 assembly (clang, -O0):
<produce_matrix_vector_product>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11c8 <produce_matrix_vector_product+0xc8>
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11b2 <produce_matrix_vector_product+0xb2>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
imul   -0x28(%rbp),%rcx
add    -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1156 <produce_matrix_vector_product+0x56>
jmp    11b7 <produce_matrix_vector_product+0xb7>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1130 <produce_matrix_vector_product+0x30>
pop    %rbp
ret

x86 assembly (clang, -O2):
<produce_matrix_vector_product>:
push   %r14
push   %rbx
test   %rcx,%rcx
je     11be <produce_matrix_vector_product+0xbe>
mov    %r8,%r9
and    $0xfffffffffffffffe,%r9
lea    0x8(%rdi),%r11
lea    0x0(,%r8,8),%r10
xor    %r14d,%r14d
jmp    1140 <produce_matrix_vector_product+0x40>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r14
add    %r10,%r11
cmp    %rcx,%r14
je     11be <produce_matrix_vector_product+0xbe>
movq   $0x0,(%rdx,%r14,8)
test   %r8,%r8
je     1130 <produce_matrix_vector_product+0x30>
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
cmp    $0x1,%r8
je     1195 <produce_matrix_vector_product+0x95>
nopl   0x0(%rax)
movsd  -0x8(%r11,%rbx,8),%xmm1
mulsd  (%rsi,%rbx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx,%r14,8)
movsd  (%r11,%rbx,8),%xmm0
mulsd  0x8(%rsi,%rbx,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rdx,%r14,8)
add    $0x2,%rbx
cmp    %rbx,%r9
jne    1160 <produce_matrix_vector_product+0x60>
test   $0x1,%r8b
je     1130 <produce_matrix_vector_product+0x30>
mov    %r14,%rax
imul   %r8,%rax
add    %rbx,%rax
movsd  (%rdi,%rax,8),%xmm1
mulsd  (%rsi,%rbx,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx,%r14,8)
jmp    1130 <produce_matrix_vector_product+0x30>
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @produce_matrix_vector_product(double* %0, double* %1, double* %2, i64 %3, i64 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store i64 %3, i64* %9
store i64 %4, i64* %10
store i64 0, i64* %11
store i64 0, i64* %12
store i64 0, i64* %11
br label %13
13: ; preds = %47, %5
%14 = load i64, i64* %11
%15 = load i64, i64* %9
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %50
17: ; preds = %13
%18 = load double*, double** %8
%19 = load i64, i64* %11
%20 = getelementptr inbounds double, double* %18, i64 %19
store double 0.000000e+00, double* %20
store i64 0, i64* %12
br label %21
21: ; preds = %43, %17
%22 = load i64, i64* %12
%23 = load i64, i64* %10
%24 = icmp ult i64 %22, %23
br i1 %24, label %25, label %46
25: ; preds = %21
%26 = load double*, double** %6
%27 = load i64, i64* %11
%28 = load i64, i64* %10
%29 = mul i64 %27, %28
%30 = load i64, i64* %12
%31 = add i64 %29, %30
%32 = getelementptr inbounds double, double* %26, i64 %31
%33 = load double, double* %32
%34 = load double*, double** %7
%35 = load i64, i64* %12
%36 = getelementptr inbounds double, double* %34, i64 %35
%37 = load double, double* %36
%38 = load double*, double** %8
%39 = load i64, i64* %11
%40 = getelementptr inbounds double, double* %38, i64 %39
%41 = load double, double* %40
%42 = call double @llvm.fmuladd.f64(double %33, double %37, double %41)
store double %42, double* %40
br label %43
43: ; preds = %25
%44 = load i64, i64* %12
%45 = add i64 %44, 1
store i64 %45, i64* %12
br label %21
46: ; preds = %21
br label %47
47: ; preds = %46
%48 = load i64, i64* %11
%49 = add i64 %48, 1
store i64 %49, i64* %11
br label %13
50: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @produce_matrix_vector_product(double* nocapture %0, double* nocapture %1, double* nocapture %2, i64 %3, i64 %4) {
%6 = icmp eq i64 %3, 0
br i1 %6, label %51, label %7
7: ; preds = %5
%8 = icmp eq i64 %4, 0
%9 = and i64 %4, 1
%10 = icmp eq i64 %4, 1
%11 = and i64 %4, -2
%12 = icmp eq i64 %9, 0
br label %13
13: ; preds = %7, %48
%14 = phi i64 [ 0, %7 ], [ %49, %48 ]
%15 = getelementptr inbounds double, double* %2, i64 %14
store double 0.000000e+00, double* %15
br i1 %8, label %48, label %16
16: ; preds = %13
%17 = mul i64 %14, %4
br i1 %10, label %38, label %18
18: ; preds = %16, %18
%19 = phi double [ %34, %18 ], [ 0.000000e+00, %16 ]
%20 = phi i64 [ %35, %18 ], [ 0, %16 ]
%21 = phi i64 [ %36, %18 ], [ 0, %16 ]
%22 = add i64 %20, %17
%23 = getelementptr inbounds double, double* %0, i64 %22
%24 = load double, double* %23
%25 = getelementptr inbounds double, double* %1, i64 %20
%26 = load double, double* %25
%27 = tail call double @llvm.fmuladd.f64(double %24, double %26, double %19)
store double %27, double* %15
%28 = or i64 %20, 1
%29 = add i64 %28, %17
%30 = getelementptr inbounds double, double* %0, i64 %29
%31 = load double, double* %30
%32 = getelementptr inbounds double, double* %1, i64 %28
%33 = load double, double* %32
%34 = tail call double @llvm.fmuladd.f64(double %31, double %33, double %27)
store double %34, double* %15
%35 = add nuw i64 %20, 2
%36 = add i64 %21, 2
%37 = icmp eq i64 %36, %11
br i1 %37, label %38, label %18
38: ; preds = %18, %16
%39 = phi double [ 0.000000e+00, %16 ], [ %34, %18 ]
%40 = phi i64 [ 0, %16 ], [ %35, %18 ]
br i1 %12, label %48, label %41
41: ; preds = %38
%42 = add i64 %40, %17
%43 = getelementptr inbounds double, double* %0, i64 %42
%44 = load double, double* %43
%45 = getelementptr inbounds double, double* %1, i64 %40
%46 = load double, double* %45
%47 = tail call double @llvm.fmuladd.f64(double %44, double %46, double %39)
store double %47, double* %15
br label %48
48: ; preds = %41, %38, %13
%49 = add nuw i64 %14, 1
%50 = icmp eq i64 %49, %3
br i1 %50, label %51, label %13
51: ; preds = %48, %5
ret void
}