#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_loadu_pd(double *);
int /*<<< orphan*/ _mm_store_sd(double *, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_storeu_pd(double *, int /*<<< orphan*/);
void kernel_align_panel_3_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, a_1;
  int k;
  for (k = 0; k < kmax - 3; k += 4) {
    a_0 = _mm_load_sd(&A0[3 + bs * 0]);
    _mm_store_sd(&B[0 + bs * 0], a_0);
    a_1 = _mm_loadu_pd(&A1[0 + bs * 0]);
    _mm_storeu_pd(&B[1 + bs * 0], a_1);
    a_0 = _mm_load_sd(&A0[3 + bs * 1]);
    _mm_store_sd(&B[0 + bs * 1], a_0);
    a_1 = _mm_loadu_pd(&A1[0 + bs * 1]);
    _mm_storeu_pd(&B[1 + bs * 1], a_1);
    a_0 = _mm_load_sd(&A0[3 + bs * 2]);
    _mm_store_sd(&B[0 + bs * 2], a_0);
    a_1 = _mm_loadu_pd(&A1[0 + bs * 2]);
    _mm_storeu_pd(&B[1 + bs * 2], a_1);
    a_0 = _mm_load_sd(&A0[3 + bs * 3]);
    _mm_store_sd(&B[0 + bs * 3], a_0);
    a_1 = _mm_loadu_pd(&A1[0 + bs * 3]);
    _mm_storeu_pd(&B[1 + bs * 3], a_1);
    A0 += 16;
    A1 += 16;
    B += 16;
  }
  for (; k < kmax; k++) {
    a_0 = _mm_load_sd(&A0[3 + bs * 0]);
    _mm_store_sd(&B[0 + bs * 0], a_0);
    a_1 = _mm_loadu_pd(&A1[0 + bs * 0]);
    _mm_storeu_pd(&B[1 + bs * 0], a_1);
    A0 += 4;
    A1 += 4;
    B += 4;
  }
}


