#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_add_sd(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_load_sd(double *);
int /*<<< orphan*/ _mm_mul_sd(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_store_sd(double *, int /*<<< orphan*/);
void kernel_dgead_1_0_lib4(int kmax, double alpha, double *A, double *B) {
  if (kmax <= 0)
    return;
  const int bs = 4;
  __m128d a_0, c_0, alpha_0;
  int k;
  alpha_0 = _mm_load_sd(&alpha);
  for (k = 0; k < kmax - 3; k += 4) {
    a_0 = _mm_load_sd(&A[0 + bs * 0]);
    c_0 = _mm_load_sd(&B[0 + bs * 0]);
    a_0 = _mm_mul_sd(alpha_0, a_0);
    a_0 = _mm_add_sd(c_0, a_0);
    _mm_store_sd(&B[0 + bs * 0], a_0);
    a_0 = _mm_load_sd(&A[0 + bs * 1]);
    c_0 = _mm_load_sd(&B[0 + bs * 1]);
    a_0 = _mm_mul_sd(alpha_0, a_0);
    a_0 = _mm_add_sd(c_0, a_0);
    _mm_store_sd(&B[0 + bs * 1], a_0);
    a_0 = _mm_load_sd(&A[0 + bs * 2]);
    c_0 = _mm_load_sd(&B[0 + bs * 2]);
    a_0 = _mm_mul_sd(alpha_0, a_0);
    a_0 = _mm_add_sd(c_0, a_0);
    _mm_store_sd(&B[0 + bs * 2], a_0);
    a_0 = _mm_load_sd(&A[0 + bs * 3]);
    c_0 = _mm_load_sd(&B[0 + bs * 3]);
    a_0 = _mm_mul_sd(alpha_0, a_0);
    a_0 = _mm_add_sd(c_0, a_0);
    _mm_store_sd(&B[0 + bs * 3], a_0);
    A += 16;
    B += 16;
  }
  for (; k < kmax; k++) {
    a_0 = _mm_load_sd(&A[0 + bs * 0]);
    c_0 = _mm_load_sd(&B[0 + bs * 0]);
    a_0 = _mm_mul_sd(alpha_0, a_0);
    a_0 = _mm_add_sd(c_0, a_0);
    _mm_store_sd(&B[0 + bs * 0], a_0);
    A += 4;
    B += 4;
  }
}


x86 assembly (clang, -O0):
<kernel_dgead_1_0_lib4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     1167 <kernel_dgead_1_0_lib4+0x27>
jmp    1357 <kernel_dgead_1_0_lib4+0x217>
movl   $0x4,-0x24(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x3,%ecx
cmp    %ecx,%eax
jge    12e0 <kernel_dgead_1_0_lib4+0x1a0>
mov    -0x18(%rbp),%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1050 <_mm_mul_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1030 <_mm_add_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1060 <_mm_store_sd@plt>
mov    -0x18(%rbp),%rdi
add    $0x20,%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x20,%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1050 <_mm_mul_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1030 <_mm_add_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x20,%rdi
mov    -0x28(%rbp),%esi
call   1060 <_mm_store_sd@plt>
mov    -0x18(%rbp),%rdi
add    $0x40,%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x40,%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1050 <_mm_mul_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1030 <_mm_add_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x40,%rdi
mov    -0x28(%rbp),%esi
call   1060 <_mm_store_sd@plt>
mov    -0x18(%rbp),%rdi
add    $0x60,%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x60,%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1050 <_mm_mul_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1030 <_mm_add_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x60,%rdi
mov    -0x28(%rbp),%esi
call   1060 <_mm_store_sd@plt>
mov    -0x18(%rbp),%rax
add    $0x80,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x80,%rax
mov    %rax,-0x20(%rbp)
mov    -0x34(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x34(%rbp)
jmp    1181 <kernel_dgead_1_0_lib4+0x41>
jmp    12e5 <kernel_dgead_1_0_lib4+0x1a5>
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1357 <kernel_dgead_1_0_lib4+0x217>
mov    -0x18(%rbp),%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1050 <_mm_mul_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1030 <_mm_add_sd@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1060 <_mm_store_sd@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x20(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12e5 <kernel_dgead_1_0_lib4+0x1a5>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_dgead_1_0_lib4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movsd  %xmm0,0x20(%rsp)
test   %edi,%edi
jle    12f2 <kernel_dgead_1_0_lib4+0x1b2>
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%ebp
lea    0x20(%rsp),%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,%r13d
xor    %eax,%eax
cmp    $0x4,%ebp
jb     12a8 <kernel_dgead_1_0_lib4+0x168>
mov    %rbp,0x18(%rsp)
lea    -0x3(%rbp),%eax
mov    %eax,0x10(%rsp)
xor    %eax,%eax
mov    %r13d,0xc(%rsp)
mov    0xc(%rsp),%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %eax,0x14(%rsp)
mov    %r14,%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,%r13d
mov    %r15d,%edi
mov    %ebp,%esi
call   1050 <_mm_mul_sd@plt>
mov    %r13d,%edi
mov    %eax,%esi
call   1030 <_mm_add_sd@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <_mm_store_sd@plt>
lea    0x20(%r14),%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,%r13d
lea    0x20(%rbx),%rbp
mov    %rbp,%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,%r12d
mov    %r15d,%edi
mov    %r13d,%esi
call   1050 <_mm_mul_sd@plt>
mov    %r12d,%edi
mov    %eax,%esi
call   1030 <_mm_add_sd@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1060 <_mm_store_sd@plt>
lea    0x40(%r14),%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,%r12d
lea    0x40(%rbx),%rbp
mov    %rbp,%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,%r13d
mov    %r15d,%edi
mov    %r12d,%esi
call   1050 <_mm_mul_sd@plt>
mov    %r13d,%edi
mov    %eax,%esi
call   1030 <_mm_add_sd@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1060 <_mm_store_sd@plt>
lea    0x60(%r14),%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,%r12d
lea    0x60(%rbx),%rbp
mov    %rbp,%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,%r13d
mov    %r15d,%edi
mov    %r12d,%esi
call   1050 <_mm_mul_sd@plt>
mov    %r13d,%edi
mov    %eax,%esi
call   1030 <_mm_add_sd@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1060 <_mm_store_sd@plt>
mov    0x14(%rsp),%eax
sub    $0xffffffffffffff80,%r14
sub    $0xffffffffffffff80,%rbx
add    $0x4,%eax
cmp    0x10(%rsp),%eax
jl     11a0 <kernel_dgead_1_0_lib4+0x60>
mov    0x18(%rsp),%rbp
mov    0xc(%rsp),%r13d
cmp    %ebp,%eax
jge    12f2 <kernel_dgead_1_0_lib4+0x1b2>
sub    %eax,%ebp
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1040 <_mm_load_sd@plt>
mov    %eax,%r12d
mov    %r13d,%edi
mov    %r15d,%esi
call   1050 <_mm_mul_sd@plt>
mov    %r12d,%edi
mov    %eax,%esi
call   1030 <_mm_add_sd@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <_mm_store_sd@plt>
add    $0x20,%r14
add    $0x20,%rbx
add    $0xffffffff,%ebp
jne    12b0 <kernel_dgead_1_0_lib4+0x170>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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