void MyGemm(int m, int n, int k, double *A, int ldA, double *B, int ldB,
            double *C, int ldC) {
  int i_one = 1;
  double d_one = 1.0;
  for (int j = 0; j < n; j++)
    dgemv_("No transpose", &m, &k, &d_one, A, &ldA, &B[(j)*ldB + 0], &i_one,
           &d_one, &C[(j)*ldC + 0], &i_one);
}


x86 assembly (clang, -O0):
<MyGemm>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x68,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
movsd  0xeb9(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11dc <MyGemm+0xcc>
mov    -0x20(%rbp),%r8
mov    -0x30(%rbp),%rbx
mov    -0x44(%rbp),%eax
imul   0x10(%rbp),%eax
add    $0x0,%eax
cltq
shl    $0x3,%rax
add    %rax,%rbx
mov    0x18(%rbp),%r10
mov    -0x44(%rbp),%eax
imul   0x20(%rbp),%eax
add    $0x0,%eax
cltq
shl    $0x3,%rax
add    %rax,%r10
lea    0xe70(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x40(%rbp),%r11
lea    -0x24(%rbp),%r9
lea    -0x34(%rbp),%rax
mov    %r11,%rcx
mov    %rbx,(%rsp)
mov    %rax,0x8(%rsp)
mov    %r11,0x10(%rsp)
mov    %r10,0x18(%rsp)
mov    %rax,0x20(%rsp)
mov    $0x0,%al
call   1030 <dgemv_@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1153 <MyGemm+0x43>
add    $0x68,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<MyGemm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edi,0xc(%rsp)
mov    %edx,0x8(%rsp)
mov    %r8d,0x4(%rsp)
movl   $0x1,(%rsp)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x20(%rsp)
test   %esi,%esi
jle    11c8 <MyGemm+0xb8>
mov    %r9,%r15
mov    %rcx,%rbp
mov    0x68(%rsp),%r13
movslq 0x60(%rsp),%rcx
movslq 0x70(%rsp),%rax
mov    %esi,%r14d
shl    $0x3,%rax
mov    %rax,0x18(%rsp)
shl    $0x3,%rcx
mov    %rcx,0x10(%rsp)
lea    0x20(%rsp),%r12
nopl   0x0(%rax,%rax,1)
sub    $0x8,%rsp
lea    0xe75(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r12,%rcx
mov    %rbp,%r8
lea    0xc(%rsp),%r9
xor    %eax,%eax
lea    0x8(%rsp),%rbx
push   %rbx
push   %r13
push   %r12
push   %rbx
push   %r15
call   1030 <dgemv_@plt>
add    $0x30,%rsp
add    0x18(%rsp),%r13
add    0x10(%rsp),%r15
add    $0xffffffffffffffff,%r14
jne    1180 <MyGemm+0x70>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"No transpose\00"
define void @MyGemm(i32 %0, i32 %1, i32 %2, double* %3, i32 %4, double* %5, i32 %6, double* %7, i32 %8) {
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
store i32 %0, i32* %10
store i32 %2, i32* %11
store i32 %4, i32* %12
%15 = bitcast i32* %13 to i8*
store i32 1, i32* %13
%16 = bitcast double* %14 to i8*
store double 1.000000e+00, double* %14
%17 = icmp sgt i32 %1, 0
br i1 %17, label %18, label %22
18: ; preds = %9
%19 = sext i32 %6 to i64
%20 = sext i32 %8 to i64
%21 = zext i32 %1 to i64
br label %23
22: ; preds = %23, %9
ret void
23: ; preds = %18, %23
%24 = phi i64 [ 0, %18 ], [ %30, %23 ]
%25 = mul nsw i64 %24, %19
%26 = getelementptr inbounds double, double* %5, i64 %25
%27 = mul nsw i64 %24, %20
%28 = getelementptr inbounds double, double* %7, i64 %27
%29 = call i32 (i8*, i32*, i32*, double*, double*, i32*, double*, i32*, double*, double*, i32*, ...) bitcast (i32 (...)* @dgemv_ to i32 (i8*, i32*, i32*, double*, double*, i32*, double*, i32*, double*, double*, i32*, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32* %10, i32* %11, double* %14, double* %3, i32* %12, double* %26, i32* %13, double* %14, double* %28, i32* %13)
%30 = add nuw nsw i64 %24, 1
%31 = icmp eq i64 %30, %21
br i1 %31, label %22, label %23
}