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

/* Variables and functions */
int /*<<< orphan*/ _mm_and_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_andnot_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_or_si128(int /*<<< orphan*/, int /*<<< orphan*/);
extern __attribute__((__gnu___, __always___, __artificial__)) __m128i
_MM_INSERT_EPI8(__m128i vec, int p, const int LANE) {
  __attribute__((aligned(16)))
  int8_t pvec[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  __attribute__((aligned(16)))
  uint8_t mask[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
                      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  __m128i vec_masked, p_masked;
  pvec[LANE] = (int8_t)p;
  mask[LANE] = 0x0;
  vec_masked = _mm_and_si128(*(__m128i *)mask, vec);
  p_masked = _mm_andnot_si128(*(__m128i *)mask, *(__m128i *)pvec);
  return _mm_or_si128(vec_masked, p_masked);
}


x86 assembly (clang, -O0):
<_MM_INSERT_EPI8>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1030 <memset@plt>
lea    -0xd0(%rbp),%rdi
lea    0xe7b(%rip),%rsi
mov    $0x40,%edx
call   1040 <memcpy@plt>
movslq -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rax
mov    %rcx,-0x90(%rbp,%rax,8)
ff
movslq -0xc(%rbp),%rax
movl   $0x0,-0xd0(%rbp,%rax,4)
mov    -0xd0(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1070 <_mm_and_si128@plt>
mov    %eax,-0xd4(%rbp)
mov    -0xd0(%rbp),%edi
mov    -0x90(%rbp),%esi
call   1060 <_mm_andnot_si128@plt>
mov    %eax,-0xd8(%rbp)
mov    -0xd4(%rbp),%edi
mov    -0xd8(%rbp),%esi
call   1050 <_mm_or_si128@plt>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_MM_INSERT_EPI8>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
mov    %edi,%esi
movaps 0xef1(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xed5(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe9d(%rip),%xmm0
movaps %xmm0,(%rsp)
movslq %edx,%rax
movl   $0x0,(%rsp,%rax,4)
mov    (%rsp),%ebx
mov    %ebx,%edi
call   1050 <_mm_and_si128@plt>
mov    %eax,%ebp
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <_mm_andnot_si128@plt>
mov    %ebp,%edi
mov    %eax,%esi
add    $0x48,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <_mm_or_si128@plt>

LLVM IR (-O0):
@__const._MM_INSERT_EPI8.mask = [16 x i32] [i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255]
define i32 @_MM_INSERT_EPI8(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [16 x i64]
%8 = alloca [16 x i32]
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = bitcast [16 x i64]* %7 to i8*
%12 = bitcast [16 x i32]* %8 to i8*
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [16 x i64], [16 x i64]* %7, i64 0, i64 %16
store i64 %14, i64* %17
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 %19
store i32 0, i32* %20
%21 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 0
%22 = load i32, i32* %21
%23 = load i32, i32* %4
%24 = call i32 @_mm_and_si128(i32 %22, i32 %23)
store i32 %24, i32* %9
%25 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 0
%26 = load i32, i32* %25
%27 = getelementptr inbounds [16 x i64], [16 x i64]* %7, i64 0, i64 0
%28 = bitcast i64* %27 to i32*
%29 = load i32, i32* %28
%30 = call i32 @_mm_andnot_si128(i32 %26, i32 %29)
store i32 %30, i32* %10
%31 = load i32, i32* %9
%32 = load i32, i32* %10
%33 = call i32 @_mm_or_si128(i32 %31, i32 %32)
ret i32 %33
}

LLVM IR (-O2):
@__const._MM_INSERT_EPI8.mask = [16 x i32] [i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255, i32 255]
define i32 @_MM_INSERT_EPI8(i32 %0, i32 %1, i32 %2) {
%4 = alloca [16 x i32]
%5 = bitcast [16 x i32]* %4 to i8*
%6 = sext i32 %2 to i64
%7 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 %6
store i32 0, i32* %7
%8 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%9 = load i32, i32* %8
%10 = tail call i32 @_mm_and_si128(i32 %9, i32 %0)
%11 = tail call i32 @_mm_andnot_si128(i32 %9, i32 0)
%12 = tail call i32 @_mm_or_si128(i32 %10, i32 %11)
ret i32 %12
}