#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_srai_epi32(int /*<<< orphan*/ const, int);
int /*<<< orphan*/ _mm_sub_epi32(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_unpackhi_epi32(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_unpacklo_epi32(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_xor_si128(int /*<<< orphan*/ const, int /*<<< orphan*/);
void abs_extend_64bit_sse2(const __m128i in, __m128i *const out,
                           __m128i *const sign) {
  sign[0] = _mm_srai_epi32(in, 31);
  out[0] = _mm_xor_si128(in, sign[0]);
  out[0] = _mm_sub_epi32(out[0], sign[0]);
  sign[1] = _mm_unpackhi_epi32(sign[0], sign[0]);
  sign[0] = _mm_unpacklo_epi32(sign[0], sign[0]);
  out[1] = _mm_unpackhi_epi32(out[0], out[0]);
  out[0] = _mm_unpacklo_epi32(out[0], out[0]);
}


x86 assembly (clang, -O0):
<abs_extend_64bit_sse2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x1f,%esi
call   1050 <_mm_srai_epi32@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1040 <_mm_sub_epi32@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1070 <_mm_unpackhi_epi32@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1030 <_mm_unpacklo_epi32@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
call   1070 <_mm_unpackhi_epi32@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
call   1030 <_mm_unpacklo_epi32@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<abs_extend_64bit_sse2>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    $0x1f,%esi
call   1050 <_mm_srai_epi32@plt>
mov    %eax,(%rbx)
mov    %ebp,%edi
mov    %eax,%esi
call   1060 <_mm_xor_si128@plt>
mov    %eax,(%r14)
mov    (%rbx),%esi
mov    %eax,%edi
call   1040 <_mm_sub_epi32@plt>
mov    %eax,(%r14)
mov    (%rbx),%edi
mov    %edi,%esi
call   1070 <_mm_unpackhi_epi32@plt>
mov    %eax,0x4(%rbx)
mov    (%rbx),%edi
mov    %edi,%esi
call   1030 <_mm_unpacklo_epi32@plt>
mov    %eax,(%rbx)
mov    (%r14),%edi
mov    %edi,%esi
call   1070 <_mm_unpackhi_epi32@plt>
mov    %eax,0x4(%r14)
mov    (%r14),%edi
mov    %edi,%esi
call   1030 <_mm_unpacklo_epi32@plt>
mov    %eax,(%r14)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @abs_extend_64bit_sse2(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%7 = load i32, i32* %4
%8 = call i32 @_mm_srai_epi32(i32 %7, i32 31)
%9 = load i32*, i32** %6
%10 = getelementptr inbounds i32, i32* %9, i64 0
store i32 %8, i32* %10
%11 = load i32, i32* %4
%12 = load i32*, i32** %6
%13 = getelementptr inbounds i32, i32* %12, i64 0
%14 = load i32, i32* %13
%15 = call i32 @_mm_xor_si128(i32 %11, i32 %14)
%16 = load i32*, i32** %5
%17 = getelementptr inbounds i32, i32* %16, i64 0
store i32 %15, i32* %17
%18 = load i32*, i32** %5
%19 = getelementptr inbounds i32, i32* %18, i64 0
%20 = load i32, i32* %19
%21 = load i32*, i32** %6
%22 = getelementptr inbounds i32, i32* %21, i64 0
%23 = load i32, i32* %22
%24 = call i32 @_mm_sub_epi32(i32 %20, i32 %23)
%25 = load i32*, i32** %5
%26 = getelementptr inbounds i32, i32* %25, i64 0
store i32 %24, i32* %26
%27 = load i32*, i32** %6
%28 = getelementptr inbounds i32, i32* %27, i64 0
%29 = load i32, i32* %28
%30 = load i32*, i32** %6
%31 = getelementptr inbounds i32, i32* %30, i64 0
%32 = load i32, i32* %31
%33 = call i32 @_mm_unpackhi_epi32(i32 %29, i32 %32)
%34 = load i32*, i32** %6
%35 = getelementptr inbounds i32, i32* %34, i64 1
store i32 %33, i32* %35
%36 = load i32*, i32** %6
%37 = getelementptr inbounds i32, i32* %36, i64 0
%38 = load i32, i32* %37
%39 = load i32*, i32** %6
%40 = getelementptr inbounds i32, i32* %39, i64 0
%41 = load i32, i32* %40
%42 = call i32 @_mm_unpacklo_epi32(i32 %38, i32 %41)
%43 = load i32*, i32** %6
%44 = getelementptr inbounds i32, i32* %43, i64 0
store i32 %42, i32* %44
%45 = load i32*, i32** %5
%46 = getelementptr inbounds i32, i32* %45, i64 0
%47 = load i32, i32* %46
%48 = load i32*, i32** %5
%49 = getelementptr inbounds i32, i32* %48, i64 0
%50 = load i32, i32* %49
%51 = call i32 @_mm_unpackhi_epi32(i32 %47, i32 %50)
%52 = load i32*, i32** %5
%53 = getelementptr inbounds i32, i32* %52, i64 1
store i32 %51, i32* %53
%54 = load i32*, i32** %5
%55 = getelementptr inbounds i32, i32* %54, i64 0
%56 = load i32, i32* %55
%57 = load i32*, i32** %5
%58 = getelementptr inbounds i32, i32* %57, i64 0
%59 = load i32, i32* %58
%60 = call i32 @_mm_unpacklo_epi32(i32 %56, i32 %59)
%61 = load i32*, i32** %5
%62 = getelementptr inbounds i32, i32* %61, i64 0
store i32 %60, i32* %62
ret void
}

LLVM IR (-O2):
define void @abs_extend_64bit_sse2(i32 %0, i32* nocapture %1, i32* nocapture %2) {
%4 = tail call i32 @_mm_srai_epi32(i32 %0, i32 31)
store i32 %4, i32* %2
%5 = tail call i32 @_mm_xor_si128(i32 %0, i32 %4)
store i32 %5, i32* %1
%6 = load i32, i32* %2
%7 = tail call i32 @_mm_sub_epi32(i32 %5, i32 %6)
store i32 %7, i32* %1
%8 = load i32, i32* %2
%9 = tail call i32 @_mm_unpackhi_epi32(i32 %8, i32 %8)
%10 = getelementptr inbounds i32, i32* %2, i64 1
store i32 %9, i32* %10
%11 = load i32, i32* %2
%12 = tail call i32 @_mm_unpacklo_epi32(i32 %11, i32 %11)
store i32 %12, i32* %2
%13 = load i32, i32* %1
%14 = tail call i32 @_mm_unpackhi_epi32(i32 %13, i32 %13)
%15 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %14, i32* %15
%16 = load i32, i32* %1
%17 = tail call i32 @_mm_unpacklo_epi32(i32 %16, i32 %16)
store i32 %17, i32* %1
ret void
}