#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_pd(int /*<<< orphan*/ const,
                              int /*<<< orphan*/ const);
int /*<<< orphan*/ _mm_load_pd(double const *);
int /*<<< orphan*/ _mm_mul_pd(int /*<<< orphan*/ const,
                              int /*<<< orphan*/ const);
int /*<<< orphan*/ _mm_set1_pd(double);
int /*<<< orphan*/ _mm_store_pd(double *, int /*<<< orphan*/ const);
int /*<<< orphan*/ assert(int);
void xvm_axpy(double r[], double a, const double x[], const double y[],
              size_t N) {
  assert(r != NULL && ((size_t)r % 16) == 0);
  assert(x != NULL && ((size_t)x % 16) == 0);
  assert(y != NULL && ((size_t)y % 16) == 0);
  const __m128d va = _mm_set1_pd(a);
  for (size_t n = 0; n < N; n += 4) {
    const __m128d x0 = _mm_load_pd(x + n);
    const __m128d x1 = _mm_load_pd(x + n + 2);
    const __m128d y0 = _mm_load_pd(y + n);
    const __m128d y1 = _mm_load_pd(y + n + 2);
    const __m128d t0 = _mm_mul_pd(x0, va);
    const __m128d t1 = _mm_mul_pd(x1, va);
    const __m128d r0 = _mm_add_pd(t0, y0);
    const __m128d r1 = _mm_add_pd(t1, y1);
    _mm_store_pd(r + n, r0);
    _mm_store_pd(r + n + 2, r1);
  }
}


