#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 uint32_t;
typedef int int32_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_EPI32(__m128i vec, int p, const int LANE) {
  __attribute__((aligned(16))) int32_t pvec[4] = {0, 0, 0, 0};
  __attribute__((aligned(16)))
  uint32_t mask[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff};
  __m128i vec_masked, p_masked;
  pvec[LANE] = 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_EPI32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1030 <memset@plt>
mov    0xe98(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe95(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%ecx
movslq -0xc(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
movslq -0xc(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
mov    -0x30(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1060 <_mm_and_si128@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1050 <_mm_andnot_si128@plt>
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1040 <_mm_or_si128@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_MM_INSERT_EPI32>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
mov    %edi,%eax
pxor   %xmm0,%xmm0
movdqa %xmm0,0x10(%rsp)
pcmpeqd %xmm0,%xmm0
movdqa %xmm0,(%rsp)
movslq %edx,%rcx
mov    %esi,0x10(%rsp,%rcx,4)
movl   $0x0,(%rsp,%rcx,4)
mov    (%rsp),%ebx
mov    %ebx,%edi
mov    %eax,%esi
call   1050 <_mm_and_si128@plt>
mov    %eax,%ebp
mov    0x10(%rsp),%esi
mov    %ebx,%edi
call   1040 <_mm_andnot_si128@plt>
mov    %ebp,%edi
mov    %eax,%esi
add    $0x28,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <_mm_or_si128@plt>

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

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