void kernel_dgecp_3_0_lib4(int tri, int kmax, double *A, double *B) {
  if (tri == 1) {
    kmax += 1;
  }
  if (kmax <= 0)
    return;
  const int bs = 4;
  int k;
  for (k = 0; k < kmax - 3; k += 4) {
    B[0 + bs * 0] = A[0 + bs * 0];
    B[1 + bs * 0] = A[1 + bs * 0];
    B[2 + bs * 0] = A[2 + bs * 0];
    B[0 + bs * 1] = A[0 + bs * 1];
    B[1 + bs * 1] = A[1 + bs * 1];
    B[2 + bs * 1] = A[2 + bs * 1];
    B[0 + bs * 2] = A[0 + bs * 2];
    B[1 + bs * 2] = A[1 + bs * 2];
    B[2 + bs * 2] = A[2 + bs * 2];
    B[0 + bs * 3] = A[0 + bs * 3];
    B[1 + bs * 3] = A[1 + bs * 3];
    B[2 + bs * 3] = A[2 + bs * 3];
    A += 16;
    B += 16;
  }
  for (; k < kmax; k++) {
    B[0 + bs * 0] = A[0 + bs * 0];
    B[1 + bs * 0] = A[1 + bs * 0];
    B[2 + bs * 0] = A[2 + bs * 0];
    A += 4;
    B += 4;
  }
  if (tri == 1) {
    B[1 + bs * 0] = A[1 + bs * 0];
    B[2 + bs * 0] = A[2 + bs * 0];
    B[2 + bs * 1] = A[2 + bs * 1];
  }
}


