#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 */

/* Variables and functions */
unsigned long _pext_u64(unsigned long long, unsigned long const);
unsigned long long test__pexp_cmask_u64(unsigned long long a[4]) {
  const unsigned long mask = 0x00000000100000a4UL;
  unsigned long res;
  res = _pext_u64(a[0], mask);
  res = (res << 8) | _pext_u64(a[1], mask);
  res = (res << 8) | _pext_u64(a[2], mask);
  res = (res << 8) | _pext_u64(a[3], mask);
  return (res);
}


x86 assembly (clang, -O0):
<test__pexp_cmask_u64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x100000a4,-0x10(%rbp)
10
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    $0x100000a4,%esi
call   1030 <_pext_u64@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x100000a4,%esi
call   1030 <_pext_u64@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
or     %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rdi
mov    $0x100000a4,%esi
call   1030 <_pext_u64@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
or     %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rdi
mov    $0x100000a4,%esi
call   1030 <_pext_u64@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
or     %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test__pexp_cmask_u64>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%rdi
mov    $0x100000a4,%esi
call   1030 <_pext_u64@plt>
mov    %rax,%r15
mov    0x8(%r14),%rdi
mov    $0x100000a4,%esi
call   1030 <_pext_u64@plt>
mov    %rax,%r12
shl    $0x10,%r15
shl    $0x8,%r12
or     %r15,%r12
mov    0x10(%r14),%rdi
mov    $0x100000a4,%esi
call   1030 <_pext_u64@plt>
mov    %rax,%rbx
or     %r12,%rbx
shl    $0x8,%rbx
mov    0x18(%r14),%rdi
mov    $0x100000a4,%esi
call   1030 <_pext_u64@plt>
or     %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @test__pexp_cmask_u64(i64* %0) {
%2 = alloca i64*
%3 = alloca i64
%4 = alloca i64
store i64* %0, i64** %2
store i64 268435620, i64* %3
%5 = load i64*, i64** %2
%6 = getelementptr inbounds i64, i64* %5, i64 0
%7 = load i64, i64* %6
%8 = call i64 @_pext_u64(i64 %7, i64 268435620)
store i64 %8, i64* %4
%9 = load i64, i64* %4
%10 = shl i64 %9, 8
%11 = load i64*, i64** %2
%12 = getelementptr inbounds i64, i64* %11, i64 1
%13 = load i64, i64* %12
%14 = call i64 @_pext_u64(i64 %13, i64 268435620)
%15 = or i64 %10, %14
store i64 %15, i64* %4
%16 = load i64, i64* %4
%17 = shl i64 %16, 8
%18 = load i64*, i64** %2
%19 = getelementptr inbounds i64, i64* %18, i64 2
%20 = load i64, i64* %19
%21 = call i64 @_pext_u64(i64 %20, i64 268435620)
%22 = or i64 %17, %21
store i64 %22, i64* %4
%23 = load i64, i64* %4
%24 = shl i64 %23, 8
%25 = load i64*, i64** %2
%26 = getelementptr inbounds i64, i64* %25, i64 3
%27 = load i64, i64* %26
%28 = call i64 @_pext_u64(i64 %27, i64 268435620)
%29 = or i64 %24, %28
store i64 %29, i64* %4
%30 = load i64, i64* %4
ret i64 %30
}

LLVM IR (-O2):
define i64 @test__pexp_cmask_u64(i64* nocapture %0) {
%2 = load i64, i64* %0
%3 = tail call i64 @_pext_u64(i64 %2, i64 268435620)
%4 = getelementptr inbounds i64, i64* %0, i64 1
%5 = load i64, i64* %4
%6 = tail call i64 @_pext_u64(i64 %5, i64 268435620)
%7 = shl i64 %3, 16
%8 = shl i64 %6, 8
%9 = or i64 %8, %7
%10 = getelementptr inbounds i64, i64* %0, i64 2
%11 = load i64, i64* %10
%12 = tail call i64 @_pext_u64(i64 %11, i64 268435620)
%13 = or i64 %9, %12
%14 = shl i64 %13, 8
%15 = getelementptr inbounds i64, i64* %0, i64 3
%16 = load i64, i64* %15
%17 = tail call i64 @_pext_u64(i64 %16, i64 268435620)
%18 = or i64 %14, %17
ret i64 %18
}