void kernel_align_panel_2_0_lib4(int kmax, double *A, double *B) {
  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[0 + bs * 1] = A[0 + bs * 1];
    B[1 + bs * 1] = A[1 + bs * 1];
    B[0 + bs * 2] = A[0 + bs * 2];
    B[1 + bs * 2] = A[1 + bs * 2];
    B[0 + bs * 3] = A[0 + bs * 3];
    B[1 + bs * 3] = A[1 + 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];
    A += 4;
    B += 4;
  }
}


x86 assembly (clang, -O0):
<kernel_align_panel_2_0_lib4>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     111e <kernel_align_panel_2_0_lib4+0x1e>
jmp    124e <kernel_align_panel_2_0_lib4+0x14e>
movl   $0x4,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jge    11f5 <kernel_align_panel_2_0_lib4+0xf5>
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  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  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  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
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    112c <kernel_align_panel_2_0_lib4+0x2c>
jmp    11fa <kernel_align_panel_2_0_lib4+0xfa>
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    124e <kernel_align_panel_2_0_lib4+0x14e>
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
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    11fa <kernel_align_panel_2_0_lib4+0xfa>
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_align_panel_2_0_lib4>:
test   %edi,%edi
jle    1247 <kernel_align_panel_2_0_lib4+0x147>
xor    %r9d,%r9d
cmp    $0x4,%edi
jb     1184 <kernel_align_panel_2_0_lib4+0x84>
lea    -0x3(%rdi),%eax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rsi),%xmm0
movsd  %xmm0,(%rdx)
movsd  0x8(%rsi),%xmm0
movsd  %xmm0,0x8(%rdx)
movsd  0x20(%rsi),%xmm0
movsd  %xmm0,0x20(%rdx)
movsd  0x28(%rsi),%xmm0
movsd  %xmm0,0x28(%rdx)
movsd  0x40(%rsi),%xmm0
movsd  %xmm0,0x40(%rdx)
movsd  0x48(%rsi),%xmm0
movsd  %xmm0,0x48(%rdx)
movsd  0x60(%rsi),%xmm0
movsd  %xmm0,0x60(%rdx)
movsd  0x68(%rsi),%xmm0
movsd  %xmm0,0x68(%rdx)
sub    $0xffffffffffffff80,%rsi
sub    $0xffffffffffffff80,%rdx
add    $0x4,%ecx
cmp    %eax,%ecx
jl     1120 <kernel_align_panel_2_0_lib4+0x20>
mov    %edi,%r9d
and    $0xfffffffc,%r9d
cmp    %edi,%r9d
jge    1247 <kernel_align_panel_2_0_lib4+0x147>
mov    %r9d,%r8d
not    %r8d
add    %edi,%r8d
mov    %edi,%ecx
and    $0x3,%ecx
je     11d4 <kernel_align_panel_2_0_lib4+0xd4>
neg    %ecx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%rsi),%xmm0
movsd  %xmm0,(%rdx)
movsd  0x8(%rsi),%xmm0
movsd  %xmm0,0x8(%rdx)
add    $0x20,%rsi
add    $0x20,%rdx
add    $0xffffffff,%eax
cmp    %eax,%ecx
jne    11b0 <kernel_align_panel_2_0_lib4+0xb0>
sub    %eax,%r9d
cmp    $0x3,%r8d
jb     1247 <kernel_align_panel_2_0_lib4+0x147>
sub    %r9d,%edi
xor    %eax,%eax
nop
movsd  (%rsi,%rax,1),%xmm0
movsd  %xmm0,(%rdx,%rax,1)
movsd  0x8(%rsi,%rax,1),%xmm0
movsd  %xmm0,0x8(%rdx,%rax,1)
movsd  0x20(%rsi,%rax,1),%xmm0
movsd  %xmm0,0x20(%rdx,%rax,1)
movsd  0x28(%rsi,%rax,1),%xmm0
movsd  %xmm0,0x28(%rdx,%rax,1)
movsd  0x40(%rsi,%rax,1),%xmm0
movsd  %xmm0,0x40(%rdx,%rax,1)
movsd  0x48(%rsi,%rax,1),%xmm0
movsd  %xmm0,0x48(%rdx,%rax,1)
movsd  0x60(%rsi,%rax,1),%xmm0
movsd  %xmm0,0x60(%rdx,%rax,1)
movsd  0x68(%rsi,%rax,1),%xmm0
movsd  %xmm0,0x68(%rdx,%rax,1)
sub    $0xffffffffffffff80,%rax
add    $0xfffffffc,%edi
jne    11e0 <kernel_align_panel_2_0_lib4+0xe0>
ret

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

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