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

/* Variables and functions */
int /*<<< orphan*/ _mm_load_pd(double const *);
int /*<<< orphan*/ _mm_store_pd(double *, int /*<<< orphan*/ const);
int /*<<< orphan*/ _mm_sub_pd(int /*<<< orphan*/ const,
                              int /*<<< orphan*/ const);
int /*<<< orphan*/ assert(int);
void xvm_sub(double r[], const double x[], const double y[], uint64_t N) {
  assert(r != NULL && ((uintptr_t)r % 16) == 0);
  assert(x != NULL && ((uintptr_t)x % 16) == 0);
  assert(y != NULL && ((uintptr_t)y % 16) == 0);
  for (uint64_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 r0 = _mm_sub_pd(x0, y0);
    const __m128d r1 = _mm_sub_pd(x1, y1);
    _mm_store_pd(r + n, r0);
    _mm_store_pd(r + n + 2, r1);
  }
}


x86 assembly (clang, -O0):
<xvm_sub>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x41(%rbp)
je     117a <xvm_sub+0x3a>
mov    -0x8(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
sete   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x42(%rbp)
je     11a9 <xvm_sub+0x69>
mov    -0x10(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
sete   %al
mov    %al,-0x42(%rbp)
mov    -0x42(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x43(%rbp)
je     11d8 <xvm_sub+0x98>
mov    -0x18(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
sete   %al
mov    %al,-0x43(%rbp)
mov    -0x43(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    12be <xvm_sub+0x17e>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1060 <_mm_load_pd@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
add    $0x10,%rdi
call   1060 <_mm_load_pd@plt>
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1060 <_mm_load_pd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
add    $0x10,%rdi
call   1060 <_mm_load_pd@plt>
mov    %eax,-0x38(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x34(%rbp),%esi
call   1040 <_mm_sub_pd@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1040 <_mm_sub_pd@plt>
mov    %eax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x3c(%rbp),%esi
call   1030 <_mm_store_pd@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
add    $0x10,%rdi
mov    -0x40(%rbp),%esi
call   1030 <_mm_store_pd@plt>
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
jmp    11ed <xvm_sub+0xad>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xvm_sub>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
test   %rdi,%rdi
setne  %al
test   $0xf,%bl
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1050 <assert@plt>
test   %r12,%r12
setne  %al
test   $0xf,%r12b
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1050 <assert@plt>
test   %r15,%r15
setne  %al
test   $0xf,%r15b
sete   %cl
and    %al,%cl
movzbl %cl,%edi
call   1050 <assert@plt>
test   %r14,%r14
jle    122c <xvm_sub+0xec>
xor    %r13d,%r13d
mov    %r14,0x10(%rsp)
nop
mov    %r12,%rdi
call   1060 <_mm_load_pd@plt>
mov    %eax,0xc(%rsp)
lea    0x10(%r12),%rdi
call   1060 <_mm_load_pd@plt>
mov    %eax,0x8(%rsp)
mov    %r15,%rdi
call   1060 <_mm_load_pd@plt>
mov    %eax,%r14d
lea    0x10(%r15),%rdi
call   1060 <_mm_load_pd@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%edi
mov    %r14d,%esi
call   1040 <_mm_sub_pd@plt>
mov    %eax,%r14d
mov    0x8(%rsp),%edi
mov    %ebp,%esi
call   1040 <_mm_sub_pd@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r14d,%esi
mov    0x10(%rsp),%r14
call   1030 <_mm_store_pd@plt>
lea    0x10(%rbx),%rdi
mov    %ebp,%esi
call   1030 <_mm_store_pd@plt>
add    $0x4,%r13
add    $0x20,%rbx
add    $0x20,%r15
add    $0x20,%r12
cmp    %r14,%r13
jl     11b0 <xvm_sub+0x70>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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