x86 assembly (clang, -O0):
<xvm_axpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x59(%rbp)
je     119f <xvm_axpy+0x3f>
mov    -0x8(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
sete   %al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x5a(%rbp)
je     11ce <xvm_axpy+0x6e>
mov    -0x18(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
sete   %al
mov    %al,-0x5a(%rbp)
mov    -0x5a(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x5b(%rbp)
je     11fd <xvm_axpy+0x9d>
mov    -0x20(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
sete   %al
mov    %al,-0x5b(%rbp)
mov    -0x5b(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movsd  -0x10(%rbp),%xmm0
call   1040 <_mm_set1_pd@plt>
mov    %eax,-0x2c(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    130c <xvm_axpy+0x1ac>
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1070 <_mm_load_pd@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
add    $0x10,%rdi
call   1070 <_mm_load_pd@plt>
mov    %eax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1070 <_mm_load_pd@plt>
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
add    $0x10,%rdi
call   1070 <_mm_load_pd@plt>
mov    %eax,-0x48(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1080 <_mm_mul_pd@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x40(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1080 <_mm_mul_pd@plt>
mov    %eax,-0x50(%rbp)
mov    -0x4c(%rbp),%edi
mov    -0x44(%rbp),%esi
call   1050 <_mm_add_pd@plt>
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%edi
mov    -0x48(%rbp),%esi
call   1050 <_mm_add_pd@plt>
mov    %eax,-0x58(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x54(%rbp),%esi
call   1030 <_mm_store_pd@plt>
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
add    $0x10,%rdi
mov    -0x58(%rbp),%esi
call   1030 <_mm_store_pd@plt>
mov    -0x38(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x38(%rbp)
jmp    121f <xvm_axpy+0xbf>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xvm_axpy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r12
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%r13
test   %rdi,%rdi
setne  %al
test   $0xf,%r13b
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1060 <assert@plt>
test   %r12,%r12
setne  %al
test   $0xf,%r12b
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1060 <assert@plt>
test   %r15,%r15
setne  %al
test   $0xf,%r15b
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1060 <assert@plt>
movsd  0x8(%rsp),%xmm0
call   1040 <_mm_set1_pd@plt>
mov    %eax,0x14(%rsp)
test   %rbx,%rbx
je     128a <xvm_axpy+0x12a>
xor    %r14d,%r14d
mov    %rbx,0x20(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
call   1070 <_mm_load_pd@plt>
mov    %eax,%ebp
lea    0x10(%r12),%rdi
call   1070 <_mm_load_pd@plt>
mov    %eax,0x18(%rsp)
mov    %r15,%rdi
call   1070 <_mm_load_pd@plt>
mov    %eax,0x8(%rsp)
lea    0x10(%r15),%rdi
call   1070 <_mm_load_pd@plt>
mov    %eax,0x1c(%rsp)
mov    %ebp,%edi
mov    0x14(%rsp),%ebx
mov    %ebx,%esi
call   1080 <_mm_mul_pd@plt>
mov    %eax,%ebp
mov    0x18(%rsp),%edi
mov    %ebx,%esi
call   1080 <_mm_mul_pd@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    0x8(%rsp),%esi
call   1050 <_mm_add_pd@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    0x1c(%rsp),%esi
call   1050 <_mm_add_pd@plt>
mov    %eax,%ebx
mov    %r13,%rdi
mov    %ebp,%esi
call   1030 <_mm_store_pd@plt>
lea    0x10(%r13),%rdi
mov    %ebx,%esi
mov    0x20(%rsp),%rbx
call   1030 <_mm_store_pd@plt>
add    $0x4,%r14
add    $0x20,%r13
add    $0x20,%r15
add    $0x20,%r12
cmp    %rbx,%r14
jb     11f0 <xvm_axpy+0x90>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @xvm_axpy(double* %0, double %1, double* %2, double* %3, i64 %4) {
%6 = alloca double*
%7 = alloca double
%8 = alloca double*
%9 = alloca double*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i64
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store double* %0, double** %6
store double %1, double* %7
store double* %2, double** %8
store double* %3, double** %9
store i64 %4, i64* %10
%21 = load double*, double** %6
%22 = icmp ne double* %21, null
br i1 %22, label %23, label %28
23: ; preds = %5
%24 = load double*, double** %6
%25 = ptrtoint double* %24 to i64
%26 = urem i64 %25, 16
%27 = icmp eq i64 %26, 0
br label %28
28: ; preds = %23, %5
%29 = phi i1 [ false, %5 ], [ %27, %23 ]
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load double*, double** %8
%33 = icmp ne double* %32, null
br i1 %33, label %34, label %39
34: ; preds = %28
%35 = load double*, double** %8
%36 = ptrtoint double* %35 to i64
%37 = urem i64 %36, 16
%38 = icmp eq i64 %37, 0
br label %39
39: ; preds = %34, %28
%40 = phi i1 [ false, %28 ], [ %38, %34 ]
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = load double*, double** %9
%44 = icmp ne double* %43, null
br i1 %44, label %45, label %50
45: ; preds = %39
%46 = load double*, double** %9
%47 = ptrtoint double* %46 to i64
%48 = urem i64 %47, 16
%49 = icmp eq i64 %48, 0
br label %50
50: ; preds = %45, %39
%51 = phi i1 [ false, %39 ], [ %49, %45 ]
%52 = zext i1 %51 to i32
%53 = call i32 @assert(i32 %52)
%54 = load double, double* %7
%55 = call i32 @_mm_set1_pd(double %54)
store i32 %55, i32* %11
store i64 0, i64* %12
br label %56
56: ; preds = %102, %50
%57 = load i64, i64* %12
%58 = load i64, i64* %10
%59 = icmp ult i64 %57, %58
br i1 %59, label %60, label %105
60: ; preds = %56
%61 = load double*, double** %8
%62 = load i64, i64* %12
%63 = getelementptr inbounds double, double* %61, i64 %62
%64 = call i32 @_mm_load_pd(double* %63)
store i32 %64, i32* %13
%65 = load double*, double** %8
%66 = load i64, i64* %12
%67 = getelementptr inbounds double, double* %65, i64 %66
%68 = getelementptr inbounds double, double* %67, i64 2
%69 = call i32 @_mm_load_pd(double* %68)
store i32 %69, i32* %14
%70 = load double*, double** %9
%71 = load i64, i64* %12
%72 = getelementptr inbounds double, double* %70, i64 %71
%73 = call i32 @_mm_load_pd(double* %72)
store i32 %73, i32* %15
%74 = load double*, double** %9
%75 = load i64, i64* %12
%76 = getelementptr inbounds double, double* %74, i64 %75
%77 = getelementptr inbounds double, double* %76, i64 2
%78 = call i32 @_mm_load_pd(double* %77)
store i32 %78, i32* %16
%79 = load i32, i32* %13
%80 = load i32, i32* %11
%81 = call i32 @_mm_mul_pd(i32 %79, i32 %80)
store i32 %81, i32* %17
%82 = load i32, i32* %14
%83 = load i32, i32* %11
%84 = call i32 @_mm_mul_pd(i32 %82, i32 %83)
store i32 %84, i32* %18
%85 = load i32, i32* %17
%86 = load i32, i32* %15
%87 = call i32 @_mm_add_pd(i32 %85, i32 %86)
store i32 %87, i32* %19
%88 = load i32, i32* %18
%89 = load i32, i32* %16
%90 = call i32 @_mm_add_pd(i32 %88, i32 %89)
store i32 %90, i32* %20
%91 = load double*, double** %6
%92 = load i64, i64* %12
%93 = getelementptr inbounds double, double* %91, i64 %92
%94 = load i32, i32* %19
%95 = call i32 @_mm_store_pd(double* %93, i32 %94)
%96 = load double*, double** %6
%97 = load i64, i64* %12
%98 = getelementptr inbounds double, double* %96, i64 %97
%99 = getelementptr inbounds double, double* %98, i64 2
%100 = load i32, i32* %20
%101 = call i32 @_mm_store_pd(double* %99, i32 %100)
br label %102
102: ; preds = %60
%103 = load i64, i64* %12
%104 = add i64 %103, 4
store i64 %104, i64* %12
br label %56
105: ; preds = %56
ret void
}

LLVM IR (-O2):
define void @xvm_axpy(double* %0, double %1, double* %2, double* %3, i64 %4) {
%6 = icmp ne double* %0, null
%7 = ptrtoint double* %0 to i64
%8 = and i64 %7, 15
%9 = icmp eq i64 %8, 0
%10 = and i1 %6, %9
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = icmp ne double* %2, null
%14 = ptrtoint double* %2 to i64
%15 = and i64 %14, 15
%16 = icmp eq i64 %15, 0
%17 = and i1 %13, %16
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
%20 = icmp ne double* %3, null
%21 = ptrtoint double* %3 to i64
%22 = and i64 %21, 15
%23 = icmp eq i64 %22, 0
%24 = and i1 %20, %23
%25 = zext i1 %24 to i32
%26 = tail call i32 @assert(i32 %25)
%27 = tail call i32 @_mm_set1_pd(double %1)
%28 = icmp eq i64 %4, 0
br i1 %28, label %29, label %30
29: ; preds = %30, %5
ret void
30: ; preds = %5, %30
%31 = phi i64 [ %48, %30 ], [ 0, %5 ]
%32 = getelementptr inbounds double, double* %2, i64 %31
%33 = tail call i32 @_mm_load_pd(double* %32)
%34 = getelementptr inbounds double, double* %32, i64 2
%35 = tail call i32 @_mm_load_pd(double* %34)
%36 = getelementptr inbounds double, double* %3, i64 %31
%37 = tail call i32 @_mm_load_pd(double* %36)
%38 = getelementptr inbounds double, double* %36, i64 2
%39 = tail call i32 @_mm_load_pd(double* %38)
%40 = tail call i32 @_mm_mul_pd(i32 %33, i32 %27)
%41 = tail call i32 @_mm_mul_pd(i32 %35, i32 %27)
%42 = tail call i32 @_mm_add_pd(i32 %40, i32 %37)
%43 = tail call i32 @_mm_add_pd(i32 %41, i32 %39)
%44 = getelementptr inbounds double, double* %0, i64 %31
%45 = tail call i32 @_mm_store_pd(double* %44, i32 %42)
%46 = getelementptr inbounds double, double* %44, i64 2
%47 = tail call i32 @_mm_store_pd(double* %46, i32 %43)
%48 = add i64 %31, 4
%49 = icmp ult i64 %48, %4
br i1 %49, label %30, label %29
}