void MyGemv(int m, int n, double *A, int ldA, double *x, int incx, double *y,
            int incy) {
  for (int i = 0; i < m; ++i)
    Dots(n, &A[(0) * ldA + i], ldA, &x[(0) * incx], 1, &y[(i)*incy]);
}


x86 assembly (clang, -O0):
<MyGemv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a1 <MyGemv+0x91>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
imul   $0x0,-0x14(%rbp),%eax
add    -0x28(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
imul   $0x0,-0x24(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rcx
mov    0x10(%rbp),%r9
mov    -0x28(%rbp),%eax
imul   0x18(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r9
mov    $0x1,%r8d
mov    $0x0,%al
call   1030 <Dots@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    113b <MyGemv+0x2b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MyGemv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    116a <MyGemv+0x5a>
mov    %r8,%r15
mov    %ecx,%r12d
mov    %rdx,%rbx
mov    %esi,%r13d
mov    0x40(%rsp),%rbp
movslq 0x48(%rsp),%rax
mov    %edi,%r14d
shl    $0x3,%rax
mov    %rax,(%rsp)
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %r12d,%edx
mov    %r15,%rcx
mov    $0x1,%r8d
mov    %rbp,%r9
xor    %eax,%eax
call   1030 <Dots@plt>
add    (%rsp),%rbp
add    $0x8,%rbx
add    $0xffffffffffffffff,%r14
jne    1140 <MyGemv+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @MyGemv(i32 %0, i32 %1, double* %2, i32 %3, double* %4, i32 %5, double* %6, i32 %7) {
%9 = icmp sgt i32 %0, 0
br i1 %9, label %10, label %13
10: ; preds = %8
%11 = sext i32 %7 to i64
%12 = zext i32 %0 to i64
br label %14
13: ; preds = %14, %8
ret void
14: ; preds = %10, %14
%15 = phi i64 [ 0, %10 ], [ %20, %14 ]
%16 = getelementptr inbounds double, double* %2, i64 %15
%17 = mul nsw i64 %15, %11
%18 = getelementptr inbounds double, double* %6, i64 %17
%19 = tail call i32 (i32, double*, i32, double*, i32, double*, ...) bitcast (i32 (...)* @Dots to i32 (i32, double*, i32, double*, i32, double*, ...)*)(i32 %1, double* %16, i32 %3, double* %4, i32 1, double* %18)
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, %12
br i1 %21, label %13, label %14
}