#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_add_epi16(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_mullo_epi16(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_or_si128(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_packus_epi16(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_slli_epi16(int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_slli_epi64(int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_srli_epi16(int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_srli_epi64(int /*<<< orphan*/, int);
int /*<<< orphan*/ _mm_sub_epi16(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_unpackhi_epi8(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_unpacklo_epi8(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_xor_si128(int /*<<< orphan*/, int /*<<< orphan*/);
__m128i blend_argb_sse_32(__m128i src, __m128i dst) {
  __m128i d16, s16, a16, t16;
  __m128i l16, h16;
  __m128i zero = _mm_xor_si128(src, src);
  s16 = _mm_unpacklo_epi8(src, zero);
  a16 = _mm_slli_epi64(s16, 48);
  a16 = _mm_or_si128(a16, _mm_srli_epi64(a16, 16));
  a16 = _mm_or_si128(a16, _mm_srli_epi64(a16, 32));
  d16 = _mm_unpacklo_epi8(dst, zero);
  t16 = _mm_sub_epi16(s16, d16);
  d16 = _mm_slli_epi16(d16, 8);
  t16 = _mm_add_epi16(_mm_mullo_epi16(t16, a16), d16);
  l16 = _mm_srli_epi16(t16, 8);
  s16 = _mm_unpackhi_epi8(src, zero);
  a16 = _mm_slli_epi64(s16, 48);
  a16 = _mm_or_si128(a16, _mm_srli_epi64(a16, 16));
  a16 = _mm_or_si128(a16, _mm_srli_epi64(a16, 32));
  d16 = _mm_unpackhi_epi8(dst, zero);
  t16 = _mm_sub_epi16(s16, d16);
  d16 = _mm_slli_epi16(d16, 8);
  t16 = _mm_add_epi16(_mm_mullo_epi16(t16, a16), d16);
  h16 = _mm_srli_epi16(t16, 8);
  return _mm_packus_epi16(l16, h16);
}


x86 assembly (clang, -O0):
<blend_argb_sse_32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x4(%rbp),%esi
call   10c0 <_mm_xor_si128@plt>
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1040 <_mm_unpacklo_epi8@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    $0x30,%esi
call   10d0 <_mm_slli_epi64@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x10,%esi
call   1090 <_mm_srli_epi64@plt>
mov    -0x34(%rbp),%edi
mov    %eax,%esi
call   10b0 <_mm_or_si128@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x20,%esi
call   1090 <_mm_srli_epi64@plt>
mov    -0x30(%rbp),%edi
mov    %eax,%esi
call   10b0 <_mm_or_si128@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1040 <_mm_unpacklo_epi8@plt>
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1070 <_mm_sub_epi16@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x8,%esi
call   10e0 <_mm_slli_epi16@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
call   10a0 <_mm_mullo_epi16@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%esi
call   1030 <_mm_add_epi16@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x8,%esi
call   1080 <_mm_srli_epi16@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1050 <_mm_unpackhi_epi8@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
mov    $0x30,%esi
call   10d0 <_mm_slli_epi64@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x10,%esi
call   1090 <_mm_srli_epi64@plt>
mov    -0x2c(%rbp),%edi
mov    %eax,%esi
call   10b0 <_mm_or_si128@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x20,%esi
call   1090 <_mm_srli_epi64@plt>
mov    -0x28(%rbp),%edi
mov    %eax,%esi
call   10b0 <_mm_or_si128@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1050 <_mm_unpackhi_epi8@plt>
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1070 <_mm_sub_epi16@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x8,%esi
call   10e0 <_mm_slli_epi16@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
call   10a0 <_mm_mullo_epi16@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%esi
call   1030 <_mm_add_epi16@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x8,%esi
call   1080 <_mm_srli_epi16@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1060 <_mm_packus_epi16@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blend_argb_sse_32>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %esi,0x4(%rsp)
mov    %edi,%r14d
mov    %edi,%esi
call   10c0 <_mm_xor_si128@plt>
mov    %eax,%r12d
mov    %r14d,%edi
mov    %eax,%esi
call   1040 <_mm_unpacklo_epi8@plt>
mov    %eax,%r15d
mov    %eax,%edi
mov    $0x30,%esi
call   10d0 <_mm_slli_epi64@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    $0x10,%esi
call   1090 <_mm_srli_epi64@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   10b0 <_mm_or_si128@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    $0x20,%esi
call   1090 <_mm_srli_epi64@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   10b0 <_mm_or_si128@plt>
mov    %eax,%r13d
mov    %ebx,%edi
mov    %r12d,%esi
call   1040 <_mm_unpacklo_epi8@plt>
mov    %eax,%ebp
mov    %r15d,%edi
mov    %eax,%esi
call   1070 <_mm_sub_epi16@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    $0x8,%esi
call   10e0 <_mm_slli_epi16@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %r13d,%esi
call   10a0 <_mm_mullo_epi16@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1030 <_mm_add_epi16@plt>
mov    %eax,%edi
mov    $0x8,%esi
call   1080 <_mm_srli_epi16@plt>
mov    %eax,%r15d
mov    %r14d,%edi
mov    %r12d,%esi
call   1050 <_mm_unpackhi_epi8@plt>
mov    %eax,%ebx
mov    %eax,%edi
mov    $0x30,%esi
call   10d0 <_mm_slli_epi64@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    $0x10,%esi
call   1090 <_mm_srli_epi64@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   10b0 <_mm_or_si128@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    $0x20,%esi
call   1090 <_mm_srli_epi64@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   10b0 <_mm_or_si128@plt>
mov    %eax,%r14d
mov    0x4(%rsp),%edi
mov    %r12d,%esi
call   1050 <_mm_unpackhi_epi8@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %eax,%esi
call   1070 <_mm_sub_epi16@plt>
mov    %eax,%ebx
mov    %ebp,%edi
mov    $0x8,%esi
call   10e0 <_mm_slli_epi16@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %r14d,%esi
call   10a0 <_mm_mullo_epi16@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1030 <_mm_add_epi16@plt>
mov    %eax,%edi
mov    $0x8,%esi
call   1080 <_mm_srli_epi16@plt>
mov    %r15d,%edi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <_mm_packus_epi16@plt>

LLVM IR (-O0):
define i32 @blend_argb_sse_32(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%12 = load i32, i32* %3
%13 = load i32, i32* %3
%14 = call i32 @_mm_xor_si128(i32 %12, i32 %13)
store i32 %14, i32* %11
%15 = load i32, i32* %3
%16 = load i32, i32* %11
%17 = call i32 @_mm_unpacklo_epi8(i32 %15, i32 %16)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = call i32 @_mm_slli_epi64(i32 %18, i32 48)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = load i32, i32* %7
%22 = call i32 @_mm_srli_epi64(i32 %21, i32 16)
%23 = call i32 @_mm_or_si128(i32 %20, i32 %22)
store i32 %23, i32* %7
%24 = load i32, i32* %7
%25 = load i32, i32* %7
%26 = call i32 @_mm_srli_epi64(i32 %25, i32 32)
%27 = call i32 @_mm_or_si128(i32 %24, i32 %26)
store i32 %27, i32* %7
%28 = load i32, i32* %4
%29 = load i32, i32* %11
%30 = call i32 @_mm_unpacklo_epi8(i32 %28, i32 %29)
store i32 %30, i32* %5
%31 = load i32, i32* %6
%32 = load i32, i32* %5
%33 = call i32 @_mm_sub_epi16(i32 %31, i32 %32)
store i32 %33, i32* %8
%34 = load i32, i32* %5
%35 = call i32 @_mm_slli_epi16(i32 %34, i32 8)
store i32 %35, i32* %5
%36 = load i32, i32* %8
%37 = load i32, i32* %7
%38 = call i32 @_mm_mullo_epi16(i32 %36, i32 %37)
%39 = load i32, i32* %5
%40 = call i32 @_mm_add_epi16(i32 %38, i32 %39)
store i32 %40, i32* %8
%41 = load i32, i32* %8
%42 = call i32 @_mm_srli_epi16(i32 %41, i32 8)
store i32 %42, i32* %9
%43 = load i32, i32* %3
%44 = load i32, i32* %11
%45 = call i32 @_mm_unpackhi_epi8(i32 %43, i32 %44)
store i32 %45, i32* %6
%46 = load i32, i32* %6
%47 = call i32 @_mm_slli_epi64(i32 %46, i32 48)
store i32 %47, i32* %7
%48 = load i32, i32* %7
%49 = load i32, i32* %7
%50 = call i32 @_mm_srli_epi64(i32 %49, i32 16)
%51 = call i32 @_mm_or_si128(i32 %48, i32 %50)
store i32 %51, i32* %7
%52 = load i32, i32* %7
%53 = load i32, i32* %7
%54 = call i32 @_mm_srli_epi64(i32 %53, i32 32)
%55 = call i32 @_mm_or_si128(i32 %52, i32 %54)
store i32 %55, i32* %7
%56 = load i32, i32* %4
%57 = load i32, i32* %11
%58 = call i32 @_mm_unpackhi_epi8(i32 %56, i32 %57)
store i32 %58, i32* %5
%59 = load i32, i32* %6
%60 = load i32, i32* %5
%61 = call i32 @_mm_sub_epi16(i32 %59, i32 %60)
store i32 %61, i32* %8
%62 = load i32, i32* %5
%63 = call i32 @_mm_slli_epi16(i32 %62, i32 8)
store i32 %63, i32* %5
%64 = load i32, i32* %8
%65 = load i32, i32* %7
%66 = call i32 @_mm_mullo_epi16(i32 %64, i32 %65)
%67 = load i32, i32* %5
%68 = call i32 @_mm_add_epi16(i32 %66, i32 %67)
store i32 %68, i32* %8
%69 = load i32, i32* %8
%70 = call i32 @_mm_srli_epi16(i32 %69, i32 8)
store i32 %70, i32* %10
%71 = load i32, i32* %9
%72 = load i32, i32* %10
%73 = call i32 @_mm_packus_epi16(i32 %71, i32 %72)
ret i32 %73
}

LLVM IR (-O2):
define i32 @blend_argb_sse_32(i32 %0, i32 %1) {
%3 = tail call i32 @_mm_xor_si128(i32 %0, i32 %0)
%4 = tail call i32 @_mm_unpacklo_epi8(i32 %0, i32 %3)
%5 = tail call i32 @_mm_slli_epi64(i32 %4, i32 48)
%6 = tail call i32 @_mm_srli_epi64(i32 %5, i32 16)
%7 = tail call i32 @_mm_or_si128(i32 %5, i32 %6)
%8 = tail call i32 @_mm_srli_epi64(i32 %7, i32 32)
%9 = tail call i32 @_mm_or_si128(i32 %7, i32 %8)
%10 = tail call i32 @_mm_unpacklo_epi8(i32 %1, i32 %3)
%11 = tail call i32 @_mm_sub_epi16(i32 %4, i32 %10)
%12 = tail call i32 @_mm_slli_epi16(i32 %10, i32 8)
%13 = tail call i32 @_mm_mullo_epi16(i32 %11, i32 %9)
%14 = tail call i32 @_mm_add_epi16(i32 %13, i32 %12)
%15 = tail call i32 @_mm_srli_epi16(i32 %14, i32 8)
%16 = tail call i32 @_mm_unpackhi_epi8(i32 %0, i32 %3)
%17 = tail call i32 @_mm_slli_epi64(i32 %16, i32 48)
%18 = tail call i32 @_mm_srli_epi64(i32 %17, i32 16)
%19 = tail call i32 @_mm_or_si128(i32 %17, i32 %18)
%20 = tail call i32 @_mm_srli_epi64(i32 %19, i32 32)
%21 = tail call i32 @_mm_or_si128(i32 %19, i32 %20)
%22 = tail call i32 @_mm_unpackhi_epi8(i32 %1, i32 %3)
%23 = tail call i32 @_mm_sub_epi16(i32 %16, i32 %22)
%24 = tail call i32 @_mm_slli_epi16(i32 %22, i32 8)
%25 = tail call i32 @_mm_mullo_epi16(i32 %23, i32 %21)
%26 = tail call i32 @_mm_add_epi16(i32 %25, i32 %24)
%27 = tail call i32 @_mm_srli_epi16(i32 %26, i32 8)
%28 = tail call i32 @_mm_packus_epi16(i32 %15, i32 %27)
ret i32 %28
}