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

/* Variables and functions */
int /*<<< orphan*/ _MM_SHUFFLE(int, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm256_addsub_ps(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm256_movehdup_ps(int /*<<< orphan*/);
int /*<<< orphan*/ _mm256_moveldup_ps(int /*<<< orphan*/);
int /*<<< orphan*/ _mm256_mul_ps(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm256_shuffle_ps(int /*<<< orphan*/, int /*<<< orphan*/,
                                     int /*<<< orphan*/);
__m256 avx_cmul_i(__m256 a, __m256 b) {
  __m256 c;
  c = _mm256_mul_ps(_mm256_moveldup_ps(a), b);
  b = _mm256_shuffle_ps(b, b, _MM_SHUFFLE(2, 3, 0, 1));
  a = _mm256_mul_ps(_mm256_movehdup_ps(a), b);
  return _mm256_addsub_ps(c, a);
}


x86 assembly (clang, -O0):
<avx_cmul_i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1080 <_mm256_moveldup_ps@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1050 <_mm256_mul_ps@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x2,%edi
mov    $0x3,%esi
xor    %edx,%edx
mov    $0x1,%ecx
call   1030 <_MM_SHUFFLE@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    %eax,%edx
call   1060 <_mm256_shuffle_ps@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <_mm256_movehdup_ps@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1050 <_mm256_mul_ps@plt>
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1040 <_mm256_addsub_ps@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<avx_cmul_i>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%ebx
call   1080 <_mm256_moveldup_ps@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1050 <_mm256_mul_ps@plt>
mov    %eax,%r14d
mov    $0x2,%edi
mov    $0x3,%esi
xor    %edx,%edx
mov    $0x1,%ecx
call   1030 <_MM_SHUFFLE@plt>
mov    %ebp,%edi
mov    %ebp,%esi
mov    %eax,%edx
call   1060 <_mm256_shuffle_ps@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1070 <_mm256_movehdup_ps@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1050 <_mm256_mul_ps@plt>
mov    %r14d,%edi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <_mm256_addsub_ps@plt>

LLVM IR (-O0):
define i32 @avx_cmul_i(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = call i32 @_mm256_moveldup_ps(i32 %6)
%8 = load i32, i32* %4
%9 = call i32 @_mm256_mul_ps(i32 %7, i32 %8)
store i32 %9, i32* %5
%10 = load i32, i32* %4
%11 = load i32, i32* %4
%12 = call i32 @_MM_SHUFFLE(i32 2, i32 3, i32 0, i32 1)
%13 = call i32 @_mm256_shuffle_ps(i32 %10, i32 %11, i32 %12)
store i32 %13, i32* %4
%14 = load i32, i32* %3
%15 = call i32 @_mm256_movehdup_ps(i32 %14)
%16 = load i32, i32* %4
%17 = call i32 @_mm256_mul_ps(i32 %15, i32 %16)
store i32 %17, i32* %3
%18 = load i32, i32* %5
%19 = load i32, i32* %3
%20 = call i32 @_mm256_addsub_ps(i32 %18, i32 %19)
ret i32 %20
}

LLVM IR (-O2):
define i32 @avx_cmul_i(i32 %0, i32 %1) {
%3 = tail call i32 @_mm256_moveldup_ps(i32 %0)
%4 = tail call i32 @_mm256_mul_ps(i32 %3, i32 %1)
%5 = tail call i32 @_MM_SHUFFLE(i32 2, i32 3, i32 0, i32 1)
%6 = tail call i32 @_mm256_shuffle_ps(i32 %1, i32 %1, i32 %5)
%7 = tail call i32 @_mm256_movehdup_ps(i32 %0)
%8 = tail call i32 @_mm256_mul_ps(i32 %7, i32 %6)
%9 = tail call i32 @_mm256_addsub_ps(i32 %4, i32 %8)
ret i32 %9
}