#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 */
typedef int /*<<< orphan*/ __m128d;

/* Variables and functions */
int /*<<< orphan*/ _mm_load_sd(double *);
int /*<<< orphan*/ _mm_loadh_pd(int /*<<< orphan*/, double *);
int /*<<< orphan*/ _mm_storeu_pd(double *, int /*<<< orphan*/);
void kernel_align_panel_2_3_lib4(int kmax, double *A0, int sda, double *B) {
  if (kmax <= 0)
    return;
  const int bs = 4;
  double *A1 = A0 + bs * sda;
  __m128d a_0;
  int k;
  for (k = 0; k < kmax - 3; k += 4) {
    a_0 = _mm_load_sd(&A0[3 + bs * 0]);
    a_0 = _mm_loadh_pd(a_0, &A1[0 + bs * 0]);
    _mm_storeu_pd(&B[0 + bs * 0], a_0);
    a_0 = _mm_load_sd(&A0[3 + bs * 1]);
    a_0 = _mm_loadh_pd(a_0, &A1[0 + bs * 1]);
    _mm_storeu_pd(&B[0 + bs * 1], a_0);
    a_0 = _mm_load_sd(&A0[3 + bs * 2]);
    a_0 = _mm_loadh_pd(a_0, &A1[0 + bs * 2]);
    _mm_storeu_pd(&B[0 + bs * 2], a_0);
    a_0 = _mm_load_sd(&A0[3 + bs * 3]);
    a_0 = _mm_loadh_pd(a_0, &A1[0 + bs * 3]);
    _mm_storeu_pd(&B[0 + bs * 3], a_0);
    A0 += 16;
    A1 += 16;
    B += 16;
  }
  for (; k < kmax; k++) {
    a_0 = _mm_load_sd(&A0[3 + bs * 0]);
    a_0 = _mm_loadh_pd(a_0, &A1[0 + bs * 0]);
    _mm_storeu_pd(&B[0 + bs * 0], a_0);
    A0 += 4;
    A1 += 4;
    B += 4;
  }
}


