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

/* Variables and functions */
int /*<<< orphan*/ _mm_extract_epi16(int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_max_epi16(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_shuffle_epi32(int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_shufflelo_epi16(int /*<<< orphan*/, int);
int16_t accumulate_eob(__m128i eob) {
  __m128i eob_shuffled;
  eob_shuffled = _mm_shuffle_epi32(eob, 0xe);
  eob = _mm_max_epi16(eob, eob_shuffled);
  eob_shuffled = _mm_shufflelo_epi16(eob, 0xe);
  eob = _mm_max_epi16(eob, eob_shuffled);
  eob_shuffled = _mm_shufflelo_epi16(eob, 0x1);
  eob = _mm_max_epi16(eob, eob_shuffled);
  return _mm_extract_epi16(eob, 1);
}


x86 assembly (clang, -O0):
<accumulate_eob>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0xe,%esi
call   1050 <_mm_shuffle_epi32@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <_mm_max_epi16@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0xe,%esi
call   1040 <_mm_shufflelo_epi16@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <_mm_max_epi16@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1040 <_mm_shufflelo_epi16@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <_mm_max_epi16@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1060 <_mm_extract_epi16@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<accumulate_eob>:
push   %rbx
mov    %edi,%ebx
mov    $0xe,%esi
call   1050 <_mm_shuffle_epi32@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1030 <_mm_max_epi16@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    $0xe,%esi
call   1040 <_mm_shufflelo_epi16@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1030 <_mm_max_epi16@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    $0x1,%esi
call   1040 <_mm_shufflelo_epi16@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1030 <_mm_max_epi16@plt>
mov    %eax,%edi
mov    $0x1,%esi
pop    %rbx
jmp    1060 <_mm_extract_epi16@plt>

LLVM IR (-O0):
define i32 @accumulate_eob(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @_mm_shuffle_epi32(i32 %4, i32 14)
store i32 %5, i32* %3
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = call i32 @_mm_max_epi16(i32 %6, i32 %7)
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = call i32 @_mm_shufflelo_epi16(i32 %9, i32 14)
store i32 %10, i32* %3
%11 = load i32, i32* %2
%12 = load i32, i32* %3
%13 = call i32 @_mm_max_epi16(i32 %11, i32 %12)
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = call i32 @_mm_shufflelo_epi16(i32 %14, i32 1)
store i32 %15, i32* %3
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = call i32 @_mm_max_epi16(i32 %16, i32 %17)
store i32 %18, i32* %2
%19 = load i32, i32* %2
%20 = call i32 @_mm_extract_epi16(i32 %19, i32 1)
ret i32 %20
}

LLVM IR (-O2):
define i32 @accumulate_eob(i32 %0) {
%2 = tail call i32 @_mm_shuffle_epi32(i32 %0, i32 14)
%3 = tail call i32 @_mm_max_epi16(i32 %0, i32 %2)
%4 = tail call i32 @_mm_shufflelo_epi16(i32 %3, i32 14)
%5 = tail call i32 @_mm_max_epi16(i32 %3, i32 %4)
%6 = tail call i32 @_mm_shufflelo_epi16(i32 %5, i32 1)
%7 = tail call i32 @_mm_max_epi16(i32 %5, i32 %6)
%8 = tail call i32 @_mm_extract_epi16(i32 %7, i32 1)
ret i32 %8
}