#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_pd(double const *);
int /*<<< orphan*/ _mm_setzero_pd();
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_neg(double r[], const double x[], size_t N) {
  assert(r != NULL && ((size_t)r % 16) == 0);
  assert(x != NULL && ((size_t)x % 16) == 0);
  const __m128d vz = _mm_setzero_pd();
  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 r0 = _mm_sub_pd(vz, x0);
    const __m128d r1 = _mm_sub_pd(vz, x1);
    _mm_store_pd(r + n, r0);
    _mm_store_pd(r + n + 2, r1);
  }
}


x86 assembly (clang, -O0):
<xvm_neg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x39(%rbp)
je     1186 <xvm_neg+0x36>
mov    -0x8(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
sete   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x3a(%rbp)
je     11b5 <xvm_neg+0x65>
mov    -0x10(%rbp),%rax
and    $0xf,%rax
cmp    $0x0,%rax
sete   %al
mov    %al,-0x3a(%rbp)
mov    -0x3a(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    $0x0,%al
call   1070 <_mm_setzero_pd@plt>
mov    %eax,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1273 <xvm_neg+0x123>
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    -0x1c(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1040 <_mm_sub_pd@plt>
mov    %eax,-0x34(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1040 <_mm_sub_pd@plt>
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x34(%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    -0x38(%rbp),%esi
call   1030 <_mm_store_pd@plt>
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
jmp    11d4 <xvm_neg+0x84>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xvm_neg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbp
mov    %rsi,%r15
mov    %rdi,%rbx
test   %rdi,%rdi
setne  %al
test   $0xf,%bl
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>
xor    %eax,%eax
call   1070 <_mm_setzero_pd@plt>
mov    %eax,0xc(%rsp)
test   %rbp,%rbp
je     121c <xvm_neg+0xcc>
xor    %r14d,%r14d
mov    %rbp,0x10(%rsp)
mov    0xc(%rsp),%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1060 <_mm_load_pd@plt>
mov    %eax,%ebp
lea    0x10(%r15),%rdi
call   1060 <_mm_load_pd@plt>
mov    %eax,%r13d
mov    %r12d,%edi
mov    %ebp,%esi
call   1040 <_mm_sub_pd@plt>
mov    %eax,%ebp
mov    %r12d,%edi
mov    %r13d,%esi
call   1040 <_mm_sub_pd@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <_mm_store_pd@plt>
lea    0x10(%rbx),%rdi
mov    %r13d,%esi
mov    0x10(%rsp),%rbp
call   1030 <_mm_store_pd@plt>
add    $0x4,%r14
add    $0x20,%rbx
add    $0x20,%r15
cmp    %rbp,%r14
jb     11c0 <xvm_neg+0x70>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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