#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_x4(const __m128i *preg0, const __m128i *preg1,
                            const __m128i *preg2, const __m128i *preg3) {
  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));
  __m128i cmp2 = _mm_or_si128(_mm_cmpeq_epi16(*preg2, max_overflow),
                              _mm_cmpeq_epi16(*preg2, min_overflow));
  __m128i cmp3 = _mm_or_si128(_mm_cmpeq_epi16(*preg3, max_overflow),
                              _mm_cmpeq_epi16(*preg3, min_overflow));
  cmp0 = _mm_or_si128(_mm_or_si128(cmp0, cmp1), _mm_or_si128(cmp2, cmp3));
  return _mm_movemask_epi8(cmp0);
}


x86 assembly (clang, -O0):
<check_epi16_overflow_x4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    $0x7fff,%edi
call   1030 <_mm_set1_epi16@plt>
mov    %eax,-0x24(%rbp)
mov    $0x8000,%edi
call   1030 <_mm_set1_epi16@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    -0x4c(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    -0x48(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    -0x44(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %eax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    -0x40(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,-0x38(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1050 <_mm_or_si128@plt>
mov    -0x3c(%rbp),%edi
mov    %eax,%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1060 <_mm_movemask_epi8@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_epi16_overflow_x4>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,(%rsp)
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%rbp
mov    $0x7fff,%edi
call   1030 <_mm_set1_epi16@plt>
mov    %eax,%ebx
mov    $0x8000,%edi
call   1030 <_mm_set1_epi16@plt>
mov    %eax,%r12d
mov    0x0(%rbp),%edi
mov    %ebx,%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %eax,%r14d
mov    0x0(%rbp),%edi
mov    %r12d,%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %r14d,%edi
mov    %eax,%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,%r14d
mov    0x0(%r13),%edi
mov    %ebx,%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %eax,%ebp
mov    0x0(%r13),%edi
mov    %r12d,%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,%r13d
mov    (%r15),%edi
mov    %ebx,%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %eax,%ebp
mov    (%r15),%edi
mov    %r12d,%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,%r15d
mov    (%rsp),%rbp
mov    0x0(%rbp),%edi
mov    %ebx,%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %eax,%ebx
mov    0x0(%rbp),%edi
mov    %r12d,%esi
call   1040 <_mm_cmpeq_epi16@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,%ebx
mov    %r14d,%edi
mov    %r13d,%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,%ebp
mov    %r15d,%edi
mov    %ebx,%esi
call   1050 <_mm_or_si128@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1050 <_mm_or_si128@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <_mm_movemask_epi8@plt>

LLVM IR (-O0):
define i32 @check_epi16_overflow_x4(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%15 = call i32 @_mm_set1_epi16(i32 32767)
store i32 %15, i32* %9
%16 = call i32 @_mm_set1_epi16(i32 32768)
store i32 %16, i32* %10
%17 = load i32*, i32** %5
%18 = load i32, i32* %17
%19 = load i32, i32* %9
%20 = call i32 @_mm_cmpeq_epi16(i32 %18, i32 %19)
%21 = load i32*, i32** %5
%22 = load i32, i32* %21
%23 = load i32, i32* %10
%24 = call i32 @_mm_cmpeq_epi16(i32 %22, i32 %23)
%25 = call i32 @_mm_or_si128(i32 %20, i32 %24)
store i32 %25, i32* %11
%26 = load i32*, i32** %6
%27 = load i32, i32* %26
%28 = load i32, i32* %9
%29 = call i32 @_mm_cmpeq_epi16(i32 %27, i32 %28)
%30 = load i32*, i32** %6
%31 = load i32, i32* %30
%32 = load i32, i32* %10
%33 = call i32 @_mm_cmpeq_epi16(i32 %31, i32 %32)
%34 = call i32 @_mm_or_si128(i32 %29, i32 %33)
store i32 %34, i32* %12
%35 = load i32*, i32** %7
%36 = load i32, i32* %35
%37 = load i32, i32* %9
%38 = call i32 @_mm_cmpeq_epi16(i32 %36, i32 %37)
%39 = load i32*, i32** %7
%40 = load i32, i32* %39
%41 = load i32, i32* %10
%42 = call i32 @_mm_cmpeq_epi16(i32 %40, i32 %41)
%43 = call i32 @_mm_or_si128(i32 %38, i32 %42)
store i32 %43, i32* %13
%44 = load i32*, i32** %8
%45 = load i32, i32* %44
%46 = load i32, i32* %9
%47 = call i32 @_mm_cmpeq_epi16(i32 %45, i32 %46)
%48 = load i32*, i32** %8
%49 = load i32, i32* %48
%50 = load i32, i32* %10
%51 = call i32 @_mm_cmpeq_epi16(i32 %49, i32 %50)
%52 = call i32 @_mm_or_si128(i32 %47, i32 %51)
store i32 %52, i32* %14
%53 = load i32, i32* %11
%54 = load i32, i32* %12
%55 = call i32 @_mm_or_si128(i32 %53, i32 %54)
%56 = load i32, i32* %13
%57 = load i32, i32* %14
%58 = call i32 @_mm_or_si128(i32 %56, i32 %57)
%59 = call i32 @_mm_or_si128(i32 %55, i32 %58)
store i32 %59, i32* %11
%60 = load i32, i32* %11
%61 = call i32 @_mm_movemask_epi8(i32 %60)
ret i32 %61
}

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