#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*/ dgemm_(char *, char *, int *, int *, int *, double *,
                          double *, int *, double *, int *, double *, double *,
                          int *);
int round(int);
void ParallelVectorMatrix(double *m1, int size, double *m2, double *result,
                          int numThreads) {
  int i;
  char transN = 'N';
  char transY = 'N';
  int aux = 1;
  double aux2 = 0;
  double factor = 1.0;
#pragma omp parallel default(shared) private(i)
  {
#pragma omp for schedule(static)
    for (i = 0; i < numThreads; i++) {
      int InitCol = round(i * size / numThreads);
      int FinalCol = round((i + 1) * size / numThreads) - 1;
      int lenghtCol = FinalCol - InitCol + 1;
      if (lenghtCol > 0) {
        dgemm_(&transN, &transY, &aux, &(lenghtCol), &(size), &factor, m1, &aux,
               &m2[size * InitCol], &size, &aux2, &result[InitCol], &aux);
      }
    }
  }
}


x86 assembly (clang, -O0):
<ParallelVectorMatrix>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rdi,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %r8d,-0x3c(%rbp)
movb   $0x4e,-0x41(%rbp)
movb   $0x4e,-0x42(%rbp)
movl   $0x1,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe9e(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1243 <ParallelVectorMatrix+0x123>
mov    -0x40(%rbp),%eax
imul   -0x24(%rbp),%eax
cltd
idivl  -0x3c(%rbp)
mov    %eax,%edi
call   1040 <round@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
imul   -0x24(%rbp),%eax
cltd
idivl  -0x3c(%rbp)
mov    %eax,%edi
call   1040 <round@plt>
sub    $0x1,%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
sub    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jle    1230 <ParallelVectorMatrix+0x110>
mov    -0x20(%rbp),%r15
mov    -0x30(%rbp),%r14
mov    -0x24(%rbp),%eax
imul   -0x5c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r14
mov    -0x38(%rbp),%r10
movslq -0x5c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%r10
lea    -0x41(%rbp),%rdi
lea    -0x42(%rbp),%rsi
lea    -0x48(%rbp),%rax
lea    -0x64(%rbp),%rcx
lea    -0x24(%rbp),%rbx
lea    -0x58(%rbp),%r9
lea    -0x50(%rbp),%r11
mov    %rax,%rdx
mov    %rbx,%r8
mov    %r15,(%rsp)
mov    %rax,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   1030 <dgemm_@plt>
jmp    1235 <ParallelVectorMatrix+0x115>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    116e <ParallelVectorMatrix+0x4e>
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<ParallelVectorMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,0x20(%rsp)
mov    %rdx,0x18(%rsp)
mov    %rdi,0x10(%rsp)
mov    %esi,0x4(%rsp)
movb   $0x4e,0x3(%rsp)
movb   $0x4e,0x2(%rsp)
movl   $0x1,0xc(%rsp)
movq   $0x0,0x30(%rsp)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x28(%rsp)
test   %r8d,%r8d
jle    122a <ParallelVectorMatrix+0x10a>
mov    %r8d,%ebx
mov    $0x1,%r15d
lea    0xc(%rsp),%r13
lea    0x4(%rsp),%r12
nopw   0x0(%rax,%rax,1)
lea    -0x1(%r15),%eax
imul   %esi,%eax
cltd
idiv   %ebx
mov    %eax,%edi
call   1040 <round@plt>
mov    %eax,%r14d
mov    0x4(%rsp),%eax
imul   %r15d,%eax
cltd
idiv   %ebx
mov    %eax,%edi
call   1040 <round@plt>
sub    %r14d,%eax
mov    %eax,0x8(%rsp)
test   %eax,%eax
jle    1218 <ParallelVectorMatrix+0xf8>
movslq 0x4(%rsp),%rax
movslq %r14d,%rcx
imul   %rcx,%rax
mov    0x18(%rsp),%rdx
lea    (%rdx,%rax,8),%rax
mov    0x20(%rsp),%rdx
lea    (%rdx,%rcx,8),%rbp
sub    $0x8,%rsp
lea    0xb(%rsp),%rdi
lea    0xa(%rsp),%rsi
mov    %r13,%rdx
lea    0x10(%rsp),%rcx
mov    %r12,%r8
lea    0x30(%rsp),%r9
push   %r13
push   %rbp
lea    0x48(%rsp),%rbp
push   %rbp
push   %r12
push   %rax
push   %r13
push   0x48(%rsp)
call   1030 <dgemm_@plt>
add    $0x40,%rsp
cmp    %r15d,%ebx
je     122a <ParallelVectorMatrix+0x10a>
mov    0x4(%rsp),%esi
add    $0x1,%r15d
jmp    1190 <ParallelVectorMatrix+0x70>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @ParallelVectorMatrix(double* %0, i32 %1, double* %2, double* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8
%8 = alloca i8
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca i32
store i32 %1, i32* %6
store i8 78, i8* %7
store i8 78, i8* %8
%13 = bitcast i32* %9 to i8*
store i32 1, i32* %9
%14 = bitcast double* %10 to i8*
store double 0.000000e+00, double* %10
%15 = bitcast double* %11 to i8*
store double 1.000000e+00, double* %11
%16 = icmp sgt i32 %4, 0
br i1 %16, label %17, label %44
17: ; preds = %5
%18 = bitcast i32* %12 to i8*
br label %19
19: ; preds = %42, %17
%20 = phi i32 [ %1, %17 ], [ %43, %42 ]
%21 = phi i32 [ 0, %17 ], [ %25, %42 ]
%22 = mul nsw i32 %20, %21
%23 = sdiv i32 %22, %4
%24 = call i32 @round(i32 %23)
%25 = add nuw nsw i32 %21, 1
%26 = load i32, i32* %6
%27 = mul nsw i32 %26, %25
%28 = sdiv i32 %27, %4
%29 = call i32 @round(i32 %28)
%30 = sub i32 %29, %24
store i32 %30, i32* %12
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %40
32: ; preds = %19
%33 = load i32, i32* %6
%34 = mul nsw i32 %33, %24
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %2, i64 %35
%37 = sext i32 %24 to i64
%38 = getelementptr inbounds double, double* %3, i64 %37
%39 = call i32 @dgemm_(i8* %7, i8* %8, i32* %9, i32* %12, i32* %6, double* %11, double* %0, i32* %9, double* %36, i32* %6, double* %10, double* %38, i32* %9)
br label %40
40: ; preds = %32, %19
%41 = icmp eq i32 %25, %4
br i1 %41, label %44, label %42
42: ; preds = %40
%43 = load i32, i32* %6
br label %19
44: ; preds = %40, %5
ret void
}