void colcpy_fill_up(double *dst, int ldD, const double *src, int ldS, int nR,
                    int nC, int unit) {
  register double *Dcu, *Dcl, *Drl, *Dru;
  register const double *Sc, *Sr;
  register int j, i;
  Dcu = dst;
  Sc = src;
  Dcl = dst;
  for (j = 0; j < nC; j++) {
    Dru = Dcu + j;
    Drl = Dcl + j;
    Sr = Sc + j;
    *Dru = unit ? 1.0 : *Sr;
    Sr++;
    Dru += ldD;
    Drl++;
    for (i = 1; i < nC - j; i++) {
      *Dru = *Sr;
      *Drl = *Sr;
      Sr++;
      Dru += ldD;
      Drl++;
    }
    Sc += ldS;
    Dcu += ldD;
    Dcl += ldD;
  }
}


x86 assembly (clang, -O0):
<colcpy_fill_up>:
push   %rbp
mov    %rsp,%rbp
mov    0x10(%rbp),%eax
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,-0x50(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12a4 <colcpy_fill_up+0x1a4>
mov    -0x30(%rbp),%rax
movslq -0x5c(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x5c(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x50(%rbp),%rax
movslq -0x5c(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
cmpl   $0x0,0x10(%rbp)
je     119d <colcpy_fill_up+0x9d>
movsd  0xe6d(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    11aa <colcpy_fill_up+0xaa>
mov    -0x58(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x58(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x58(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x40(%rbp)
movl   $0x1,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    -0x5c(%rbp),%ecx
cmp    %ecx,%eax
jge    1257 <colcpy_fill_up+0x157>
mov    -0x58(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x58(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x58(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x58(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x40(%rbp)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    11eb <colcpy_fill_up+0xeb>
mov    -0x1c(%rbp),%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    113c <colcpy_fill_up+0x3c>
pop    %rbp
ret

x86 assembly (clang, -O2):
<colcpy_fill_up>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %r9d,%r9d
jle    1399 <colcpy_fill_up+0x299>
mov    %r9d,%r15d
mov    0x38(%rsp),%r12d
movslq %esi,%rbx
movslq %ecx,%rcx
mov    %rcx,-0x8(%rsp)
mov    %r9d,%ecx
mov    %rcx,-0x10(%rsp)
lea    -0x2(%r15),%ecx
mov    %ecx,-0x64(%rsp)
lea    0x0(,%rbx,8),%rcx
mov    %rcx,%rsi
xor    $0xfffffffffffffff8,%rsi
mov    %rsi,-0x18(%rsp)
mov    %rbx,%rsi
shl    $0x5,%rsi
lea    0x8(,%rbx,8),%rbp
mov    %rbp,-0x20(%rsp)
lea    (%rcx,%rcx,2),%rbp
mov    %rbp,-0x48(%rsp)
mov    %rbx,%rax
shl    $0x4,%rax
mov    %rax,-0x50(%rsp)
lea    0x1(%rbx),%rax
mov    %rax,-0x28(%rsp)
lea    0x0(,%rbx,4),%r8
lea    -0x1(%r15),%r10d
xor    %eax,%eax
mov    %rax,-0x58(%rsp)
movsd  0xe69(%rip),%xmm0
mov    %rbx,-0x40(%rsp)
mov    %rbx,-0x70(%rsp)
mov    %rsi,-0x60(%rsp)
xor    %eax,%eax
mov    %rax,-0x78(%rsp)
xor    %r14d,%r14d
mov    %rdi,%r13
mov    %r15,-0x38(%rsp)
jmp    121d <colcpy_fill_up+0x11d>
nopw   0x0(%rax,%rax,1)
mov    -0x8(%rsp),%rax
lea    (%rdx,%rax,8),%rdx
mov    -0x40(%rsp),%rax
lea    0x0(%r13,%rax,8),%r13
add    $0x1,%r14
mov    -0x78(%rsp),%rax
add    -0x18(%rsp),%rax
mov    %rax,-0x78(%rsp)
mov    -0x20(%rsp),%rax
add    %rax,-0x60(%rsp)
add    %rax,-0x48(%rsp)
add    %rax,-0x50(%rsp)
mov    -0x70(%rsp),%rbp
add    -0x28(%rsp),%rbp
mov    %rbp,-0x70(%rsp)
add    %rax,-0x58(%rsp)
add    $0xffffffff,%r10d
cmp    -0x10(%rsp),%r14
je     1399 <colcpy_fill_up+0x299>
lea    (%rdx,%r14,8),%r9
movaps %xmm0,%xmm1
test   %r12d,%r12d
jne    122e <colcpy_fill_up+0x12e>
movsd  (%r9),%xmm1
lea    0x0(,%r14,8),%rax
add    %r13,%rax
movsd  %xmm1,(%rax)
mov    %r15d,%ebp
sub    %r14d,%ebp
cmp    $0x2,%ebp
jl     11c0 <colcpy_fill_up+0xc0>
mov    -0x64(%rsp),%ebp
sub    %r14d,%ebp
mov    %r14d,%ebx
not    %ebx
add    %r15d,%ebx
cmp    $0x3,%ebp
jae    1280 <colcpy_fill_up+0x180>
mov    %rax,%r11
test   $0x3,%bl
jne    1352 <colcpy_fill_up+0x252>
jmp    11c0 <colcpy_fill_up+0xc0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,-0x68(%rsp)
mov    %rdx,-0x30(%rsp)
mov    %r10d,%ebx
and    $0xfffffffc,%ebx
mov    -0x58(%rsp),%r11
mov    -0x70(%rsp),%r12
mov    -0x50(%rsp),%rdx
mov    -0x48(%rsp),%rbp
mov    -0x60(%rsp),%rax
mov    -0x78(%rsp),%r15
nopl   (%rax)
movsd  0x8(%r9),%xmm1
movsd  %xmm1,(%rdi,%r12,8)
movsd  0x8(%r9),%xmm1
movsd  %xmm1,0x8(%rdi,%r11,1)
movsd  0x10(%r9),%xmm1
movsd  %xmm1,(%rdi,%rdx,1)
movsd  0x10(%r9),%xmm1
movsd  %xmm1,0x10(%rdi,%r11,1)
movsd  0x18(%r9),%xmm1
movsd  %xmm1,(%rdi,%rbp,1)
movsd  0x18(%r9),%xmm1
movsd  %xmm1,0x18(%rdi,%r11,1)
movsd  0x20(%r9),%xmm1
movsd  %xmm1,(%rdi,%rax,1)
movsd  0x20(%r9),%xmm1
add    $0x20,%r9
movsd  %xmm1,0x20(%rdi,%r11,1)
sub    %rsi,%r15
add    %rsi,%rax
add    %rsi,%rbp
add    %rsi,%rdx
add    %r8,%r12
add    $0x20,%r11
add    $0xfffffffc,%ebx
jne    12b0 <colcpy_fill_up+0x1b0>
mov    %rdi,%rax
sub    %r15,%rax
add    %rdi,%r11
mov    -0x38(%rsp),%r15
mov    -0x30(%rsp),%rdx
mov    0x38(%rsp),%r12d
mov    -0x68(%rsp),%ebx
test   $0x3,%bl
je     11c0 <colcpy_fill_up+0xc0>
mov    %r10d,%ebp
and    $0x3,%ebp
mov    -0x40(%rsp),%rbx
lea    (%rax,%rbx,8),%rax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  0x8(%r9,%rbx,8),%xmm1
movsd  %xmm1,(%rax)
movsd  0x8(%r9,%rbx,8),%xmm1
movsd  %xmm1,0x8(%r11,%rbx,8)
add    %rcx,%rax
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    1370 <colcpy_fill_up+0x270>
jmp    11c0 <colcpy_fill_up+0xc0>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @colcpy_fill_up(double* %0, i32 %1, double* %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca double*
%9 = alloca i32
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca double*
%16 = alloca double*
%17 = alloca double*
%18 = alloca double*
%19 = alloca double*
%20 = alloca double*
%21 = alloca i32
%22 = alloca i32
store double* %0, double** %8
store i32 %1, i32* %9
store double* %2, double** %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%23 = load double*, double** %8
store double* %23, double** %15
%24 = load double*, double** %10
store double* %24, double** %19
%25 = load double*, double** %8
store double* %25, double** %16
store i32 0, i32* %21
br label %26
26: ; preds = %97, %7
%27 = load i32, i32* %21
%28 = load i32, i32* %13
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %100
30: ; preds = %26
%31 = load double*, double** %15
%32 = load i32, i32* %21
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
store double* %34, double** %18
%35 = load double*, double** %16
%36 = load i32, i32* %21
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
store double* %38, double** %17
%39 = load double*, double** %19
%40 = load i32, i32* %21
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
store double* %42, double** %20
%43 = load i32, i32* %14
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %30
br label %49
46: ; preds = %30
%47 = load double*, double** %20
%48 = load double, double* %47
br label %49
49: ; preds = %46, %45
%50 = phi double [ 1.000000e+00, %45 ], [ %48, %46 ]
%51 = load double*, double** %18
store double %50, double* %51
%52 = load double*, double** %20
%53 = getelementptr inbounds double, double* %52, i32 1
store double* %53, double** %20
%54 = load i32, i32* %9
%55 = load double*, double** %18
%56 = sext i32 %54 to i64
%57 = getelementptr inbounds double, double* %55, i64 %56
store double* %57, double** %18
%58 = load double*, double** %17
%59 = getelementptr inbounds double, double* %58, i32 1
store double* %59, double** %17
store i32 1, i32* %22
br label %60
60: ; preds = %81, %49
%61 = load i32, i32* %22
%62 = load i32, i32* %13
%63 = load i32, i32* %21
%64 = sub nsw i32 %62, %63
%65 = icmp slt i32 %61, %64
br i1 %65, label %66, label %84
66: ; preds = %60
%67 = load double*, double** %20
%68 = load double, double* %67
%69 = load double*, double** %18
store double %68, double* %69
%70 = load double*, double** %20
%71 = load double, double* %70
%72 = load double*, double** %17
store double %71, double* %72
%73 = load double*, double** %20
%74 = getelementptr inbounds double, double* %73, i32 1
store double* %74, double** %20
%75 = load i32, i32* %9
%76 = load double*, double** %18
%77 = sext i32 %75 to i64
%78 = getelementptr inbounds double, double* %76, i64 %77
store double* %78, double** %18
%79 = load double*, double** %17
%80 = getelementptr inbounds double, double* %79, i32 1
store double* %80, double** %17
br label %81
81: ; preds = %66
%82 = load i32, i32* %22
%83 = add nsw i32 %82, 1
store i32 %83, i32* %22
br label %60
84: ; preds = %60
%85 = load i32, i32* %11
%86 = load double*, double** %19
%87 = sext i32 %85 to i64
%88 = getelementptr inbounds double, double* %86, i64 %87
store double* %88, double** %19
%89 = load i32, i32* %9
%90 = load double*, double** %15
%91 = sext i32 %89 to i64
%92 = getelementptr inbounds double, double* %90, i64 %91
store double* %92, double** %15
%93 = load i32, i32* %9
%94 = load double*, double** %16
%95 = sext i32 %93 to i64
%96 = getelementptr inbounds double, double* %94, i64 %95
store double* %96, double** %16
br label %97
97: ; preds = %84
%98 = load i32, i32* %21
%99 = add nsw i32 %98, 1
store i32 %99, i32* %21
br label %26
100: ; preds = %26
ret void
}

LLVM IR (-O2):
define void @colcpy_fill_up(double* nocapture writeonly %0, i32 %1, double* nocapture %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = icmp sgt i32 %5, 0
br i1 %8, label %9, label %87
9: ; preds = %7
%10 = icmp eq i32 %6, 0
%11 = sext i32 %1 to i64
%12 = sext i32 %3 to i64
%13 = zext i32 %5 to i64
%14 = add i32 %5, -2
br label %15
15: ; preds = %9, %82
%16 = phi i64 [ 0, %9 ], [ %85, %82 ]
%17 = phi double* [ %2, %9 ], [ %83, %82 ]
%18 = phi double* [ %0, %9 ], [ %84, %82 ]
%19 = trunc i64 %16 to i32
%20 = xor i32 %19, -1
%21 = add i32 %20, %5
%22 = trunc i64 %16 to i32
%23 = sub i32 %14, %22
%24 = getelementptr inbounds double, double* %18, i64 %16
%25 = getelementptr inbounds double, double* %17, i64 %16
br i1 %10, label %26, label %28
26: ; preds = %15
%27 = load double, double* %25
br label %28
28: ; preds = %15, %26
%29 = phi double [ %27, %26 ], [ 1.000000e+00, %15 ]
store double %29, double* %24
%30 = trunc i64 %16 to i32
%31 = sub nsw i32 %5, %30
%32 = icmp sgt i32 %31, 1
br i1 %32, label %33, label %82
33: ; preds = %28
%34 = and i32 %21, 3
%35 = icmp ult i32 %23, 3
br i1 %35, label %65, label %36
36: ; preds = %33
%37 = and i32 %21, -4
br label %38
38: ; preds = %38, %36
%39 = phi double* [ %24, %36 ], [ %60, %38 ]
%40 = phi double* [ %25, %36 ], [ %59, %38 ]
%41 = phi double* [ %24, %36 ], [ %58, %38 ]
%42 = phi i32 [ 0, %36 ], [ %63, %38 ]
%43 = getelementptr inbounds double, double* %41, i64 1
%44 = getelementptr inbounds double, double* %40, i64 1
%45 = getelementptr inbounds double, double* %39, i64 %11
%46 = load double, double* %44
store double %46, double* %45
%47 = load double, double* %44
store double %47, double* %43
%48 = getelementptr inbounds double, double* %41, i64 2
%49 = getelementptr inbounds double, double* %40, i64 2
%50 = getelementptr inbounds double, double* %45, i64 %11
%51 = load double, double* %49
store double %51, double* %50
%52 = load double, double* %49
store double %52, double* %48
%53 = getelementptr inbounds double, double* %41, i64 3
%54 = getelementptr inbounds double, double* %40, i64 3
%55 = getelementptr inbounds double, double* %50, i64 %11
%56 = load double, double* %54
store double %56, double* %55
%57 = load double, double* %54
store double %57, double* %53
%58 = getelementptr inbounds double, double* %41, i64 4
%59 = getelementptr inbounds double, double* %40, i64 4
%60 = getelementptr inbounds double, double* %55, i64 %11
%61 = load double, double* %59
store double %61, double* %60
%62 = load double, double* %59
store double %62, double* %58
%63 = add i32 %42, 4
%64 = icmp eq i32 %63, %37
br i1 %64, label %65, label %38
65: ; preds = %38, %33
%66 = phi double* [ %24, %33 ], [ %60, %38 ]
%67 = phi double* [ %25, %33 ], [ %59, %38 ]
%68 = phi double* [ %24, %33 ], [ %58, %38 ]
%69 = icmp eq i32 %34, 0
br i1 %69, label %82, label %70
70: ; preds = %65, %70
%71 = phi double* [ %77, %70 ], [ %66, %65 ]
%72 = phi double* [ %76, %70 ], [ %67, %65 ]
%73 = phi double* [ %75, %70 ], [ %68, %65 ]
%74 = phi i32 [ %80, %70 ], [ 0, %65 ]
%75 = getelementptr inbounds double, double* %73, i64 1
%76 = getelementptr inbounds double, double* %72, i64 1
%77 = getelementptr inbounds double, double* %71, i64 %11
%78 = load double, double* %76
store double %78, double* %77
%79 = load double, double* %76
store double %79, double* %75
%80 = add i32 %74, 1
%81 = icmp eq i32 %80, %34
br i1 %81, label %82, label %70
82: ; preds = %65, %70, %28
%83 = getelementptr inbounds double, double* %17, i64 %12
%84 = getelementptr inbounds double, double* %18, i64 %11
%85 = add nuw nsw i64 %16, 1
%86 = icmp eq i64 %85, %13
br i1 %86, label %87, label %15
87: ; preds = %82, %7
ret void
}