#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, unsigned int *, unsigned int *, unsigned int *,
                         unsigned int *);
int arch_init_amd(unsigned int level) {
  unsigned int eax, ebx, ecx, edx;
  cpuid(0x80000000, &eax, &ebx, &ecx, &edx);
  if (eax < 0x80000007)
    return 0;
  cpuid(0x80000007, &eax, &ebx, &ecx, &edx);
  if (edx & (1 << 8))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<arch_init_amd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    $0x80000000,%edi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
call   1030 <cpuid@plt>
cmpl   $0x80000007,-0xc(%rbp)
jae    114e <arch_init_amd+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    118c <arch_init_amd+0x7c>
mov    $0x80000007,%edi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
call   1030 <cpuid@plt>
mov    -0x18(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
je     1185 <arch_init_amd+0x75>
movl   $0x1,-0x4(%rbp)
jmp    118c <arch_init_amd+0x7c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arch_init_amd>:
sub    $0x18,%rsp
lea    0xc(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    $0x80000000,%edi
call   1030 <cpuid@plt>
xor    %eax,%eax
cmpl   $0x80000007,0xc(%rsp)
80
jb     1166 <arch_init_amd+0x56>
lea    0xc(%rsp),%rsi
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    $0x80000007,%edi
call   1030 <cpuid@plt>
mov    0x8(%rsp),%eax
shr    $0x8,%eax
and    $0x1,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @arch_init_amd(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
%8 = call i32 @cpuid(i32 -2147483648, i32* %4, i32* %5, i32* %6, i32* %7)
%9 = load i32, i32* %4
%10 = icmp ult i32 %9, -2147483641
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 0, i32* %2
br label %19
12: ; preds = %1
%13 = call i32 @cpuid(i32 -2147483641, i32* %4, i32* %5, i32* %6, i32* %7)
%14 = load i32, i32* %7
%15 = and i32 %14, 256
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 1, i32* %2
br label %19
18: ; preds = %12
store i32 0, i32* %2
br label %19
19: ; preds = %18, %17, %11
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
define i32 @arch_init_amd(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = call i32 @cpuid(i32 -2147483648, i32* %2, i32* %3, i32* %4, i32* %5)
%11 = load i32, i32* %2
%12 = icmp ult i32 %11, -2147483641
br i1 %12, label %18, label %13
13: ; preds = %1
%14 = call i32 @cpuid(i32 -2147483641, i32* %2, i32* %3, i32* %4, i32* %5)
%15 = load i32, i32* %5
%16 = lshr i32 %15, 8
%17 = and i32 %16, 1
br label %18
18: ; preds = %13, %1
%19 = phi i32 [ 0, %1 ], [ %17, %13 ]
ret i32 %19
}