#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*/ int64_t;
typedef int /*<<< orphan*/ __m128i;

/* Variables and functions */
int /*<<< orphan*/ _mm_add_epi64(int /*<<< orphan*/ const,
                                 int /*<<< orphan*/ const);
int /*<<< orphan*/ _mm_cmplt_epi32(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_setzero_si128();
int /*<<< orphan*/ _mm_unpackhi_epi32(int /*<<< orphan*/,
                                      int /*<<< orphan*/ const);
int /*<<< orphan*/ _mm_unpacklo_epi32(int /*<<< orphan*/,
                                      int /*<<< orphan*/ const);
int /*<<< orphan*/ xx_hsum_epi64_si64(int /*<<< orphan*/);
int64_t xx_hsum_epi32_si64(__m128i v_d) {
  const __m128i v_sign_d = _mm_cmplt_epi32(v_d, _mm_setzero_si128());
  const __m128i v_0_q = _mm_unpacklo_epi32(v_d, v_sign_d);
  const __m128i v_1_q = _mm_unpackhi_epi32(v_d, v_sign_d);
  return xx_hsum_epi64_si64(_mm_add_epi64(v_0_q, v_1_q));
}


x86 assembly (clang, -O0):
<xx_hsum_epi32_si64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1040 <_mm_setzero_si128@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%esi
call   1070 <_mm_cmplt_epi32@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1050 <_mm_unpacklo_epi32@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1080 <_mm_unpackhi_epi32@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1060 <_mm_add_epi64@plt>
mov    %eax,%edi
call   1030 <xx_hsum_epi64_si64@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xx_hsum_epi32_si64>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <_mm_setzero_si128@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1070 <_mm_cmplt_epi32@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <_mm_unpacklo_epi32@plt>
mov    %eax,%r14d
mov    %ebx,%edi
mov    %ebp,%esi
call   1080 <_mm_unpackhi_epi32@plt>
mov    %r14d,%edi
mov    %eax,%esi
call   1060 <_mm_add_epi64@plt>
mov    %eax,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <xx_hsum_epi64_si64@plt>

LLVM IR (-O0):
define i32 @xx_hsum_epi32_si64(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = call i32 (...) @_mm_setzero_si128()
%8 = call i32 @_mm_cmplt_epi32(i32 %6, i32 %7)
store i32 %8, i32* %3
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = call i32 @_mm_unpacklo_epi32(i32 %9, i32 %10)
store i32 %11, i32* %4
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = call i32 @_mm_unpackhi_epi32(i32 %12, i32 %13)
store i32 %14, i32* %5
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = call i32 @_mm_add_epi64(i32 %15, i32 %16)
%18 = call i32 @xx_hsum_epi64_si64(i32 %17)
ret i32 %18
}

LLVM IR (-O2):
define i32 @xx_hsum_epi32_si64(i32 %0) {
%2 = tail call i32 (...) @_mm_setzero_si128()
%3 = tail call i32 @_mm_cmplt_epi32(i32 %0, i32 %2)
%4 = tail call i32 @_mm_unpacklo_epi32(i32 %0, i32 %3)
%5 = tail call i32 @_mm_unpackhi_epi32(i32 %0, i32 %3)
%6 = tail call i32 @_mm_add_epi64(i32 %4, i32 %5)
%7 = tail call i32 @xx_hsum_epi64_si64(i32 %6)
ret i32 %7
}