x86 assembly (clang, -O0):
<kernel_align_panel_2_3_lib4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     1155 <kernel_align_panel_2_3_lib4+0x25>
jmp    12f6 <kernel_align_panel_2_3_lib4+0x1c6>
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,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jge    1288 <kernel_align_panel_2_3_lib4+0x158>
mov    -0x10(%rbp),%rdi
add    $0x18,%rdi
call   1030 <_mm_load_sd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1040 <_mm_loadh_pd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1050 <_mm_storeu_pd@plt>
mov    -0x10(%rbp),%rdi
add    $0x38,%rdi
call   1030 <_mm_load_sd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
add    $0x20,%rsi
call   1040 <_mm_loadh_pd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x20,%rdi
mov    -0x34(%rbp),%esi
call   1050 <_mm_storeu_pd@plt>
mov    -0x10(%rbp),%rdi
add    $0x58,%rdi
call   1030 <_mm_load_sd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
add    $0x40,%rsi
call   1040 <_mm_loadh_pd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x40,%rdi
mov    -0x34(%rbp),%esi
call   1050 <_mm_storeu_pd@plt>
mov    -0x10(%rbp),%rdi
add    $0x78,%rdi
call   1030 <_mm_load_sd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
add    $0x60,%rsi
call   1040 <_mm_loadh_pd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x60,%rdi
mov    -0x34(%rbp),%esi
call   1050 <_mm_storeu_pd@plt>
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    -0x38(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x38(%rbp)
jmp    117b <kernel_align_panel_2_3_lib4+0x4b>
jmp    128d <kernel_align_panel_2_3_lib4+0x15d>
mov    -0x38(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12f6 <kernel_align_panel_2_3_lib4+0x1c6>
mov    -0x10(%rbp),%rdi
add    $0x18,%rdi
call   1030 <_mm_load_sd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1040 <_mm_loadh_pd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1050 <_mm_storeu_pd@plt>
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    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    128d <kernel_align_panel_2_3_lib4+0x15d>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_align_panel_2_3_lib4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edi,%edi
jle    128d <kernel_align_panel_2_3_lib4+0x15d>
mov    %rcx,%r14
mov    %rsi,%r12
mov    %edi,%ebx
shl    $0x2,%edx
movslq %edx,%rax
lea    (%rsi,%rax,8),%r13
xor    %eax,%eax
cmp    $0x4,%edi
jb     1251 <kernel_align_panel_2_3_lib4+0x121>
mov    %rbx,0x10(%rsp)
lea    -0x3(%rbx),%eax
mov    %eax,0x8(%rsp)
xor    %r15d,%r15d
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,0xc(%rsp)
lea    (%r15,%r13,1),%rbx
lea    (%r14,%r15,1),%rbp
lea    (%r12,%r15,1),%rdi
add    $0x18,%rdi
call   1030 <_mm_load_sd@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1040 <_mm_loadh_pd@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1050 <_mm_storeu_pd@plt>
lea    (%r12,%r15,1),%rdi
add    $0x38,%rdi
call   1030 <_mm_load_sd@plt>
lea    (%r15,%r13,1),%rsi
add    $0x20,%rsi
mov    %eax,%edi
call   1040 <_mm_loadh_pd@plt>
lea    (%r14,%r15,1),%rdi
add    $0x20,%rdi
mov    %eax,%esi
call   1050 <_mm_storeu_pd@plt>
lea    (%r12,%r15,1),%rdi
add    $0x58,%rdi
call   1030 <_mm_load_sd@plt>
lea    (%r15,%r13,1),%rsi
add    $0x40,%rsi
mov    %eax,%edi
call   1040 <_mm_loadh_pd@plt>
lea    (%r14,%r15,1),%rdi
add    $0x40,%rdi
mov    %eax,%esi
call   1050 <_mm_storeu_pd@plt>
lea    (%r12,%r15,1),%rdi
add    $0x78,%rdi
call   1030 <_mm_load_sd@plt>
lea    (%r15,%r13,1),%rsi
add    $0x60,%rsi
mov    %eax,%edi
call   1040 <_mm_loadh_pd@plt>
lea    (%r14,%r15,1),%rdi
add    $0x60,%rdi
mov    %eax,%esi
call   1050 <_mm_storeu_pd@plt>
mov    0xc(%rsp),%eax
add    $0x4,%eax
sub    $0xffffffffffffff80,%r15
cmp    0x8(%rsp),%eax
jl     1180 <kernel_align_panel_2_3_lib4+0x50>
add    %r15,%r13
add    %r15,%r12
add    %r15,%r14
mov    0x10(%rsp),%rbx
cmp    %ebx,%eax
jge    128d <kernel_align_panel_2_3_lib4+0x15d>
sub    %eax,%ebx
add    $0x18,%r12
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1030 <_mm_load_sd@plt>
mov    %eax,%edi
mov    %r13,%rsi
call   1040 <_mm_loadh_pd@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <_mm_storeu_pd@plt>
add    $0x20,%r13
add    $0x20,%r14
add    $0x20,%r12
add    $0xffffffff,%ebx
jne    1260 <kernel_align_panel_2_3_lib4+0x130>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @kernel_align_panel_2_3_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
%12 = alloca i32
store i32 %0, i32* %5
store double* %1, double** %6
store i32 %2, i32* %7
store double* %3, double** %8
%13 = load i32, i32* %5
%14 = icmp sle i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %4
br label %107
16: ; preds = %4
store i32 4, i32* %9
%17 = load double*, double** %6
%18 = load i32, i32* %7
%19 = mul nsw i32 4, %18
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %17, i64 %20
store double* %21, double** %10
store i32 0, i32* %12
br label %22
22: ; preds = %78, %16
%23 = load i32, i32* %12
%24 = load i32, i32* %5
%25 = sub nsw i32 %24, 3
%26 = icmp slt i32 %23, %25
br i1 %26, label %27, label %81
27: ; preds = %22
%28 = load double*, double** %6
%29 = getelementptr inbounds double, double* %28, i64 3
%30 = call i32 @_mm_load_sd(double* %29)
store i32 %30, i32* %11
%31 = load i32, i32* %11
%32 = load double*, double** %10
%33 = getelementptr inbounds double, double* %32, i64 0
%34 = call i32 @_mm_loadh_pd(i32 %31, double* %33)
store i32 %34, i32* %11
%35 = load double*, double** %8
%36 = getelementptr inbounds double, double* %35, i64 0
%37 = load i32, i32* %11
%38 = call i32 @_mm_storeu_pd(double* %36, i32 %37)
%39 = load double*, double** %6
%40 = getelementptr inbounds double, double* %39, i64 7
%41 = call i32 @_mm_load_sd(double* %40)
store i32 %41, i32* %11
%42 = load i32, i32* %11
%43 = load double*, double** %10
%44 = getelementptr inbounds double, double* %43, i64 4
%45 = call i32 @_mm_loadh_pd(i32 %42, double* %44)
store i32 %45, i32* %11
%46 = load double*, double** %8
%47 = getelementptr inbounds double, double* %46, i64 4
%48 = load i32, i32* %11
%49 = call i32 @_mm_storeu_pd(double* %47, i32 %48)
%50 = load double*, double** %6
%51 = getelementptr inbounds double, double* %50, i64 11
%52 = call i32 @_mm_load_sd(double* %51)
store i32 %52, i32* %11
%53 = load i32, i32* %11
%54 = load double*, double** %10
%55 = getelementptr inbounds double, double* %54, i64 8
%56 = call i32 @_mm_loadh_pd(i32 %53, double* %55)
store i32 %56, i32* %11
%57 = load double*, double** %8
%58 = getelementptr inbounds double, double* %57, i64 8
%59 = load i32, i32* %11
%60 = call i32 @_mm_storeu_pd(double* %58, i32 %59)
%61 = load double*, double** %6
%62 = getelementptr inbounds double, double* %61, i64 15
%63 = call i32 @_mm_load_sd(double* %62)
store i32 %63, i32* %11
%64 = load i32, i32* %11
%65 = load double*, double** %10
%66 = getelementptr inbounds double, double* %65, i64 12
%67 = call i32 @_mm_loadh_pd(i32 %64, double* %66)
store i32 %67, i32* %11
%68 = load double*, double** %8
%69 = getelementptr inbounds double, double* %68, i64 12
%70 = load i32, i32* %11
%71 = call i32 @_mm_storeu_pd(double* %69, i32 %70)
%72 = load double*, double** %6
%73 = getelementptr inbounds double, double* %72, i64 16
store double* %73, double** %6
%74 = load double*, double** %10
%75 = getelementptr inbounds double, double* %74, i64 16
store double* %75, double** %10
%76 = load double*, double** %8
%77 = getelementptr inbounds double, double* %76, i64 16
store double* %77, double** %8
br label %78
78: ; preds = %27
%79 = load i32, i32* %12
%80 = add nsw i32 %79, 4
store i32 %80, i32* %12
br label %22
81: ; preds = %22
br label %82
82: ; preds = %104, %81
%83 = load i32, i32* %12
%84 = load i32, i32* %5
%85 = icmp slt i32 %83, %84
br i1 %85, label %86, label %107
86: ; preds = %82
%87 = load double*, double** %6
%88 = getelementptr inbounds double, double* %87, i64 3
%89 = call i32 @_mm_load_sd(double* %88)
store i32 %89, i32* %11
%90 = load i32, i32* %11
%91 = load double*, double** %10
%92 = getelementptr inbounds double, double* %91, i64 0
%93 = call i32 @_mm_loadh_pd(i32 %90, double* %92)
store i32 %93, i32* %11
%94 = load double*, double** %8
%95 = getelementptr inbounds double, double* %94, i64 0
%96 = load i32, i32* %11
%97 = call i32 @_mm_storeu_pd(double* %95, i32 %96)
%98 = load double*, double** %6
%99 = getelementptr inbounds double, double* %98, i64 4
store double* %99, double** %6
%100 = load double*, double** %10
%101 = getelementptr inbounds double, double* %100, i64 4
store double* %101, double** %10
%102 = load double*, double** %8
%103 = getelementptr inbounds double, double* %102, i64 4
store double* %103, double** %8
br label %104
104: ; preds = %86
%105 = load i32, i32* %12
%106 = add nsw i32 %105, 1
store i32 %106, i32* %12
br label %82
107: ; preds = %15, %82
ret void
}

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