#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*/ dgemv_(char *, int *, int *, double *, double *, int *,
                          double *, int *, double *, double *, int *);
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 i = 0; i < m; i++)
    dgemv_("Transpose", &k, &n, &d_one, B, &ldA, &A[(0) * ldA + i], &ldA,
           &d_one, &C[(0) * ldC + i], &ldC);
}


x86 assembly (clang, -O0):
<MyGemm>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
movsd  0xeb7(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d9 <MyGemm+0xc9>
mov    -0x38(%rbp),%r8
mov    -0x28(%rbp),%r14
imul   $0x0,-0x2c(%rbp),%eax
add    -0x4c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r14
mov    0x18(%rbp),%r10
imul   $0x0,0x20(%rbp),%eax
add    -0x4c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r10
lea    0xe74(%rip),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x48(%rbp),%r11
lea    -0x2c(%rbp),%rbx
lea    0x20(%rbp),%rax
mov    %r11,%rcx
mov    %rbx,%r9
mov    %r14,(%rsp)
mov    %rbx,0x8(%rsp)
mov    %r11,0x10(%rsp)
mov    %r10,0x18(%rsp)
mov    %rax,0x20(%rsp)
call   1030 <dgemv_@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1155 <MyGemm+0x45>
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<MyGemm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,0xc(%rsp)
mov    %edx,0x8(%rsp)
mov    %r8d,0x4(%rsp)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x10(%rsp)
test   %edi,%edi
jle    11a1 <MyGemm+0x91>
mov    %r9,%r14
mov    %rcx,%rbx
mov    0x58(%rsp),%rbp
mov    %edi,%r13d
lea    0x10(%rsp),%r15
lea    0x4(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
sub    $0x8,%rsp
lea    0xe95(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x14(%rsp),%rdx
mov    %r15,%rcx
mov    %r14,%r8
mov    %r12,%r9
lea    0x68(%rsp),%rax
push   %rax
push   %rbp
push   %r15
push   %r12
push   %rbx
call   1030 <dgemv_@plt>
add    $0x30,%rsp
add    $0x8,%rbp
add    $0x8,%rbx
add    $0xffffffffffffffff,%r13
jne    1160 <MyGemm+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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