void colcpy_trans(double *__restrict dst, int ldD, const double *__restrict src,
                  int ldS, int nR, int nC) {
  register double *Dc, *Dr;
  register const double *Sc, *Sr;
  register int j, i;
  Dc = dst;
  Sc = src;
  for (j = 0; j < nC; j++) {
    Dr = Dc;
    Sr = Sc;
    for (i = 0; i < nR; i++) {
      *Dr = *Sr;
      Dr += ldD;
      Sr++;
    }
    Dc++;
    Sc += ldS;
  }
}


x86 assembly (clang, -O0):
<colcpy_trans>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11ce <colcpy_trans+0xce>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    119f <colcpy_trans+0x9f>
mov    -0x48(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0xc(%rbp),%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x48(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x48(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1154 <colcpy_trans+0x54>
mov    -0x30(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1131 <colcpy_trans+0x31>
pop    %rbp
ret

x86 assembly (clang, -O2):
<colcpy_trans>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %r9d,%r9d
jle    122b <colcpy_trans+0x12b>
movslq %esi,%rax
movslq %ecx,%r15
lea    -0x1(%r8),%r14d
mov    %r8d,%r10d
and    $0xfffffff8,%r10d
mov    %rax,%r11
shl    $0x6,%r11
shl    $0x3,%rax
mov    %r8d,%r13d
and    $0x7,%r13d
xor    %r12d,%r12d
jmp    1155 <colcpy_trans+0x55>
nopl   0x0(%rax,%rax,1)
add    $0x8,%rdi
lea    (%rdx,%r15,8),%rdx
add    $0x1,%r12d
cmp    %r9d,%r12d
je     122b <colcpy_trans+0x12b>
test   %r8d,%r8d
jle    1140 <colcpy_trans+0x40>
mov    %rdx,%rbp
mov    %rdi,%rbx
cmp    $0x7,%r14d
jb     11f6 <colcpy_trans+0xf6>
mov    %r10d,%esi
mov    %rdi,%rcx
mov    %rdx,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rcx,%rbx
movsd  0x0(%rbp),%xmm0
movsd  %xmm0,(%rcx)
movsd  0x8(%rbp),%xmm0
add    %rax,%rcx
movsd  %xmm0,(%rbx,%rax,1)
movsd  0x10(%rbp),%xmm0
movsd  %xmm0,(%rax,%rcx,1)
add    %rax,%rcx
movsd  0x18(%rbp),%xmm0
movsd  %xmm0,(%rax,%rcx,1)
add    %rax,%rcx
movsd  0x20(%rbp),%xmm0
movsd  %xmm0,(%rax,%rcx,1)
add    %rax,%rcx
movsd  0x28(%rbp),%xmm0
movsd  %xmm0,(%rax,%rcx,1)
add    %rax,%rcx
movsd  0x30(%rbp),%xmm0
movsd  %xmm0,(%rax,%rcx,1)
add    %rax,%rcx
movsd  0x38(%rbp),%xmm0
movsd  %xmm0,(%rax,%rcx,1)
add    %rax,%rcx
add    $0x40,%rbp
add    %rax,%rcx
add    $0xfffffff8,%esi
jne    1180 <colcpy_trans+0x80>
add    %r11,%rbx
test   $0x7,%r8b
je     1140 <colcpy_trans+0x40>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0x0(%rbp,%rcx,8),%xmm0
movsd  %xmm0,(%rbx)
add    $0x1,%rcx
add    %rax,%rbx
cmp    %ecx,%r13d
jne    1210 <colcpy_trans+0x110>
jmp    1140 <colcpy_trans+0x40>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @colcpy_trans(double* noalias nocapture writeonly %0, i32 %1, double* noalias nocapture %2, i32 %3, i32 %4, i32 %5) {
%7 = icmp sgt i32 %5, 0
br i1 %7, label %8, label %69
8: ; preds = %6
%9 = icmp sgt i32 %4, 0
%10 = sext i32 %1 to i64
%11 = sext i32 %3 to i64
%12 = add i32 %4, -1
%13 = and i32 %4, 7
%14 = icmp ult i32 %12, 7
%15 = and i32 %4, -8
%16 = icmp eq i32 %13, 0
br label %17
17: ; preds = %8, %64
%18 = phi i32 [ 0, %8 ], [ %67, %64 ]
%19 = phi double* [ %2, %8 ], [ %66, %64 ]
%20 = phi double* [ %0, %8 ], [ %65, %64 ]
br i1 %9, label %21, label %64
21: ; preds = %17
br i1 %14, label %52, label %22
22: ; preds = %21, %22
%23 = phi double* [ %49, %22 ], [ %19, %21 ]
%24 = phi double* [ %48, %22 ], [ %20, %21 ]
%25 = phi i32 [ %50, %22 ], [ 0, %21 ]
%26 = load double, double* %23
store double %26, double* %24
%27 = getelementptr inbounds double, double* %24, i64 %10
%28 = getelementptr inbounds double, double* %23, i64 1
%29 = load double, double* %28
store double %29, double* %27
%30 = getelementptr inbounds double, double* %27, i64 %10
%31 = getelementptr inbounds double, double* %23, i64 2
%32 = load double, double* %31
store double %32, double* %30
%33 = getelementptr inbounds double, double* %30, i64 %10
%34 = getelementptr inbounds double, double* %23, i64 3
%35 = load double, double* %34
store double %35, double* %33
%36 = getelementptr inbounds double, double* %33, i64 %10
%37 = getelementptr inbounds double, double* %23, i64 4
%38 = load double, double* %37
store double %38, double* %36
%39 = getelementptr inbounds double, double* %36, i64 %10
%40 = getelementptr inbounds double, double* %23, i64 5
%41 = load double, double* %40
store double %41, double* %39
%42 = getelementptr inbounds double, double* %39, i64 %10
%43 = getelementptr inbounds double, double* %23, i64 6
%44 = load double, double* %43
store double %44, double* %42
%45 = getelementptr inbounds double, double* %42, i64 %10
%46 = getelementptr inbounds double, double* %23, i64 7
%47 = load double, double* %46
store double %47, double* %45
%48 = getelementptr inbounds double, double* %45, i64 %10
%49 = getelementptr inbounds double, double* %23, i64 8
%50 = add i32 %25, 8
%51 = icmp eq i32 %50, %15
br i1 %51, label %52, label %22
52: ; preds = %22, %21
%53 = phi double* [ %19, %21 ], [ %49, %22 ]
%54 = phi double* [ %20, %21 ], [ %48, %22 ]
br i1 %16, label %64, label %55
55: ; preds = %52, %55
%56 = phi double* [ %61, %55 ], [ %53, %52 ]
%57 = phi double* [ %60, %55 ], [ %54, %52 ]
%58 = phi i32 [ %62, %55 ], [ 0, %52 ]
%59 = load double, double* %56
store double %59, double* %57
%60 = getelementptr inbounds double, double* %57, i64 %10
%61 = getelementptr inbounds double, double* %56, i64 1
%62 = add i32 %58, 1
%63 = icmp eq i32 %62, %13
br i1 %63, label %64, label %55
64: ; preds = %52, %55, %17
%65 = getelementptr inbounds double, double* %20, i64 1
%66 = getelementptr inbounds double, double* %19, i64 %11
%67 = add nuw nsw i32 %18, 1
%68 = icmp eq i32 %67, %5
br i1 %68, label %69, label %17
69: ; preds = %64, %6
ret void
}