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

/* Variables and functions */
int /*<<< orphan*/ _mm_andnot_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_cmpgt_epi16(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_or_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_setzero_si128();
int /*<<< orphan*/ _mm_shuffle_epi8(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_unpackhi_epi64(int /*<<< orphan*/, int /*<<< orphan*/);
extern __attribute__((__gnu___, __always___, __artificial__)) __m128i
_MM_PACKUS1_EPI32(__m128i a) {
  __attribute__((aligned(16))) int8_t mask8_32_even_odd[16] = {
      0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15};
  __m128i a16, res, reshi, cmp, zero;
  zero = _mm_setzero_si128();
  a16 = _mm_shuffle_epi8(a, *(__m128i *)mask8_32_even_odd);
  reshi = _mm_unpackhi_epi64(a16, a16);
  cmp = _mm_cmpgt_epi16(zero, reshi);
  res = _mm_andnot_si128(cmp, a16);
  cmp = _mm_cmpgt_epi16(reshi, zero);
  return _mm_or_si128(res, cmp);
}


x86 assembly (clang, -O0):
<_MM_PACKUS1_EPI32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe7a(%rip),%rsi
mov    $0x40,%edx
call   1070 <memcpy@plt>
mov    $0x0,%al
call   1030 <_mm_setzero_si128@plt>
mov    %eax,-0x64(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x50(%rbp),%esi
call   1040 <_mm_shuffle_epi8@plt>
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%edi
mov    -0x54(%rbp),%esi
call   1050 <_mm_unpackhi_epi64@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x64(%rbp),%edi
mov    -0x5c(%rbp),%esi
call   1060 <_mm_cmpgt_epi16@plt>
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%edi
mov    -0x54(%rbp),%esi
call   1090 <_mm_andnot_si128@plt>
mov    %eax,-0x58(%rbp)
mov    -0x5c(%rbp),%edi
mov    -0x64(%rbp),%esi
call   1060 <_mm_cmpgt_epi16@plt>
mov    %eax,-0x60(%rbp)
mov    -0x58(%rbp),%edi
mov    -0x60(%rbp),%esi
call   1080 <_mm_or_si128@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_MM_PACKUS1_EPI32>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <_mm_setzero_si128@plt>
mov    %eax,%r14d
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <_mm_shuffle_epi8@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    %eax,%esi
call   1050 <_mm_unpackhi_epi64@plt>
mov    %eax,%ebp
mov    %r14d,%edi
mov    %eax,%esi
call   1060 <_mm_cmpgt_epi16@plt>
mov    %eax,%edi
mov    %ebx,%esi
call   1080 <_mm_andnot_si128@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    %r14d,%esi
call   1060 <_mm_cmpgt_epi16@plt>
mov    %ebx,%edi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <_mm_or_si128@plt>

LLVM IR (-O0):
@__const._MM_PACKUS1_EPI32.mask8_32_even_odd = [16 x i32] [i32 0, i32 1, i32 4, i32 5, i32 8, i32 9, i32 12, i32 13, i32 2, i32 3, i32 6, i32 7, i32 10, i32 11, i32 14, i32 15]
define i32 @_MM_PACKUS1_EPI32(i32 %0) {
%2 = alloca i32
%3 = alloca [16 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %2
%9 = bitcast [16 x i32]* %3 to i8*
%10 = call i32 (...) @_mm_setzero_si128()
store i32 %10, i32* %8
%11 = load i32, i32* %2
%12 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 0
%13 = load i32, i32* %12
%14 = call i32 @_mm_shuffle_epi8(i32 %11, i32 %13)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = load i32, i32* %4
%17 = call i32 @_mm_unpackhi_epi64(i32 %15, i32 %16)
store i32 %17, i32* %6
%18 = load i32, i32* %8
%19 = load i32, i32* %6
%20 = call i32 @_mm_cmpgt_epi16(i32 %18, i32 %19)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = load i32, i32* %4
%23 = call i32 @_mm_andnot_si128(i32 %21, i32 %22)
store i32 %23, i32* %5
%24 = load i32, i32* %6
%25 = load i32, i32* %8
%26 = call i32 @_mm_cmpgt_epi16(i32 %24, i32 %25)
store i32 %26, i32* %7
%27 = load i32, i32* %5
%28 = load i32, i32* %7
%29 = call i32 @_mm_or_si128(i32 %27, i32 %28)
ret i32 %29
}

LLVM IR (-O2):
define i32 @_MM_PACKUS1_EPI32(i32 %0) {
%2 = tail call i32 (...) @_mm_setzero_si128()
%3 = tail call i32 @_mm_shuffle_epi8(i32 %0, i32 0)
%4 = tail call i32 @_mm_unpackhi_epi64(i32 %3, i32 %3)
%5 = tail call i32 @_mm_cmpgt_epi16(i32 %2, i32 %4)
%6 = tail call i32 @_mm_andnot_si128(i32 %5, i32 %3)
%7 = tail call i32 @_mm_cmpgt_epi16(i32 %4, i32 %2)
%8 = tail call i32 @_mm_or_si128(i32 %6, i32 %7)
ret i32 %8
}