#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 _mm_extract_epi16(int /*<<< orphan*/, int);
extern __attribute__((__gnu___, __always___, __artificial__)) int
_MM_EXTRACT_EPI16(__m128i vec, const int LANE) {
  switch (LANE) {
  case 0:
    return _mm_extract_epi16(vec, 0);
  case 1:
    return _mm_extract_epi16(vec, 1);
  case 2:
    return _mm_extract_epi16(vec, 2);
  case 3:
    return _mm_extract_epi16(vec, 3);
  case 4:
    return _mm_extract_epi16(vec, 4);
  case 5:
    return _mm_extract_epi16(vec, 5);
  case 6:
    return _mm_extract_epi16(vec, 6);
  case 7:
    return _mm_extract_epi16(vec, 7);
  default:
    return _mm_extract_epi16(vec, 0);
  }
}


x86 assembly (clang, -O0):
<_MM_EXTRACT_EPI16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x7,%rax
ja     11e8 <_MM_EXTRACT_EPI16+0xd8>
mov    -0x18(%rbp),%rax
lea    0xec6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1030 <_mm_extract_epi16@plt>
mov    %eax,-0x4(%rbp)
jmp    11f5 <_MM_EXTRACT_EPI16+0xe5>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1030 <_mm_extract_epi16@plt>
mov    %eax,-0x4(%rbp)
jmp    11f5 <_MM_EXTRACT_EPI16+0xe5>
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1030 <_mm_extract_epi16@plt>
mov    %eax,-0x4(%rbp)
jmp    11f5 <_MM_EXTRACT_EPI16+0xe5>
mov    -0x8(%rbp),%edi
mov    $0x3,%esi
call   1030 <_mm_extract_epi16@plt>
mov    %eax,-0x4(%rbp)
jmp    11f5 <_MM_EXTRACT_EPI16+0xe5>
mov    -0x8(%rbp),%edi
mov    $0x4,%esi
call   1030 <_mm_extract_epi16@plt>
mov    %eax,-0x4(%rbp)
jmp    11f5 <_MM_EXTRACT_EPI16+0xe5>
mov    -0x8(%rbp),%edi
mov    $0x5,%esi
call   1030 <_mm_extract_epi16@plt>
mov    %eax,-0x4(%rbp)
jmp    11f5 <_MM_EXTRACT_EPI16+0xe5>
mov    -0x8(%rbp),%edi
mov    $0x6,%esi
call   1030 <_mm_extract_epi16@plt>
mov    %eax,-0x4(%rbp)
jmp    11f5 <_MM_EXTRACT_EPI16+0xe5>
mov    -0x8(%rbp),%edi
mov    $0x7,%esi
call   1030 <_mm_extract_epi16@plt>
mov    %eax,-0x4(%rbp)
jmp    11f5 <_MM_EXTRACT_EPI16+0xe5>
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1030 <_mm_extract_epi16@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_MM_EXTRACT_EPI16>:
lea    -0x1(%rsi),%eax
xor    %ecx,%ecx
cmp    $0x7,%eax
cmovae %ecx,%esi
jmp    1030 <_mm_extract_epi16@plt>

LLVM IR (-O0):
define i32 @_MM_EXTRACT_EPI16(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
switch i32 %6, label %31 [
i32 0, label %7
i32 1, label %10
i32 2, label %13
i32 3, label %16
i32 4, label %19
i32 5, label %22
i32 6, label %25
i32 7, label %28
]
7: ; preds = %2
%8 = load i32, i32* %4
%9 = call i32 @_mm_extract_epi16(i32 %8, i32 0)
store i32 %9, i32* %3
br label %34
10: ; preds = %2
%11 = load i32, i32* %4
%12 = call i32 @_mm_extract_epi16(i32 %11, i32 1)
store i32 %12, i32* %3
br label %34
13: ; preds = %2
%14 = load i32, i32* %4
%15 = call i32 @_mm_extract_epi16(i32 %14, i32 2)
store i32 %15, i32* %3
br label %34
16: ; preds = %2
%17 = load i32, i32* %4
%18 = call i32 @_mm_extract_epi16(i32 %17, i32 3)
store i32 %18, i32* %3
br label %34
19: ; preds = %2
%20 = load i32, i32* %4
%21 = call i32 @_mm_extract_epi16(i32 %20, i32 4)
store i32 %21, i32* %3
br label %34
22: ; preds = %2
%23 = load i32, i32* %4
%24 = call i32 @_mm_extract_epi16(i32 %23, i32 5)
store i32 %24, i32* %3
br label %34
25: ; preds = %2
%26 = load i32, i32* %4
%27 = call i32 @_mm_extract_epi16(i32 %26, i32 6)
store i32 %27, i32* %3
br label %34
28: ; preds = %2
%29 = load i32, i32* %4
%30 = call i32 @_mm_extract_epi16(i32 %29, i32 7)
store i32 %30, i32* %3
br label %34
31: ; preds = %2
%32 = load i32, i32* %4
%33 = call i32 @_mm_extract_epi16(i32 %32, i32 0)
store i32 %33, i32* %3
br label %34
34: ; preds = %31, %28, %25, %22, %19, %16, %13, %10, %7
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
define i32 @_MM_EXTRACT_EPI16(i32 %0, i32 %1) {
%3 = add i32 %1, -1
%4 = icmp ult i32 %3, 7
%5 = select i1 %4, i32 %1, i32 0
%6 = tail call i32 @_mm_extract_epi16(i32 %0, i32 %5)
ret i32 %6
}