void Gemm_P_Ger(int m, int n, int k, double *A, int ldA, double *B, int ldB,
                double *C, int ldC) {
  for (int p = 0; p < k; p++)
    Ger(m, n, &A[(p)*ldA + (0)], 1, &B[(0) * ldB + (p)], ldB, C, ldC);
}


x86 assembly (clang, -O0):
<Gemm_P_Ger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11a8 <Gemm_P_Ger+0x98>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x2c(%rbp),%eax
imul   -0x1c(%rbp),%eax
add    $0x0,%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x28(%rbp),%r8
imul   $0x0,0x10(%rbp),%eax
add    -0x2c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%r8
mov    0x10(%rbp),%r9d
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%eax
mov    $0x1,%ecx
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1030 <Ger@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    113e <Gemm_P_Ger+0x2e>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Gemm_P_Ger>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    1178 <Gemm_P_Ger+0x68>
mov    %r9,%r14
mov    %rcx,%rbx
mov    %esi,%r15d
mov    %edi,%r13d
movslq %r8d,%rax
mov    %edx,%r12d
shl    $0x3,%rax
mov    %rax,(%rsp)
nopl   0x0(%rax)
mov    %r13d,%edi
mov    %r15d,%esi
mov    %rbx,%rdx
mov    $0x1,%ecx
mov    %r14,%r8
mov    0x40(%rsp),%r9d
xor    %eax,%eax
mov    0x50(%rsp),%ebp
push   %rbp
push   0x50(%rsp)
call   1030 <Ger@plt>
add    $0x10,%rsp
add    (%rsp),%rbx
add    $0x8,%r14
add    $0xffffffffffffffff,%r12
jne    1140 <Gemm_P_Ger+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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