#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 */
int /*<<< orphan*/ __cpuid(int, int, int, int, int);
int /*<<< orphan*/ __cpuid_count(int, int /*<<< orphan*/, int, int, int, int);
int bit_AVX;
int bit_AVX2;
int bit_BMI;
int bit_BMI2;
int bit_F16C;
int bit_FMA;
int bit_MMX;
int bit_SSE;
int bit_SSE2;
int bit_SSE3;
int bit_SSE4_1;
int bit_SSE4_2;
int bit_SSSE3;
int get_cpu_features(void) {
  int a, b, c, d, _tmp;
  __cpuid(1, a, b, c, d);
  c &= bit_SSE3 | bit_SSSE3 | bit_FMA | bit_SSE4_1 | bit_SSE4_2 | bit_AVX |
       bit_F16C;
  d &= bit_SSE | bit_SSE2 | bit_MMX;
  _tmp = c | d;
  __cpuid_count(7, 0, a, b, c, d);
  b &= bit_BMI | bit_AVX2 | bit_BMI2;
  return _tmp | b;
}


x86 assembly (clang, -O0):
<get_cpu_features>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    $0x1,%edi
call   1030 <__cpuid@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%eax
mov    0x2e49(%rip),%rcx
or     (%rcx),%eax
mov    0x2e68(%rip),%rcx
or     (%rcx),%eax
mov    0x2e7f(%rip),%rcx
or     (%rcx),%eax
mov    0x2e36(%rip),%rcx
or     (%rcx),%eax
mov    0x2e55(%rip),%rcx
or     (%rcx),%eax
mov    0x2e34(%rip),%rcx
or     (%rcx),%eax
and    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e05(%rip),%rax
mov    (%rax),%eax
mov    0x2e24(%rip),%rcx
or     (%rcx),%eax
mov    0x2e3b(%rip),%rcx
or     (%rcx),%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    -0x10(%rbp),%r9d
mov    $0x7,%edi
xor    %esi,%esi
call   1040 <__cpuid_count@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
mov    0x2e10(%rip),%rcx
or     (%rcx),%eax
mov    0x2def(%rip),%rcx
or     (%rcx),%eax
and    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
or     -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_cpu_features>:
push   %rax
mov    $0x1,%edi
call   1030 <__cpuid@plt>
mov    $0x7,%edi
xor    %esi,%esi
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1040 <__cpuid_count@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@bit_SSE3 = global i32 0
@bit_SSSE3 = global i32 0
@bit_FMA = global i32 0
@bit_SSE4_1 = global i32 0
@bit_SSE4_2 = global i32 0
@bit_AVX = global i32 0
@bit_F16C = global i32 0
@bit_SSE = global i32 0
@bit_SSE2 = global i32 0
@bit_MMX = global i32 0
@bit_BMI = global i32 0
@bit_AVX2 = global i32 0
@bit_BMI2 = global i32 0
define i32 @get_cpu_features() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call i32 @__cpuid(i32 1, i32 %6, i32 %7, i32 %8, i32 %9)
%11 = load i32, i32* @bit_SSE3
%12 = load i32, i32* @bit_SSSE3
%13 = or i32 %11, %12
%14 = load i32, i32* @bit_FMA
%15 = or i32 %13, %14
%16 = load i32, i32* @bit_SSE4_1
%17 = or i32 %15, %16
%18 = load i32, i32* @bit_SSE4_2
%19 = or i32 %17, %18
%20 = load i32, i32* @bit_AVX
%21 = or i32 %19, %20
%22 = load i32, i32* @bit_F16C
%23 = or i32 %21, %22
%24 = load i32, i32* %3
%25 = and i32 %24, %23
store i32 %25, i32* %3
%26 = load i32, i32* @bit_SSE
%27 = load i32, i32* @bit_SSE2
%28 = or i32 %26, %27
%29 = load i32, i32* @bit_MMX
%30 = or i32 %28, %29
%31 = load i32, i32* %4
%32 = and i32 %31, %30
store i32 %32, i32* %4
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = or i32 %33, %34
store i32 %35, i32* %5
%36 = load i32, i32* %1
%37 = load i32, i32* %2
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = call i32 @__cpuid_count(i32 7, i32 0, i32 %36, i32 %37, i32 %38, i32 %39)
%41 = load i32, i32* @bit_BMI
%42 = load i32, i32* @bit_AVX2
%43 = or i32 %41, %42
%44 = load i32, i32* @bit_BMI2
%45 = or i32 %43, %44
%46 = load i32, i32* %2
%47 = and i32 %46, %45
store i32 %47, i32* %2
%48 = load i32, i32* %5
%49 = load i32, i32* %2
%50 = or i32 %48, %49
ret i32 %50
}

LLVM IR (-O2):
@bit_SSE3 = global i32 0
@bit_SSSE3 = global i32 0
@bit_FMA = global i32 0
@bit_SSE4_1 = global i32 0
@bit_SSE4_2 = global i32 0
@bit_AVX = global i32 0
@bit_F16C = global i32 0
@bit_SSE = global i32 0
@bit_SSE2 = global i32 0
@bit_MMX = global i32 0
@bit_BMI = global i32 0
@bit_AVX2 = global i32 0
@bit_BMI2 = global i32 0
define i32 @get_cpu_features() {
%1 = tail call i32 @__cpuid(i32 1, i32 undef, i32 undef, i32 undef, i32 undef)
%2 = tail call i32 @__cpuid_count(i32 7, i32 0, i32 undef, i32 undef, i32 0, i32 0)
ret i32 0
}