#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*/ __m256d;

/* Variables and functions */
int /*<<< orphan*/ _mm256_setr_pd(double const, double const, double const,
                                  double);
int /*<<< orphan*/ _mm256_sub_pd(int /*<<< orphan*/, int /*<<< orphan*/);
void subtract_vector(const double *a, const double *b, double *out) {
  __m256d A = _mm256_setr_pd(a[0], a[1], a[2], 0.0);
  __m256d B = _mm256_setr_pd(b[0], b[1], b[2], 0.0);
  __m256d C = _mm256_sub_pd(A, B);
  double *re = (double *)&C;
  out[0] = re[0];
  out[1] = re[1];
  out[2] = re[2];
}


x86 assembly (clang, -O0):
<subtract_vector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
xorps  %xmm3,%xmm3
call   1040 <_mm256_setr_pd@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
xorps  %xmm3,%xmm3
call   1040 <_mm256_setr_pd@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1030 <_mm256_sub_pd@plt>
mov    %eax,-0x24(%rbp)
lea    -0x24(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x30(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<subtract_vector>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
movsd  (%rdi),%xmm0
movsd  0x8(%rdi),%xmm1
movsd  0x10(%rdi),%xmm2
xorps  %xmm3,%xmm3
call   1040 <_mm256_setr_pd@plt>
mov    %eax,%ebp
movsd  (%rbx),%xmm0
movsd  0x8(%rbx),%xmm1
movsd  0x10(%rbx),%xmm2
xorps  %xmm3,%xmm3
call   1040 <_mm256_setr_pd@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1030 <_mm256_sub_pd@plt>
mov    %eax,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @subtract_vector(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%11 = load double*, double** %4
%12 = getelementptr inbounds double, double* %11, i64 0
%13 = load double, double* %12
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load double, double* %15
%17 = load double*, double** %4
%18 = getelementptr inbounds double, double* %17, i64 2
%19 = load double, double* %18
%20 = call i32 @_mm256_setr_pd(double %13, double %16, double %19, double 0.000000e+00)
store i32 %20, i32* %7
%21 = load double*, double** %5
%22 = getelementptr inbounds double, double* %21, i64 0
%23 = load double, double* %22
%24 = load double*, double** %5
%25 = getelementptr inbounds double, double* %24, i64 1
%26 = load double, double* %25
%27 = load double*, double** %5
%28 = getelementptr inbounds double, double* %27, i64 2
%29 = load double, double* %28
%30 = call i32 @_mm256_setr_pd(double %23, double %26, double %29, double 0.000000e+00)
store i32 %30, i32* %8
%31 = load i32, i32* %7
%32 = load i32, i32* %8
%33 = call i32 @_mm256_sub_pd(i32 %31, i32 %32)
store i32 %33, i32* %9
%34 = bitcast i32* %9 to double*
store double* %34, double** %10
%35 = load double*, double** %10
%36 = getelementptr inbounds double, double* %35, i64 0
%37 = load double, double* %36
%38 = load double*, double** %6
%39 = getelementptr inbounds double, double* %38, i64 0
store double %37, double* %39
%40 = load double*, double** %10
%41 = getelementptr inbounds double, double* %40, i64 1
%42 = load double, double* %41
%43 = load double*, double** %6
%44 = getelementptr inbounds double, double* %43, i64 1
store double %42, double* %44
%45 = load double*, double** %10
%46 = getelementptr inbounds double, double* %45, i64 2
%47 = load double, double* %46
%48 = load double*, double** %6
%49 = getelementptr inbounds double, double* %48, i64 2
store double %47, double* %49
ret void
}

LLVM IR (-O2):
define void @subtract_vector(double* nocapture %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = alloca i32
%5 = load double, double* %0
%6 = getelementptr inbounds double, double* %0, i64 1
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %0, i64 2
%9 = load double, double* %8
%10 = tail call i32 @_mm256_setr_pd(double %5, double %7, double %9, double 0.000000e+00)
%11 = load double, double* %1
%12 = getelementptr inbounds double, double* %1, i64 1
%13 = load double, double* %12
%14 = getelementptr inbounds double, double* %1, i64 2
%15 = load double, double* %14
%16 = tail call i32 @_mm256_setr_pd(double %11, double %13, double %15, double 0.000000e+00)
%17 = bitcast i32* %4 to i8*
%18 = tail call i32 @_mm256_sub_pd(i32 %10, i32 %16)
store i32 %18, i32* %4
%19 = bitcast i32* %4 to double*
%20 = load double, double* %19
store double %20, double* %2
ret void
}