#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_cmpeq_epi16(int /*<<< orphan*/ const,
                                   int /*<<< orphan*/ const);
int _mm_movemask_epi8(int /*<<< orphan*/);
int /*<<< orphan*/ _mm_or_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_set1_epi16(int);
int check_epi16_overflow_x2(const __m128i *preg0, const __m128i *preg1) {
  const __m128i max_overflow = _mm_set1_epi16(0x7fff);
  const __m128i min_overflow = _mm_set1_epi16(0x8000);
  __m128i cmp0 = _mm_or_si128(_mm_cmpeq_epi16(*preg0, max_overflow),
                              _mm_cmpeq_epi16(*preg0, min_overflow));
  __m128i cmp1 = _mm_or_si128(_mm_cmpeq_epi16(*preg1, max_overflow),
                              _mm_cmpeq_epi16(*preg1, min_overflow));
  cmp0 = _mm_or_si128(cmp0, cmp1);
  return _mm_movemask_epi8(cmp0);
}


x86 assembly (clang, -O0):
<check_epi16_overflow_x2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x7fff,%edi
call   1030 <_mm_set1_epi16@plt>
mov    %eax,-0x14(%rbp)
mov    $0x8000,%edi
call   1030 <_mm_set1_epi16@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    -0x28(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1060 <_mm_movemask_epi8@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_epi16_overflow_x2>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x7fff,%edi
call   1030 <_mm_set1_epi16@plt>
mov    %eax,%r12d
mov    $0x8000,%edi
call   1030 <_mm_set1_epi16@plt>
mov    %eax,%r15d
mov    (%rbx),%edi
mov    %r12d,%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %eax,%ebp
mov    (%rbx),%edi
mov    %r15d,%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,%ebx
mov    (%r14),%edi
mov    %r12d,%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %eax,%ebp
mov    (%r14),%edi
mov    %r15d,%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1050 <_mm_or_si128@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <_mm_movemask_epi8@plt>

LLVM IR (-O0):
define i32 @check_epi16_overflow_x2(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%9 = call i32 @_mm_set1_epi16(i32 32767)
store i32 %9, i32* %5
%10 = call i32 @_mm_set1_epi16(i32 32768)
store i32 %10, i32* %6
%11 = load i32*, i32** %3
%12 = load i32, i32* %11
%13 = load i32, i32* %5
%14 = call i32 @_mm_cmpeq_epi16(i32 %12, i32 %13)
%15 = load i32*, i32** %3
%16 = load i32, i32* %15
%17 = load i32, i32* %6
%18 = call i32 @_mm_cmpeq_epi16(i32 %16, i32 %17)
%19 = call i32 @_mm_or_si128(i32 %14, i32 %18)
store i32 %19, i32* %7
%20 = load i32*, i32** %4
%21 = load i32, i32* %20
%22 = load i32, i32* %5
%23 = call i32 @_mm_cmpeq_epi16(i32 %21, i32 %22)
%24 = load i32*, i32** %4
%25 = load i32, i32* %24
%26 = load i32, i32* %6
%27 = call i32 @_mm_cmpeq_epi16(i32 %25, i32 %26)
%28 = call i32 @_mm_or_si128(i32 %23, i32 %27)
store i32 %28, i32* %8
%29 = load i32, i32* %7
%30 = load i32, i32* %8
%31 = call i32 @_mm_or_si128(i32 %29, i32 %30)
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = call i32 @_mm_movemask_epi8(i32 %32)
ret i32 %33
}

LLVM IR (-O2):
define i32 @check_epi16_overflow_x2(i32* nocapture %0, i32* nocapture %1) {
%3 = tail call i32 @_mm_set1_epi16(i32 32767)
%4 = tail call i32 @_mm_set1_epi16(i32 32768)
%5 = load i32, i32* %0
%6 = tail call i32 @_mm_cmpeq_epi16(i32 %5, i32 %3)
%7 = load i32, i32* %0
%8 = tail call i32 @_mm_cmpeq_epi16(i32 %7, i32 %4)
%9 = tail call i32 @_mm_or_si128(i32 %6, i32 %8)
%10 = load i32, i32* %1
%11 = tail call i32 @_mm_cmpeq_epi16(i32 %10, i32 %3)
%12 = load i32, i32* %1
%13 = tail call i32 @_mm_cmpeq_epi16(i32 %12, i32 %4)
%14 = tail call i32 @_mm_or_si128(i32 %11, i32 %13)
%15 = tail call i32 @_mm_or_si128(i32 %9, i32 %14)
%16 = tail call i32 @_mm_movemask_epi8(i32 %15)
ret i32 %16
}