#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_add_pd(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm256_hadd_pd(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm256_mul_pd(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm256_permute2f128_pd(int /*<<< orphan*/,
                                          int /*<<< orphan*/, int);
__m256d hadd4(__m256d v, __m256d u) {
  __m256d a, b;
  v = _mm256_hadd_pd(v, v);
  a = _mm256_permute2f128_pd(v, v, 1);
  v = _mm256_add_pd(a, v);
  u = _mm256_hadd_pd(u, u);
  b = _mm256_permute2f128_pd(u, u, 1);
  u = _mm256_add_pd(b, u);
  v = _mm256_mul_pd(v, u);
  return v;
}


x86 assembly (clang, -O0):
<hadd4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1060 <_mm256_hadd_pd@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    $0x1,%edx
call   1040 <_mm256_permute2f128_pd@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1050 <_mm256_add_pd@plt>
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1060 <_mm256_hadd_pd@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x1,%edx
call   1040 <_mm256_permute2f128_pd@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <_mm256_add_pd@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <_mm256_mul_pd@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hadd4>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%esi
call   1060 <_mm256_hadd_pd@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %eax,%esi
mov    $0x1,%edx
call   1040 <_mm256_permute2f128_pd@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1050 <_mm256_add_pd@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %ebx,%esi
call   1060 <_mm256_hadd_pd@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    %eax,%esi
mov    $0x1,%edx
call   1040 <_mm256_permute2f128_pd@plt>
mov    %eax,%edi
mov    %ebx,%esi
call   1050 <_mm256_add_pd@plt>
mov    %ebp,%edi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <_mm256_mul_pd@plt>

LLVM IR (-O0):
define i32 @hadd4(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = load i32, i32* %3
%9 = call i32 @_mm256_hadd_pd(i32 %7, i32 %8)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = load i32, i32* %3
%12 = call i32 @_mm256_permute2f128_pd(i32 %10, i32 %11, i32 1)
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = load i32, i32* %3
%15 = call i32 @_mm256_add_pd(i32 %13, i32 %14)
store i32 %15, i32* %3
%16 = load i32, i32* %4
%17 = load i32, i32* %4
%18 = call i32 @_mm256_hadd_pd(i32 %16, i32 %17)
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = load i32, i32* %4
%21 = call i32 @_mm256_permute2f128_pd(i32 %19, i32 %20, i32 1)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = load i32, i32* %4
%24 = call i32 @_mm256_add_pd(i32 %22, i32 %23)
store i32 %24, i32* %4
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = call i32 @_mm256_mul_pd(i32 %25, i32 %26)
store i32 %27, i32* %3
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
define i32 @hadd4(i32 %0, i32 %1) {
%3 = tail call i32 @_mm256_hadd_pd(i32 %0, i32 %0)
%4 = tail call i32 @_mm256_permute2f128_pd(i32 %3, i32 %3, i32 1)
%5 = tail call i32 @_mm256_add_pd(i32 %4, i32 %3)
%6 = tail call i32 @_mm256_hadd_pd(i32 %1, i32 %1)
%7 = tail call i32 @_mm256_permute2f128_pd(i32 %6, i32 %6, i32 1)
%8 = tail call i32 @_mm256_add_pd(i32 %7, i32 %6)
%9 = tail call i32 @_mm256_mul_pd(i32 %5, i32 %8)
ret i32 %9
}