#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 *generate_zero_vector(int);
double *multiply_double_vector_matrix(double *b, double **a, int m, int n) {
  double *c = generate_zero_vector(n + 1);
  int i, j;
  for (j = 1; j <= n; j++) {
    c[j] = 0.0;
    for (i = 1; i <= m; i++) {
      c[j] += b[i] * a[i][j];
    }
  }
  return c;
}


x86 assembly (clang, -O0):
<multiply_double_vector_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x18(%rbp),%edi
add    $0x1,%edi
call   1030 <generate_zero_vector@plt>
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11c8 <multiply_double_vector_matrix+0xb8>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11b5 <multiply_double_vector_matrix+0xa5>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115f <multiply_double_vector_matrix+0x4f>
jmp    11ba <multiply_double_vector_matrix+0xaa>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    113c <multiply_double_vector_matrix+0x2c>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multiply_double_vector_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x1(%rbp),%r12d
mov    %r12d,%edi
call   1030 <generate_zero_vector@plt>
test   %ebp,%ebp
jle    11f4 <multiply_double_vector_matrix+0xe4>
lea    0x1(%r14),%r8d
mov    %r12d,%edx
lea    -0x1(%r8),%r9
mov    %r9,%rdi
and    $0xfffffffffffffffe,%rdi
neg    %rdi
mov    $0x1,%ebp
jmp    116d <multiply_double_vector_matrix+0x5d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbp
cmp    %rdx,%rbp
je     11f4 <multiply_double_vector_matrix+0xe4>
movq   $0x0,(%rax,%rbp,8)
test   %r14d,%r14d
jle    1160 <multiply_double_vector_matrix+0x50>
mov    $0x1,%ecx
xorpd  %xmm0,%xmm0
cmp    $0x2,%r8d
je     11d2 <multiply_double_vector_matrix+0xc2>
nopl   0x0(%rax)
movsd  (%rbx,%rcx,8),%xmm1
mov    (%r15,%rcx,8),%rsi
mulsd  (%rsi,%rbp,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rax,%rbp,8)
movsd  0x8(%rbx,%rcx,8),%xmm0
mov    0x8(%r15,%rcx,8),%rsi
mulsd  (%rsi,%rbp,8),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rbp,8)
lea    (%rdi,%rcx,1),%rsi
add    $0x2,%rsi
add    $0x2,%rcx
cmp    $0x1,%rsi
jne    1190 <multiply_double_vector_matrix+0x80>
test   $0x1,%r9b
je     1160 <multiply_double_vector_matrix+0x50>
movsd  (%rbx,%rcx,8),%xmm1
mov    (%r15,%rcx,8),%rcx
mulsd  (%rcx,%rbp,8),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rax,%rbp,8)
jmp    1160 <multiply_double_vector_matrix+0x50>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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