x86 assembly (clang, -O0):
<kernel_align_panel_3_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     1165 <kernel_align_panel_3_3_lib4+0x25>
jmp    1347 <kernel_align_panel_3_3_lib4+0x207>
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,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jge    12cc <kernel_align_panel_3_3_lib4+0x18c>
mov    -0x10(%rbp),%rdi
add    $0x18,%rdi
call   1030 <_mm_load_sd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1060 <_mm_store_sd@plt>
mov    -0x30(%rbp),%rdi
call   1050 <_mm_loadu_pd@plt>
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x8,%rdi
mov    -0x38(%rbp),%esi
call   1040 <_mm_storeu_pd@plt>
mov    -0x10(%rbp),%rdi
add    $0x38,%rdi
call   1030 <_mm_load_sd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x20,%rdi
mov    -0x34(%rbp),%esi
call   1060 <_mm_store_sd@plt>
mov    -0x30(%rbp),%rdi
add    $0x20,%rdi
call   1050 <_mm_loadu_pd@plt>
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x28,%rdi
mov    -0x38(%rbp),%esi
call   1040 <_mm_storeu_pd@plt>
mov    -0x10(%rbp),%rdi
add    $0x58,%rdi
call   1030 <_mm_load_sd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x40,%rdi
mov    -0x34(%rbp),%esi
call   1060 <_mm_store_sd@plt>
mov    -0x30(%rbp),%rdi
add    $0x40,%rdi
call   1050 <_mm_loadu_pd@plt>
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x48,%rdi
mov    -0x38(%rbp),%esi
call   1040 <_mm_storeu_pd@plt>
mov    -0x10(%rbp),%rdi
add    $0x78,%rdi
call   1030 <_mm_load_sd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x60,%rdi
mov    -0x34(%rbp),%esi
call   1060 <_mm_store_sd@plt>
mov    -0x30(%rbp),%rdi
add    $0x60,%rdi
call   1050 <_mm_loadu_pd@plt>
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x68,%rdi
mov    -0x38(%rbp),%esi
call   1040 <_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    -0x3c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x3c(%rbp)
jmp    118b <kernel_align_panel_3_3_lib4+0x4b>
jmp    12d1 <kernel_align_panel_3_3_lib4+0x191>
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1347 <kernel_align_panel_3_3_lib4+0x207>
mov    -0x10(%rbp),%rdi
add    $0x18,%rdi
call   1030 <_mm_load_sd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1060 <_mm_store_sd@plt>
mov    -0x30(%rbp),%rdi
call   1050 <_mm_loadu_pd@plt>
mov    %eax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x8,%rdi
mov    -0x38(%rbp),%esi
call   1040 <_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    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12d1 <kernel_align_panel_3_3_lib4+0x191>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_align_panel_3_3_lib4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edi,%edi
jle    12d6 <kernel_align_panel_3_3_lib4+0x196>
mov    %rcx,%rbx
mov    %rsi,%r14
mov    %edi,%ebp
shl    $0x2,%edx
movslq %edx,%rax
lea    (%rsi,%rax,8),%r12
xor    %eax,%eax
cmp    $0x4,%edi
jb     1295 <kernel_align_panel_3_3_lib4+0x155>
mov    %rbp,0x10(%rsp)
lea    -0x3(%rbp),%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    (%r12,%r15,1),%r13
lea    (%rbx,%r15,1),%rbp
lea    (%r14,%r15,1),%rdi
add    $0x18,%rdi
call   1030 <_mm_load_sd@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1060 <_mm_store_sd@plt>
mov    %r13,%rdi
call   1050 <_mm_loadu_pd@plt>
lea    (%rbx,%r15,1),%rdi
add    $0x8,%rdi
mov    %eax,%esi
call   1040 <_mm_storeu_pd@plt>
lea    (%r14,%r15,1),%rdi
add    $0x38,%rdi
call   1030 <_mm_load_sd@plt>
lea    (%rbx,%r15,1),%rdi
add    $0x20,%rdi
mov    %eax,%esi
call   1060 <_mm_store_sd@plt>
lea    (%r12,%r15,1),%rdi
add    $0x20,%rdi
call   1050 <_mm_loadu_pd@plt>
lea    (%rbx,%r15,1),%rdi
add    $0x28,%rdi
mov    %eax,%esi
call   1040 <_mm_storeu_pd@plt>
lea    (%r14,%r15,1),%rdi
add    $0x58,%rdi
call   1030 <_mm_load_sd@plt>
lea    (%rbx,%r15,1),%rdi
add    $0x40,%rdi
mov    %eax,%esi
call   1060 <_mm_store_sd@plt>
lea    (%r12,%r15,1),%rdi
add    $0x40,%rdi
call   1050 <_mm_loadu_pd@plt>
lea    (%rbx,%r15,1),%rdi
add    $0x48,%rdi
mov    %eax,%esi
call   1040 <_mm_storeu_pd@plt>
lea    (%r14,%r15,1),%rdi
add    $0x78,%rdi
call   1030 <_mm_load_sd@plt>
lea    (%rbx,%r15,1),%rdi
add    $0x60,%rdi
mov    %eax,%esi
call   1060 <_mm_store_sd@plt>
lea    (%r12,%r15,1),%rdi
add    $0x60,%rdi
call   1050 <_mm_loadu_pd@plt>
lea    (%rbx,%r15,1),%rdi
add    $0x68,%rdi
mov    %eax,%esi
call   1040 <_mm_storeu_pd@plt>
mov    0xc(%rsp),%eax
add    $0x4,%eax
sub    $0xffffffffffffff80,%r15
cmp    0x8(%rsp),%eax
jl     1190 <kernel_align_panel_3_3_lib4+0x50>
add    %r15,%r12
add    %r15,%r14
add    %r15,%rbx
mov    0x10(%rsp),%rbp
cmp    %ebp,%eax
jge    12d6 <kernel_align_panel_3_3_lib4+0x196>
sub    %eax,%ebp
add    $0x18,%r14
nop
mov    %r14,%rdi
call   1030 <_mm_load_sd@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <_mm_store_sd@plt>
mov    %r12,%rdi
call   1050 <_mm_loadu_pd@plt>
lea    0x8(%rbx),%rdi
mov    %eax,%esi
call   1040 <_mm_storeu_pd@plt>
add    $0x20,%r12
add    $0x20,%r14
add    $0x20,%rbx
add    $0xffffffff,%ebp
jne    12a0 <kernel_align_panel_3_3_lib4+0x160>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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