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

/* Variables and functions */
int /*<<< orphan*/ _MM_SHUFFLE(int /*<<< orphan*/, int /*<<< orphan*/, int,
                               int /*<<< orphan*/);
int /*<<< orphan*/ _mm_mul_epu32(int /*<<< orphan*/ const,
                                 int /*<<< orphan*/ const);
int /*<<< orphan*/ _mm_shuffle_epi32(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ const _mm_srli_si128(int /*<<< orphan*/ const, int);
int /*<<< orphan*/ _mm_unpacklo_epi32(int /*<<< orphan*/, int /*<<< orphan*/);
__m128i muly(const __m128i a, const __m128i b) {
  __m128i tmp1 = _mm_mul_epu32(a, b);
  __m128i tmp2 = _mm_mul_epu32(_mm_srli_si128(a, 4), _mm_srli_si128(b, 4));
  return _mm_unpacklo_epi32(_mm_shuffle_epi32(tmp1, _MM_SHUFFLE(0, 0, 2, 0)),
                            _mm_shuffle_epi32(tmp2, _MM_SHUFFLE(0, 0, 2, 0)));
}


x86 assembly (clang, -O0):
<muly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1070 <_mm_mul_epu32@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x4,%esi
call   1050 <_mm_srli_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x4,%esi
call   1050 <_mm_srli_si128@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%esi
call   1070 <_mm_mul_epu32@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
xor    %ecx,%ecx
mov    $0x2,%edx
mov    %ecx,%edi
mov    %ecx,%esi
call   1030 <_MM_SHUFFLE@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%esi
call   1060 <_mm_shuffle_epi32@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
xor    %ecx,%ecx
mov    $0x2,%edx
mov    %ecx,%edi
mov    %ecx,%esi
call   1030 <_MM_SHUFFLE@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%esi
call   1060 <_mm_shuffle_epi32@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%esi
call   1040 <_mm_unpacklo_epi32@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<muly>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%ebx
call   1070 <_mm_mul_epu32@plt>
mov    %eax,%r14d
mov    %ebx,%edi
mov    $0x4,%esi
call   1050 <_mm_srli_si128@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    $0x4,%esi
call   1050 <_mm_srli_si128@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1070 <_mm_mul_epu32@plt>
mov    %eax,%ebx
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
call   1030 <_MM_SHUFFLE@plt>
mov    %r14d,%edi
mov    %eax,%esi
call   1060 <_mm_shuffle_epi32@plt>
mov    %eax,%ebp
xor    %edi,%edi
xor    %esi,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
call   1030 <_MM_SHUFFLE@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1060 <_mm_shuffle_epi32@plt>
mov    %ebp,%edi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <_mm_unpacklo_epi32@plt>

LLVM IR (-O0):
define i32 @muly(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* %4
%9 = call i32 @_mm_mul_epu32(i32 %7, i32 %8)
store i32 %9, i32* %5
%10 = load i32, i32* %3
%11 = call i32 @_mm_srli_si128(i32 %10, i32 4)
%12 = load i32, i32* %4
%13 = call i32 @_mm_srli_si128(i32 %12, i32 4)
%14 = call i32 @_mm_mul_epu32(i32 %11, i32 %13)
store i32 %14, i32* %6
%15 = load i32, i32* %5
%16 = call i32 @_MM_SHUFFLE(i32 0, i32 0, i32 2, i32 0)
%17 = call i32 @_mm_shuffle_epi32(i32 %15, i32 %16)
%18 = load i32, i32* %6
%19 = call i32 @_MM_SHUFFLE(i32 0, i32 0, i32 2, i32 0)
%20 = call i32 @_mm_shuffle_epi32(i32 %18, i32 %19)
%21 = call i32 @_mm_unpacklo_epi32(i32 %17, i32 %20)
ret i32 %21
}

LLVM IR (-O2):
define i32 @muly(i32 %0, i32 %1) {
%3 = tail call i32 @_mm_mul_epu32(i32 %0, i32 %1)
%4 = tail call i32 @_mm_srli_si128(i32 %0, i32 4)
%5 = tail call i32 @_mm_srli_si128(i32 %1, i32 4)
%6 = tail call i32 @_mm_mul_epu32(i32 %4, i32 %5)
%7 = tail call i32 @_MM_SHUFFLE(i32 0, i32 0, i32 2, i32 0)
%8 = tail call i32 @_mm_shuffle_epi32(i32 %3, i32 %7)
%9 = tail call i32 @_MM_SHUFFLE(i32 0, i32 0, i32 2, i32 0)
%10 = tail call i32 @_mm_shuffle_epi32(i32 %6, i32 %9)
%11 = tail call i32 @_mm_unpacklo_epi32(i32 %8, i32 %10)
ret i32 %11
}