void kernel_align_panel_1_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[0 + bs * 1] = A[0 + bs * 1];
    B[0 + bs * 2] = A[0 + bs * 2];
    B[0 + bs * 3] = A[0 + bs * 3];
    A += 16;
    B += 16;
  }
  for (; k < kmax; k++) {
    B[0 + bs * 0] = A[0 + bs * 0];
    A += 4;
    B += 4;
  }
}


x86 assembly (clang, -O0):
<kernel_align_panel_1_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_1_0_lib4+0x1e>
jmp    11f4 <kernel_align_panel_1_0_lib4+0xf4>
movl   $0x4,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jge    11ad <kernel_align_panel_1_0_lib4+0xad>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x20(%rax)
mov    -0x10(%rbp),%rax
movsd  0x40(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x40(%rax)
mov    -0x10(%rbp),%rax
movsd  0x60(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x60(%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_1_0_lib4+0x2c>
jmp    11b2 <kernel_align_panel_1_0_lib4+0xb2>
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11f4 <kernel_align_panel_1_0_lib4+0xf4>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%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    11b2 <kernel_align_panel_1_0_lib4+0xb2>
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_align_panel_1_0_lib4>:
test   %edi,%edi
jle    1235 <kernel_align_panel_1_0_lib4+0x135>
xor    %r9d,%r9d
cmp    $0x4,%edi
jb     115c <kernel_align_panel_1_0_lib4+0x5c>
lea    -0x3(%rdi),%eax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rsi),%xmm0
movsd  %xmm0,(%rdx)
movsd  0x20(%rsi),%xmm0
movsd  %xmm0,0x20(%rdx)
movsd  0x40(%rsi),%xmm0
movsd  %xmm0,0x40(%rdx)
movsd  0x60(%rsi),%xmm0
movsd  %xmm0,0x60(%rdx)
sub    $0xffffffffffffff80,%rsi
sub    $0xffffffffffffff80,%rdx
add    $0x4,%ecx
cmp    %eax,%ecx
jl     1120 <kernel_align_panel_1_0_lib4+0x20>
mov    %edi,%r9d
and    $0xfffffffc,%r9d
cmp    %edi,%r9d
jge    1235 <kernel_align_panel_1_0_lib4+0x135>
mov    %edi,%ecx
sub    %r9d,%ecx
mov    %r9d,%r8d
not    %r8d
add    %edi,%r8d
and    $0x7,%ecx
je     119a <kernel_align_panel_1_0_lib4+0x9a>
neg    %ecx
xor    %eax,%eax
nopl   0x0(%rax)
movsd  (%rsi),%xmm0
movsd  %xmm0,(%rdx)
add    $0x20,%rsi
add    $0x20,%rdx
add    $0xffffffff,%eax
cmp    %eax,%ecx
jne    1180 <kernel_align_panel_1_0_lib4+0x80>
sub    %eax,%r9d
cmp    $0x7,%r8d
jb     1235 <kernel_align_panel_1_0_lib4+0x135>
sub    %r9d,%edi
xor    %eax,%eax
nopl   0x0(%rax)
movsd  (%rsi,%rax,1),%xmm0
movsd  %xmm0,(%rdx,%rax,1)
movsd  0x20(%rsi,%rax,1),%xmm0
movsd  %xmm0,0x20(%rdx,%rax,1)
movsd  0x40(%rsi,%rax,1),%xmm0
movsd  %xmm0,0x40(%rdx,%rax,1)
movsd  0x60(%rsi,%rax,1),%xmm0
movsd  %xmm0,0x60(%rdx,%rax,1)
movsd  0x80(%rsi,%rax,1),%xmm0
movsd  %xmm0,0x80(%rdx,%rax,1)
movsd  0xa0(%rsi,%rax,1),%xmm0
movsd  %xmm0,0xa0(%rdx,%rax,1)
movsd  0xc0(%rsi,%rax,1),%xmm0
movsd  %xmm0,0xc0(%rdx,%rax,1)
movsd  0xe0(%rsi,%rax,1),%xmm0
movsd  %xmm0,0xe0(%rdx,%rax,1)
add    $0x100,%rax
add    $0xfffffff8,%edi
jne    11b0 <kernel_align_panel_1_0_lib4+0xb0>
ret

LLVM IR (-O0):
define void @kernel_align_panel_1_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 %64
12: ; preds = %3
store i32 4, i32* %7
store i32 0, i32* %8
br label %13
13: ; preds = %43, %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 %46
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 4
%26 = load double, double* %25
%27 = load double*, double** %6
%28 = getelementptr inbounds double, double* %27, i64 4
store double %26, double* %28
%29 = load double*, double** %5
%30 = getelementptr inbounds double, double* %29, i64 8
%31 = load double, double* %30
%32 = load double*, double** %6
%33 = getelementptr inbounds double, double* %32, i64 8
store double %31, double* %33
%34 = load double*, double** %5
%35 = getelementptr inbounds double, double* %34, i64 12
%36 = load double, double* %35
%37 = load double*, double** %6
%38 = getelementptr inbounds double, double* %37, i64 12
store double %36, double* %38
%39 = load double*, double** %5
%40 = getelementptr inbounds double, double* %39, i64 16
store double* %40, double** %5
%41 = load double*, double** %6
%42 = getelementptr inbounds double, double* %41, i64 16
store double* %42, double** %6
br label %43
43: ; preds = %18
%44 = load i32, i32* %8
%45 = add nsw i32 %44, 4
store i32 %45, i32* %8
br label %13
46: ; preds = %13
br label %47
47: ; preds = %61, %46
%48 = load i32, i32* %8
%49 = load i32, i32* %4
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %64
51: ; preds = %47
%52 = load double*, double** %5
%53 = getelementptr inbounds double, double* %52, i64 0
%54 = load double, double* %53
%55 = load double*, double** %6
%56 = getelementptr inbounds double, double* %55, i64 0
store double %54, double* %56
%57 = load double*, double** %5
%58 = getelementptr inbounds double, double* %57, i64 4
store double* %58, double** %5
%59 = load double*, double** %6
%60 = getelementptr inbounds double, double* %59, i64 4
store double* %60, double** %6
br label %61
61: ; preds = %51
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
br label %47
64: ; preds = %11, %47
ret void
}

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