#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*/ memcpy(double *, double const *, int);
void colcpy(double *__restrict dst, int ldD, const double *__restrict src,
            int ldS, int nR, int nC) {
  register int i;
  for (i = 0; i < nC; i++) {
    memcpy(dst, src, nR * sizeof(double));
    dst += ldD;
    src += ldS;
  }
}


x86 assembly (clang, -O0):
<colcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1190 <colcpy+0x80>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x20(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1030 <memcpy@plt>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1135 <colcpy+0x25>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<colcpy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %r9d,%r9d
jle    115a <colcpy+0x4a>
mov    %r9d,%r15d
mov    %r8d,%r14d
mov    %rdx,%rbp
mov    %rdi,%rbx
shl    $0x3,%r14d
movslq %esi,%r12
movslq %ecx,%r13
shl    $0x3,%r12
shl    $0x3,%r13
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1030 <memcpy@plt>
add    %r12,%rbx
add    %r13,%rbp
add    $0xffffffff,%r15d
jne    1140 <colcpy+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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