#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 */
scalar_t__ __get_cpuid(int, unsigned int *, unsigned int *, unsigned int *,
                       unsigned int *);
unsigned init_caps(void) {
  unsigned int caps = 0;
  unsigned int eax, ebx, ecx, edx;
  if (__get_cpuid(1, &eax, &ebx, &ecx, &edx)) {
    if (edx & (1 << 26)) {
      caps |= 0x00000001;
    }
    if (ecx & (1 << 19)) {
      caps |= 0x00000002;
    }
  }
  if (__get_cpuid(7, &eax, &ebx, &ecx, &edx)) {
    if (ebx & (1 << 5)) {
      caps |= 0x00000004;
    }
  }
  return caps;
}


x86 assembly (clang, -O0):
<init_caps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1030 <__get_cpuid@plt>
cmp    $0x0,%rax
je     117c <init_caps+0x6c>
mov    -0x14(%rbp),%eax
and    $0x4000000,%eax
cmp    $0x0,%eax
je     115d <init_caps+0x4d>
mov    -0x4(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%eax
and    $0x80000,%eax
cmp    $0x0,%eax
je     1177 <init_caps+0x67>
mov    -0x4(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    117c <init_caps+0x6c>
mov    $0x7,%edi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1030 <__get_cpuid@plt>
cmp    $0x0,%rax
je     11bd <init_caps+0xad>
mov    -0xc(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
je     11b8 <init_caps+0xa8>
mov    -0x4(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x4(%rbp)
jmp    11bd <init_caps+0xad>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_caps>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    $0x1,%edi
call   1030 <__get_cpuid@plt>
xor    %ebx,%ebx
mov    $0x0,%ebp
test   %rax,%rax
je     1156 <init_caps+0x46>
mov    0x8(%rsp),%eax
shr    $0x1a,%eax
and    $0x1,%eax
mov    0xc(%rsp),%ebp
shr    $0x12,%ebp
and    $0x2,%ebp
or     %eax,%ebp
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    $0x7,%edi
call   1030 <__get_cpuid@plt>
mov    0x10(%rsp),%ecx
shr    $0x3,%ecx
and    $0x4,%ecx
test   %rax,%rax
cmove  %ebx,%ecx
or     %ebp,%ecx
mov    %ecx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @init_caps() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i64 @__get_cpuid(i32 1, i32* %2, i32* %3, i32* %4, i32* %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %23
8: ; preds = %0
%9 = load i32, i32* %5
%10 = and i32 %9, 67108864
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* %1
%14 = or i32 %13, 1
store i32 %14, i32* %1
br label %15
15: ; preds = %12, %8
%16 = load i32, i32* %4
%17 = and i32 %16, 524288
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* %1
%21 = or i32 %20, 2
store i32 %21, i32* %1
br label %22
22: ; preds = %19, %15
br label %23
23: ; preds = %22, %0
%24 = call i64 @__get_cpuid(i32 7, i32* %2, i32* %3, i32* %4, i32* %5)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %34
26: ; preds = %23
%27 = load i32, i32* %3
%28 = and i32 %27, 32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i32, i32* %1
%32 = or i32 %31, 4
store i32 %32, i32* %1
br label %33
33: ; preds = %30, %26
br label %34
34: ; preds = %33, %23
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
define i32 @init_caps() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i64 @__get_cpuid(i32 1, i32* %1, i32* %2, i32* %3, i32* %4)
%10 = icmp eq i64 %9, 0
br i1 %10, label %19, label %11
11: ; preds = %0
%12 = load i32, i32* %4
%13 = lshr i32 %12, 26
%14 = and i32 %13, 1
%15 = load i32, i32* %3
%16 = lshr i32 %15, 18
%17 = and i32 %16, 2
%18 = or i32 %17, %14
br label %19
19: ; preds = %11, %0
%20 = phi i32 [ 0, %0 ], [ %18, %11 ]
%21 = call i64 @__get_cpuid(i32 7, i32* %1, i32* %2, i32* %3, i32* %4)
%22 = icmp eq i64 %21, 0
%23 = load i32, i32* %2
%24 = lshr i32 %23, 3
%25 = and i32 %24, 4
%26 = select i1 %22, i32 0, i32 %25
%27 = or i32 %20, %26
ret i32 %27
}