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


x86 assembly (clang, -O0):
<kernel_align_panel_3_2_lib4>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     1121 <kernel_align_panel_3_2_lib4+0x21>
jmp    12dd <kernel_align_panel_3_2_lib4+0x1dd>
movl   $0x4,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x2,%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jge    1266 <kernel_align_panel_3_2_lib4+0x166>
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
movsd  0x30(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
movsd  0x38(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x28(%rax)
mov    -0x30(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x30(%rax)
mov    -0x10(%rbp),%rax
movsd  0x50(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x40(%rax)
mov    -0x10(%rbp),%rax
movsd  0x58(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x48(%rax)
mov    -0x30(%rbp),%rax
movsd  0x40(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x50(%rax)
mov    -0x10(%rbp),%rax
movsd  0x70(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x60(%rax)
mov    -0x10(%rbp),%rax
movsd  0x78(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x68(%rax)
mov    -0x30(%rbp),%rax
movsd  0x60(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x70(%rax)
mov    -0x10(%rbp),%rax
add    $0x80,%rax
mov    %rax,-0x10(%rbp)
mov    -0x30(%rbp),%rax
add    $0x80,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
add    $0x80,%rax
mov    %rax,-0x20(%rbp)
mov    -0x34(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x34(%rbp)
jmp    1147 <kernel_align_panel_3_2_lib4+0x47>
jmp    126b <kernel_align_panel_3_2_lib4+0x16b>
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12dd <kernel_align_panel_3_2_lib4+0x1dd>
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x18(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x10(%rbp)
mov    -0x30(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x20(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    126b <kernel_align_panel_3_2_lib4+0x16b>
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_align_panel_3_2_lib4>:
test   %edi,%edi
jle    125f <kernel_align_panel_3_2_lib4+0x15f>
shl    $0x2,%edx
movslq %edx,%rax
cmp    $0x4,%edi
jb     11c0 <kernel_align_panel_3_2_lib4+0xc0>
lea    -0x3(%rdi),%r8d
xor    %edx,%edx
nopl   (%rax)
movsd  0x10(%rsi),%xmm0
movsd  %xmm0,(%rcx)
movsd  0x18(%rsi),%xmm0
movsd  %xmm0,0x8(%rcx)
movsd  (%rsi,%rax,8),%xmm0
movsd  %xmm0,0x10(%rcx)
movsd  0x30(%rsi),%xmm0
movsd  %xmm0,0x20(%rcx)
movsd  0x38(%rsi),%xmm0
movsd  %xmm0,0x28(%rcx)
movsd  0x20(%rsi,%rax,8),%xmm0
movsd  %xmm0,0x30(%rcx)
movsd  0x50(%rsi),%xmm0
movsd  %xmm0,0x40(%rcx)
movsd  0x58(%rsi),%xmm0
movsd  %xmm0,0x48(%rcx)
movsd  0x40(%rsi,%rax,8),%xmm0
movsd  %xmm0,0x50(%rcx)
movsd  0x70(%rsi),%xmm0
movsd  %xmm0,0x60(%rcx)
movsd  0x78(%rsi),%xmm0
movsd  %xmm0,0x68(%rcx)
movsd  0x60(%rsi,%rax,8),%xmm0
movsd  %xmm0,0x70(%rcx)
sub    $0xffffffffffffff80,%rsi
sub    $0xffffffffffffff80,%rcx
add    $0x4,%edx
cmp    %r8d,%edx
jl     1120 <kernel_align_panel_3_2_lib4+0x20>
mov    %edi,%edx
and    $0xfffffffc,%edx
lea    (%rsi,%rax,8),%rax
cmp    %edi,%edx
jl     11ce <kernel_align_panel_3_2_lib4+0xce>
jmp    125f <kernel_align_panel_3_2_lib4+0x15f>
lea    (%rsi,%rax,8),%rax
xor    %edx,%edx
cmp    %edi,%edx
jge    125f <kernel_align_panel_3_2_lib4+0x15f>
mov    %edx,%r8d
not    %r8d
test   $0x1,%dil
je     1205 <kernel_align_panel_3_2_lib4+0x105>
movsd  0x10(%rsi),%xmm0
movsd  %xmm0,(%rcx)
movsd  0x18(%rsi),%xmm0
movsd  %xmm0,0x8(%rcx)
movsd  (%rax),%xmm0
movsd  %xmm0,0x10(%rcx)
add    $0x20,%rsi
add    $0x20,%rax
add    $0x20,%rcx
or     $0x1,%edx
add    %edi,%r8d
je     125f <kernel_align_panel_3_2_lib4+0x15f>
sub    %edx,%edi
xor    %edx,%edx
xchg   %ax,%ax
movsd  0x10(%rsi,%rdx,1),%xmm0
movsd  %xmm0,(%rcx,%rdx,1)
movsd  0x18(%rsi,%rdx,1),%xmm0
movsd  %xmm0,0x8(%rcx,%rdx,1)
movsd  (%rax,%rdx,1),%xmm0
movsd  %xmm0,0x10(%rcx,%rdx,1)
movsd  0x30(%rsi,%rdx,1),%xmm0
movsd  %xmm0,0x20(%rcx,%rdx,1)
movsd  0x38(%rsi,%rdx,1),%xmm0
movsd  %xmm0,0x28(%rcx,%rdx,1)
movsd  0x20(%rax,%rdx,1),%xmm0
movsd  %xmm0,0x30(%rcx,%rdx,1)
add    $0x40,%rdx
add    $0xfffffffe,%edi
jne    1210 <kernel_align_panel_3_2_lib4+0x110>
ret

LLVM IR (-O0):
define void @kernel_align_panel_3_2_lib4(i32 %0, double* %1, i32 %2, double* %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca i32
%8 = alloca double*
%9 = alloca i32
%10 = alloca double*
%11 = alloca i32
store i32 %0, i32* %5
store double* %1, double** %6
store i32 %2, i32* %7
store double* %3, double** %8
%12 = load i32, i32* %5
%13 = icmp sle i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %4
br label %126
15: ; preds = %4
store i32 4, i32* %9
%16 = load double*, double** %6
%17 = load i32, i32* %7
%18 = mul nsw i32 4, %17
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %16, i64 %19
store double* %20, double** %10
store i32 0, i32* %11
br label %21
21: ; preds = %93, %15
%22 = load i32, i32* %11
%23 = load i32, i32* %5
%24 = sub nsw i32 %23, 3
%25 = icmp slt i32 %22, %24
br i1 %25, label %26, label %96
26: ; preds = %21
%27 = load double*, double** %6
%28 = getelementptr inbounds double, double* %27, i64 2
%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** %6
%33 = getelementptr inbounds double, double* %32, i64 3
%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** %10
%38 = getelementptr inbounds double, double* %37, i64 0
%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** %6
%43 = getelementptr inbounds double, double* %42, i64 6
%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** %6
%48 = getelementptr inbounds double, double* %47, i64 7
%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** %10
%53 = getelementptr inbounds double, double* %52, i64 4
%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** %6
%58 = getelementptr inbounds double, double* %57, i64 10
%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** %6
%63 = getelementptr inbounds double, double* %62, i64 11
%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** %10
%68 = getelementptr inbounds double, double* %67, i64 8
%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** %6
%73 = getelementptr inbounds double, double* %72, i64 14
%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** %6
%78 = getelementptr inbounds double, double* %77, i64 15
%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** %10
%83 = getelementptr inbounds double, double* %82, i64 12
%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** %6
%88 = getelementptr inbounds double, double* %87, i64 16
store double* %88, double** %6
%89 = load double*, double** %10
%90 = getelementptr inbounds double, double* %89, i64 16
store double* %90, double** %10
%91 = load double*, double** %8
%92 = getelementptr inbounds double, double* %91, i64 16
store double* %92, double** %8
br label %93
93: ; preds = %26
%94 = load i32, i32* %11
%95 = add nsw i32 %94, 4
store i32 %95, i32* %11
br label %21
96: ; preds = %21
br label %97
97: ; preds = %123, %96
%98 = load i32, i32* %11
%99 = load i32, i32* %5
%100 = icmp slt i32 %98, %99
br i1 %100, label %101, label %126
101: ; preds = %97
%102 = load double*, double** %6
%103 = getelementptr inbounds double, double* %102, i64 2
%104 = load double, double* %103
%105 = load double*, double** %8
%106 = getelementptr inbounds double, double* %105, i64 0
store double %104, double* %106
%107 = load double*, double** %6
%108 = getelementptr inbounds double, double* %107, i64 3
%109 = load double, double* %108
%110 = load double*, double** %8
%111 = getelementptr inbounds double, double* %110, i64 1
store double %109, double* %111
%112 = load double*, double** %10
%113 = getelementptr inbounds double, double* %112, i64 0
%114 = load double, double* %113
%115 = load double*, double** %8
%116 = getelementptr inbounds double, double* %115, i64 2
store double %114, double* %116
%117 = load double*, double** %6
%118 = getelementptr inbounds double, double* %117, i64 4
store double* %118, double** %6
%119 = load double*, double** %10
%120 = getelementptr inbounds double, double* %119, i64 4
store double* %120, double** %10
%121 = load double*, double** %8
%122 = getelementptr inbounds double, double* %121, i64 4
store double* %122, double** %8
br label %123
123: ; preds = %101
%124 = load i32, i32* %11
%125 = add nsw i32 %124, 1
store i32 %125, i32* %11
br label %97
126: ; preds = %14, %97
ret void
}

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