x86 assembly (clang, -O0):
<kernel_dgecp_3_0_lib4>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
cmpl   $0x1,-0x4(%rbp)
jne    1125 <kernel_dgecp_3_0_lib4+0x25>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jg     1134 <kernel_dgecp_3_0_lib4+0x34>
jmp    12fe <kernel_dgecp_3_0_lib4+0x1fe>
movl   $0x4,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jge    1253 <kernel_dgecp_3_0_lib4+0x153>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
movsd  0x28(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x28(%rax)
mov    -0x10(%rbp),%rax
movsd  0x30(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x30(%rax)
mov    -0x10(%rbp),%rax
movsd  0x40(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x40(%rax)
mov    -0x10(%rbp),%rax
movsd  0x48(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x48(%rax)
mov    -0x10(%rbp),%rax
movsd  0x50(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x50(%rax)
mov    -0x10(%rbp),%rax
movsd  0x60(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x60(%rax)
mov    -0x10(%rbp),%rax
movsd  0x68(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x68(%rax)
mov    -0x10(%rbp),%rax
movsd  0x70(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x70(%rax)
mov    -0x10(%rbp),%rax
add    $0x80,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x80,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x20(%rbp)
jmp    1142 <kernel_dgecp_3_0_lib4+0x42>
jmp    1258 <kernel_dgecp_3_0_lib4+0x158>
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12be <kernel_dgecp_3_0_lib4+0x1be>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1258 <kernel_dgecp_3_0_lib4+0x158>
cmpl   $0x1,-0x4(%rbp)
jne    12fe <kernel_dgecp_3_0_lib4+0x1fe>
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
movsd  0x30(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x30(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_dgecp_3_0_lib4>:
xor    %eax,%eax
cmp    $0x1,%edi
sete   %al
add    %esi,%eax
test   %eax,%eax
jle    126a <kernel_dgecp_3_0_lib4+0x16a>
xor    %esi,%esi
cmp    $0x4,%eax
jb     11ba <kernel_dgecp_3_0_lib4+0xba>
lea    -0x3(%rax),%r8d
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%rdx),%xmm0
movsd  %xmm0,(%rcx)
movsd  0x8(%rdx),%xmm0
movsd  %xmm0,0x8(%rcx)
movsd  0x10(%rdx),%xmm0
movsd  %xmm0,0x10(%rcx)
movsd  0x20(%rdx),%xmm0
movsd  %xmm0,0x20(%rcx)
movsd  0x28(%rdx),%xmm0
movsd  %xmm0,0x28(%rcx)
movsd  0x30(%rdx),%xmm0
movsd  %xmm0,0x30(%rcx)
movsd  0x40(%rdx),%xmm0
movsd  %xmm0,0x40(%rcx)
movsd  0x48(%rdx),%xmm0
movsd  %xmm0,0x48(%rcx)
movsd  0x50(%rdx),%xmm0
movsd  %xmm0,0x50(%rcx)
movsd  0x60(%rdx),%xmm0
movsd  %xmm0,0x60(%rcx)
movsd  0x68(%rdx),%xmm0
movsd  %xmm0,0x68(%rcx)
movsd  0x70(%rdx),%xmm0
movsd  %xmm0,0x70(%rcx)
sub    $0xffffffffffffff80,%rdx
sub    $0xffffffffffffff80,%rcx
add    $0x4,%esi
cmp    %r8d,%esi
jl     1130 <kernel_dgecp_3_0_lib4+0x30>
cmp    %eax,%esi
jge    1247 <kernel_dgecp_3_0_lib4+0x147>
mov    %eax,%r9d
sub    %esi,%r9d
lea    0x1(%rsi),%r8d
test   $0x1,%r9b
je     11f9 <kernel_dgecp_3_0_lib4+0xf9>
movsd  (%rdx),%xmm0
movsd  %xmm0,(%rcx)
movsd  0x8(%rdx),%xmm0
movsd  %xmm0,0x8(%rcx)
movsd  0x10(%rdx),%xmm0
movsd  %xmm0,0x10(%rcx)
add    $0x20,%rdx
add    $0x20,%rcx
mov    %r8d,%esi
cmp    %r8d,%eax
je     1247 <kernel_dgecp_3_0_lib4+0x147>
sub    %esi,%eax
movsd  (%rdx),%xmm0
movsd  %xmm0,(%rcx)
movsd  0x8(%rdx),%xmm0
movsd  %xmm0,0x8(%rcx)
movsd  0x10(%rdx),%xmm0
movsd  %xmm0,0x10(%rcx)
movsd  0x20(%rdx),%xmm0
movsd  %xmm0,0x20(%rcx)
movsd  0x28(%rdx),%xmm0
movsd  %xmm0,0x28(%rcx)
movsd  0x30(%rdx),%xmm0
movsd  %xmm0,0x30(%rcx)
add    $0x40,%rdx
add    $0x40,%rcx
add    $0xfffffffe,%eax
jne    1200 <kernel_dgecp_3_0_lib4+0x100>
cmp    $0x1,%edi
jne    126a <kernel_dgecp_3_0_lib4+0x16a>
movsd  0x8(%rdx),%xmm0
movsd  %xmm0,0x8(%rcx)
movsd  0x10(%rdx),%xmm0
movsd  %xmm0,0x10(%rcx)
movsd  0x30(%rdx),%xmm0
movsd  %xmm0,0x30(%rcx)
ret

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

LLVM IR (-O2):
define void @kernel_dgecp_3_0_lib4(i32 %0, i32 %1, double* nocapture %2, double* nocapture writeonly %3) {
%5 = icmp eq i32 %0, 1
%6 = zext i1 %5 to i32
%7 = add i32 %6, %1
%8 = icmp slt i32 %7, 1
br i1 %8, label %120, label %9
9: ; preds = %4
%10 = add nsw i32 %7, -3
%11 = icmp ugt i32 %7, 3
br i1 %11, label %41, label %12
12: ; preds = %41, %9
%13 = phi double* [ %2, %9 ], [ %79, %41 ]
%14 = phi double* [ %3, %9 ], [ %80, %41 ]
%15 = phi i32 [ 0, %9 ], [ %81, %41 ]
%16 = icmp slt i32 %15, %7
br i1 %16, label %17, label %107
17: ; preds = %12
%18 = add i32 %6, %1
%19 = sub i32 %18, %15
%20 = add i32 %15, 1
%21 = and i32 %19, 1
%22 = icmp eq i32 %21, 0
br i1 %22, label %34, label %23
23: ; preds = %17
%24 = load double, double* %13
store double %24, double* %14
%25 = getelementptr inbounds double, double* %13, i64 1
%26 = load double, double* %25
%27 = getelementptr inbounds double, double* %14, i64 1
store double %26, double* %27
%28 = getelementptr inbounds double, double* %13, i64 2
%29 = load double, double* %28
%30 = getelementptr inbounds double, double* %14, i64 2
store double %29, double* %30
%31 = getelementptr inbounds double, double* %13, i64 4
%32 = getelementptr inbounds double, double* %14, i64 4
%33 = add nuw nsw i32 %15, 1
br label %34
34: ; preds = %23, %17
%35 = phi double* [ undef, %17 ], [ %31, %23 ]
%36 = phi double* [ undef, %17 ], [ %32, %23 ]
%37 = phi i32 [ %15, %17 ], [ %33, %23 ]
%38 = phi double* [ %14, %17 ], [ %32, %23 ]
%39 = phi double* [ %13, %17 ], [ %31, %23 ]
%40 = icmp eq i32 %18, %20
br i1 %40, label %107, label %83
41: ; preds = %9, %41
%42 = phi i32 [ %81, %41 ], [ 0, %9 ]
%43 = phi double* [ %80, %41 ], [ %3, %9 ]
%44 = phi double* [ %79, %41 ], [ %2, %9 ]
%45 = load double, double* %44
store double %45, double* %43
%46 = getelementptr inbounds double, double* %44, i64 1
%47 = load double, double* %46
%48 = getelementptr inbounds double, double* %43, i64 1
store double %47, double* %48
%49 = getelementptr inbounds double, double* %44, i64 2
%50 = load double, double* %49
%51 = getelementptr inbounds double, double* %43, i64 2
store double %50, double* %51
%52 = getelementptr inbounds double, double* %44, i64 4
%53 = load double, double* %52
%54 = getelementptr inbounds double, double* %43, i64 4
store double %53, double* %54
%55 = getelementptr inbounds double, double* %44, i64 5
%56 = load double, double* %55
%57 = getelementptr inbounds double, double* %43, i64 5
store double %56, double* %57
%58 = getelementptr inbounds double, double* %44, i64 6
%59 = load double, double* %58
%60 = getelementptr inbounds double, double* %43, i64 6
store double %59, double* %60
%61 = getelementptr inbounds double, double* %44, i64 8
%62 = load double, double* %61
%63 = getelementptr inbounds double, double* %43, i64 8
store double %62, double* %63
%64 = getelementptr inbounds double, double* %44, i64 9
%65 = load double, double* %64
%66 = getelementptr inbounds double, double* %43, i64 9
store double %65, double* %66
%67 = getelementptr inbounds double, double* %44, i64 10
%68 = load double, double* %67
%69 = getelementptr inbounds double, double* %43, i64 10
store double %68, double* %69
%70 = getelementptr inbounds double, double* %44, i64 12
%71 = load double, double* %70
%72 = getelementptr inbounds double, double* %43, i64 12
store double %71, double* %72
%73 = getelementptr inbounds double, double* %44, i64 13
%74 = load double, double* %73
%75 = getelementptr inbounds double, double* %43, i64 13
store double %74, double* %75
%76 = getelementptr inbounds double, double* %44, i64 14
%77 = load double, double* %76
%78 = getelementptr inbounds double, double* %43, i64 14
store double %77, double* %78
%79 = getelementptr inbounds double, double* %44, i64 16
%80 = getelementptr inbounds double, double* %43, i64 16
%81 = add nuw nsw i32 %42, 4
%82 = icmp slt i32 %81, %10
br i1 %82, label %41, label %12
83: ; preds = %34, %83
%84 = phi i32 [ %105, %83 ], [ %37, %34 ]
%85 = phi double* [ %104, %83 ], [ %38, %34 ]
%86 = phi double* [ %103, %83 ], [ %39, %34 ]
%87 = load double, double* %86
store double %87, double* %85
%88 = getelementptr inbounds double, double* %86, i64 1
%89 = load double, double* %88
%90 = getelementptr inbounds double, double* %85, i64 1
store double %89, double* %90
%91 = getelementptr inbounds double, double* %86, i64 2
%92 = load double, double* %91
%93 = getelementptr inbounds double, double* %85, i64 2
store double %92, double* %93
%94 = getelementptr inbounds double, double* %86, i64 4
%95 = getelementptr inbounds double, double* %85, i64 4
%96 = load double, double* %94
store double %96, double* %95
%97 = getelementptr inbounds double, double* %86, i64 5
%98 = load double, double* %97
%99 = getelementptr inbounds double, double* %85, i64 5
store double %98, double* %99
%100 = getelementptr inbounds double, double* %86, i64 6
%101 = load double, double* %100
%102 = getelementptr inbounds double, double* %85, i64 6
store double %101, double* %102
%103 = getelementptr inbounds double, double* %86, i64 8
%104 = getelementptr inbounds double, double* %85, i64 8
%105 = add nuw nsw i32 %84, 2
%106 = icmp eq i32 %105, %7
br i1 %106, label %107, label %83
107: ; preds = %34, %83, %12
%108 = phi double* [ %13, %12 ], [ %35, %34 ], [ %103, %83 ]
%109 = phi double* [ %14, %12 ], [ %36, %34 ], [ %104, %83 ]
br i1 %5, label %110, label %120
110: ; preds = %107
%111 = getelementptr inbounds double, double* %108, i64 1
%112 = load double, double* %111
%113 = getelementptr inbounds double, double* %109, i64 1
store double %112, double* %113
%114 = getelementptr inbounds double, double* %108, i64 2
%115 = load double, double* %114
%116 = getelementptr inbounds double, double* %109, i64 2
store double %115, double* %116
%117 = getelementptr inbounds double, double* %108, i64 6
%118 = load double, double* %117
%119 = getelementptr inbounds double, double* %109, i64 6
store double %118, double* %119
br label %120
120: ; preds = %107, %110, %4
ret void
}