#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 int32_t;
typedef int /*<<< orphan*/ __m128;

/* Variables and functions */
int /*<<< orphan*/ _mm_and_ps(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_andnot_ps(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_or_ps(int /*<<< orphan*/, int /*<<< orphan*/);
extern __attribute__((__gnu___, __always___, __artificial__)) __m128
_MM_INSERT_PS(__m128 vec, __m128 p, const int LANE) {
  __attribute__((aligned(16)))
  int32_t mask[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff};
  __m128 tmp, vec_masked, p_masked;
  mask[LANE >> 4] = 0x0;
  vec_masked = _mm_and_ps(*(__m128 *)mask, vec);
  p_masked = _mm_andnot_ps(*(__m128 *)mask, p);
  tmp = _mm_or_ps(vec_masked, p_masked);
  return tmp;
}


x86 assembly (clang, -O0):
<_MM_INSERT_PS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb5(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sar    $0x4,%eax
cltq
movl   $0x0,-0x20(%rbp,%rax,4)
mov    -0x20(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1050 <_mm_and_ps@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <_mm_andnot_ps@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1030 <_mm_or_ps@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_MM_INSERT_PS>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %edi,%esi
pcmpeqd %xmm0,%xmm0
movdqa %xmm0,(%rsp)
sar    $0x4,%edx
movslq %edx,%rax
movl   $0x0,(%rsp,%rax,4)
mov    (%rsp),%ebp
mov    %ebp,%edi
call   1050 <_mm_and_ps@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    %r14d,%esi
call   1040 <_mm_andnot_ps@plt>
mov    %ebx,%edi
mov    %eax,%esi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <_mm_or_ps@plt>

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

LLVM IR (-O2):
define i32 @_MM_INSERT_PS(i32 %0, i32 %1, i32 %2) {
%4 = alloca [4 x i32]
%5 = bitcast [4 x i32]* %4 to i8*
%6 = ashr i32 %2, 4
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 %7
store i32 0, i32* %8
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%10 = load i32, i32* %9
%11 = tail call i32 @_mm_and_ps(i32 %10, i32 %0)
%12 = tail call i32 @_mm_andnot_ps(i32 %10, i32 %1)
%13 = tail call i32 @_mm_or_ps(i32 %11, i32 %12)
ret i32 %13
}