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


x86 assembly (clang, -O0):
<_MM_INSERT_EPI16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x7,%rax
ja     1203 <_MM_INSERT_EPI16+0xf3>
mov    -0x18(%rbp),%rax
lea    0xec3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
xor    %edx,%edx
call   1030 <_mm_insert_epi16@plt>
mov    %eax,-0x4(%rbp)
jmp    1213 <_MM_INSERT_EPI16+0x103>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x1,%edx
call   1030 <_mm_insert_epi16@plt>
mov    %eax,-0x4(%rbp)
jmp    1213 <_MM_INSERT_EPI16+0x103>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x2,%edx
call   1030 <_mm_insert_epi16@plt>
mov    %eax,-0x4(%rbp)
jmp    1213 <_MM_INSERT_EPI16+0x103>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x3,%edx
call   1030 <_mm_insert_epi16@plt>
mov    %eax,-0x4(%rbp)
jmp    1213 <_MM_INSERT_EPI16+0x103>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x4,%edx
call   1030 <_mm_insert_epi16@plt>
mov    %eax,-0x4(%rbp)
jmp    1213 <_MM_INSERT_EPI16+0x103>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x5,%edx
call   1030 <_mm_insert_epi16@plt>
mov    %eax,-0x4(%rbp)
jmp    1213 <_MM_INSERT_EPI16+0x103>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x6,%edx
call   1030 <_mm_insert_epi16@plt>
mov    %eax,-0x4(%rbp)
jmp    1213 <_MM_INSERT_EPI16+0x103>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x7,%edx
call   1030 <_mm_insert_epi16@plt>
mov    %eax,-0x4(%rbp)
jmp    1213 <_MM_INSERT_EPI16+0x103>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
xor    %edx,%edx
call   1030 <_mm_insert_epi16@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_MM_INSERT_EPI16>:
lea    -0x1(%rdx),%eax
xor    %ecx,%ecx
cmp    $0x7,%eax
cmovae %ecx,%edx
jmp    1030 <_mm_insert_epi16@plt>

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

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