#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 colcpy4(double *__restrict dst, int ldD, const double *__restrict src,
             int ldS, int nR, int nC) {
  register int i;
  for (i = 0; i < nC - 3; i += 4) {
    memcpy(dst, src, nR * sizeof(double));
    dst += ldD;
    src += ldS;
    memcpy(dst, src, nR * sizeof(double));
    dst += ldD;
    src += ldS;
    memcpy(dst, src, nR * sizeof(double));
    dst += ldD;
    src += ldS;
    memcpy(dst, src, nR * sizeof(double));
    dst += ldD;
    src += ldS;
  }
  if (i == nC)
    return;
  if (i < nC - 1) {
    memcpy(dst, src, nR * sizeof(double));
    dst += ldD;
    src += ldS;
    memcpy(dst, src, nR * sizeof(double));
    dst += ldD;
    src += ldS;
    i += 2;
  }
  if (i < nC) {
    memcpy(dst, src, nR * sizeof(double));
  }
}


x86 assembly (clang, -O0):
<colcpy4>:
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
mov    -0x24(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jge    1258 <colcpy4+0x148>
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    -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    -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    -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    $0x4,%eax
mov    %eax,-0x28(%rbp)
jmp    1135 <colcpy4+0x25>
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    1269 <colcpy4+0x159>
jmp    1328 <colcpy4+0x218>
mov    -0x28(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1305 <colcpy4+0x1f5>
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    -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    $0x2,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1328 <colcpy4+0x218>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x20(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1030 <memcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<colcpy4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %ecx,%r14d
mov    %rdx,%r12
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %ecx,%ecx
cmp    $0x4,%r9d
jl     122e <colcpy4+0x11e>
mov    %r9,0x10(%rsp)
lea    -0x3(%r9),%eax
mov    %eax,0x2c(%rsp)
mov    %r8,0x18(%rsp)
lea    0x0(,%r8,8),%eax
mov    %eax,0x28(%rsp)
mov    %ebp,0x20(%rsp)
movslq %ebp,%rcx
mov    %r14d,0x24(%rsp)
movslq %r14d,%rdx
mov    %rcx,%rax
shl    $0x5,%rax
mov    %rax,0x38(%rsp)
mov    %rdx,%rax
shl    $0x5,%rax
mov    %rax,0x30(%rsp)
shl    $0x3,%rcx
mov    %rcx,0x50(%rsp)
shl    $0x3,%rdx
mov    %rdx,0x48(%rsp)
xor    %ecx,%ecx
mov    0x28(%rsp),%r13d
mov    0x50(%rsp),%r15
mov    0x48(%rsp),%rbp
nopl   (%rax)
mov    %ecx,0xc(%rsp)
mov    %r12,%r14
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
call   1030 <memcpy@plt>
mov    %rbx,0x40(%rsp)
add    %r15,%rbx
add    %rbp,%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
call   1030 <memcpy@plt>
add    %r15,%rbx
add    %rbp,%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
call   1030 <memcpy@plt>
add    %r15,%rbx
add    %rbp,%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
call   1030 <memcpy@plt>
mov    0xc(%rsp),%ecx
add    $0x4,%ecx
add    %r15,%rbx
add    %rbp,%r12
cmp    0x2c(%rsp),%ecx
jl     11a0 <colcpy4+0x90>
mov    0x40(%rsp),%rbx
add    0x38(%rsp),%rbx
add    0x30(%rsp),%r14
mov    %r14,%r12
mov    0x18(%rsp),%r8
mov    0x10(%rsp),%r9
mov    0x24(%rsp),%r14d
mov    0x20(%rsp),%ebp
cmp    %r9d,%ecx
je     12c4 <colcpy4+0x1b4>
lea    -0x1(%r9),%eax
cmp    %eax,%ecx
jge    129f <colcpy4+0x18f>
lea    0x0(,%r8,8),%r15d
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    %r8,0x18(%rsp)
mov    %r9,0x10(%rsp)
mov    %ecx,0xc(%rsp)
call   1030 <memcpy@plt>
movslq %ebp,%r13
lea    (%rbx,%r13,8),%rbx
movslq %r14d,%r14
lea    (%r12,%r14,8),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
call   1030 <memcpy@plt>
mov    0xc(%rsp),%ecx
mov    0x10(%rsp),%r9
mov    0x18(%rsp),%r8
lea    (%rbx,%r13,8),%rbx
lea    0x0(,%r14,8),%r12
add    %rbp,%r12
or     $0x2,%ecx
cmp    %r9d,%ecx
jge    12c4 <colcpy4+0x1b4>
shl    $0x3,%r8d
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r8d,%edx
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <memcpy@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @colcpy4(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 = %80, %6
%15 = load i32, i32* %13
%16 = load i32, i32* %12
%17 = sub nsw i32 %16, 3
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %83
19: ; preds = %14
%20 = load double*, double** %7
%21 = load double*, double** %9
%22 = load i32, i32* %11
%23 = sext i32 %22 to i64
%24 = mul i64 %23, 8
%25 = trunc i64 %24 to i32
%26 = call i32 @memcpy(double* %20, double* %21, i32 %25)
%27 = load i32, i32* %8
%28 = load double*, double** %7
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds double, double* %28, i64 %29
store double* %30, double** %7
%31 = load i32, i32* %10
%32 = load double*, double** %9
%33 = sext i32 %31 to i64
%34 = getelementptr inbounds double, double* %32, i64 %33
store double* %34, double** %9
%35 = load double*, double** %7
%36 = load double*, double** %9
%37 = load i32, i32* %11
%38 = sext i32 %37 to i64
%39 = mul i64 %38, 8
%40 = trunc i64 %39 to i32
%41 = call i32 @memcpy(double* %35, double* %36, i32 %40)
%42 = load i32, i32* %8
%43 = load double*, double** %7
%44 = sext i32 %42 to i64
%45 = getelementptr inbounds double, double* %43, i64 %44
store double* %45, double** %7
%46 = load i32, i32* %10
%47 = load double*, double** %9
%48 = sext i32 %46 to i64
%49 = getelementptr inbounds double, double* %47, i64 %48
store double* %49, double** %9
%50 = load double*, double** %7
%51 = load double*, double** %9
%52 = load i32, i32* %11
%53 = sext i32 %52 to i64
%54 = mul i64 %53, 8
%55 = trunc i64 %54 to i32
%56 = call i32 @memcpy(double* %50, double* %51, i32 %55)
%57 = load i32, i32* %8
%58 = load double*, double** %7
%59 = sext i32 %57 to i64
%60 = getelementptr inbounds double, double* %58, i64 %59
store double* %60, double** %7
%61 = load i32, i32* %10
%62 = load double*, double** %9
%63 = sext i32 %61 to i64
%64 = getelementptr inbounds double, double* %62, i64 %63
store double* %64, double** %9
%65 = load double*, double** %7
%66 = load double*, double** %9
%67 = load i32, i32* %11
%68 = sext i32 %67 to i64
%69 = mul i64 %68, 8
%70 = trunc i64 %69 to i32
%71 = call i32 @memcpy(double* %65, double* %66, i32 %70)
%72 = load i32, i32* %8
%73 = load double*, double** %7
%74 = sext i32 %72 to i64
%75 = getelementptr inbounds double, double* %73, i64 %74
store double* %75, double** %7
%76 = load i32, i32* %10
%77 = load double*, double** %9
%78 = sext i32 %76 to i64
%79 = getelementptr inbounds double, double* %77, i64 %78
store double* %79, double** %9
br label %80
80: ; preds = %19
%81 = load i32, i32* %13
%82 = add nsw i32 %81, 4
store i32 %82, i32* %13
br label %14
83: ; preds = %14
%84 = load i32, i32* %13
%85 = load i32, i32* %12
%86 = icmp eq i32 %84, %85
br i1 %86, label %87, label %88
87: ; preds = %83
br label %138
88: ; preds = %83
%89 = load i32, i32* %13
%90 = load i32, i32* %12
%91 = sub nsw i32 %90, 1
%92 = icmp slt i32 %89, %91
br i1 %92, label %93, label %126
93: ; preds = %88
%94 = load double*, double** %7
%95 = load double*, double** %9
%96 = load i32, i32* %11
%97 = sext i32 %96 to i64
%98 = mul i64 %97, 8
%99 = trunc i64 %98 to i32
%100 = call i32 @memcpy(double* %94, double* %95, i32 %99)
%101 = load i32, i32* %8
%102 = load double*, double** %7
%103 = sext i32 %101 to i64
%104 = getelementptr inbounds double, double* %102, i64 %103
store double* %104, double** %7
%105 = load i32, i32* %10
%106 = load double*, double** %9
%107 = sext i32 %105 to i64
%108 = getelementptr inbounds double, double* %106, i64 %107
store double* %108, double** %9
%109 = load double*, double** %7
%110 = load double*, double** %9
%111 = load i32, i32* %11
%112 = sext i32 %111 to i64
%113 = mul i64 %112, 8
%114 = trunc i64 %113 to i32
%115 = call i32 @memcpy(double* %109, double* %110, i32 %114)
%116 = load i32, i32* %8
%117 = load double*, double** %7
%118 = sext i32 %116 to i64
%119 = getelementptr inbounds double, double* %117, i64 %118
store double* %119, double** %7
%120 = load i32, i32* %10
%121 = load double*, double** %9
%122 = sext i32 %120 to i64
%123 = getelementptr inbounds double, double* %121, i64 %122
store double* %123, double** %9
%124 = load i32, i32* %13
%125 = add nsw i32 %124, 2
store i32 %125, i32* %13
br label %126
126: ; preds = %93, %88
%127 = load i32, i32* %13
%128 = load i32, i32* %12
%129 = icmp slt i32 %127, %128
br i1 %129, label %130, label %138
130: ; preds = %126
%131 = load double*, double** %7
%132 = load double*, double** %9
%133 = load i32, i32* %11
%134 = sext i32 %133 to i64
%135 = mul i64 %134, 8
%136 = trunc i64 %135 to i32
%137 = call i32 @memcpy(double* %131, double* %132, i32 %136)
br label %138
138: ; preds = %87, %130, %126
ret void
}

LLVM IR (-O2):
define void @colcpy4(double* noalias %0, i32 %1, double* noalias %2, i32 %3, i32 %4, i32 %5) {
%7 = add nsw i32 %5, -3
%8 = icmp sgt i32 %5, 3
br i1 %8, label %9, label %31
9: ; preds = %6
%10 = shl i32 %4, 3
%11 = sext i32 %1 to i64
%12 = sext i32 %3 to i64
br label %13
13: ; preds = %9, %13
%14 = phi i32 [ 0, %9 ], [ %29, %13 ]
%15 = phi double* [ %0, %9 ], [ %27, %13 ]
%16 = phi double* [ %2, %9 ], [ %28, %13 ]
%17 = tail call i32 @memcpy(double* %15, double* %16, i32 %10)
%18 = getelementptr inbounds double, double* %15, i64 %11
%19 = getelementptr inbounds double, double* %16, i64 %12
%20 = tail call i32 @memcpy(double* %18, double* %19, i32 %10)
%21 = getelementptr inbounds double, double* %18, i64 %11
%22 = getelementptr inbounds double, double* %19, i64 %12
%23 = tail call i32 @memcpy(double* %21, double* %22, i32 %10)
%24 = getelementptr inbounds double, double* %21, i64 %11
%25 = getelementptr inbounds double, double* %22, i64 %12
%26 = tail call i32 @memcpy(double* %24, double* %25, i32 %10)
%27 = getelementptr inbounds double, double* %24, i64 %11
%28 = getelementptr inbounds double, double* %25, i64 %12
%29 = add nuw nsw i32 %14, 4
%30 = icmp slt i32 %29, %7
br i1 %30, label %13, label %31
31: ; preds = %13, %6
%32 = phi double* [ %2, %6 ], [ %28, %13 ]
%33 = phi double* [ %0, %6 ], [ %27, %13 ]
%34 = phi i32 [ 0, %6 ], [ %29, %13 ]
%35 = icmp eq i32 %34, %5
br i1 %35, label %58, label %36
36: ; preds = %31
%37 = add nsw i32 %5, -1
%38 = icmp slt i32 %34, %37
br i1 %38, label %39, label %50
39: ; preds = %36
%40 = shl i32 %4, 3
%41 = tail call i32 @memcpy(double* %33, double* %32, i32 %40)
%42 = sext i32 %1 to i64
%43 = getelementptr inbounds double, double* %33, i64 %42
%44 = sext i32 %3 to i64
%45 = getelementptr inbounds double, double* %32, i64 %44
%46 = tail call i32 @memcpy(double* %43, double* %45, i32 %40)
%47 = getelementptr inbounds double, double* %43, i64 %42
%48 = getelementptr inbounds double, double* %45, i64 %44
%49 = or i32 %34, 2
br label %50
50: ; preds = %39, %36
%51 = phi double* [ %48, %39 ], [ %32, %36 ]
%52 = phi double* [ %47, %39 ], [ %33, %36 ]
%53 = phi i32 [ %49, %39 ], [ %34, %36 ]
%54 = icmp slt i32 %53, %5
br i1 %54, label %55, label %58
55: ; preds = %50
%56 = shl i32 %4, 3
%57 = tail call i32 @memcpy(double* %52, double* %51, i32 %56)
br label %58
58: ; preds = %50, %55, %31
ret void
}