#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(unsigned int *, int);
scalar_t__ memcmp(unsigned char *, char *, int);
int check_for_aes_instructions() {
  unsigned int cpuid_results[4];
  int yes = 1, no = 0;
  __cpuid(cpuid_results, 0);
  if (cpuid_results[0] < 1)
    return no;
  if ((memcmp((unsigned char *)&cpuid_results[1], "Genu", 4) != 0) ||
      (memcmp((unsigned char *)&cpuid_results[3], "ineI", 4) != 0) ||
      (memcmp((unsigned char *)&cpuid_results[2], "ntel", 4) != 0))
    return no;
  __cpuid(cpuid_results, 1);
  if (cpuid_results[2] & (1 << 25))
    return yes;
  return no;
}


x86 assembly (clang, -O0):
<check_for_aes_instructions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x1,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1040 <__cpuid@plt>
cmpl   $0x1,-0x20(%rbp)
jae    1156 <check_for_aes_instructions+0x36>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11fa <check_for_aes_instructions+0xda>
lea    -0x20(%rbp),%rdi
add    $0x4,%rdi
lea    0xe9b(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    11bf <check_for_aes_instructions+0x9f>
lea    -0x20(%rbp),%rdi
add    $0xc,%rdi
lea    0xe7d(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
jne    11bf <check_for_aes_instructions+0x9f>
lea    -0x20(%rbp),%rdi
add    $0x8,%rdi
lea    0xe5f(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
je     11ca <check_for_aes_instructions+0xaa>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11fa <check_for_aes_instructions+0xda>
lea    -0x20(%rbp),%rdi
mov    $0x1,%esi
call   1040 <__cpuid@plt>
mov    -0x18(%rbp),%eax
and    $0x2000000,%eax
cmp    $0x0,%eax
je     11f4 <check_for_aes_instructions+0xd4>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11fa <check_for_aes_instructions+0xda>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_for_aes_instructions>:
push   %rbx
sub    $0x10,%rsp
mov    %rsp,%rdi
xor    %ebx,%ebx
xor    %esi,%esi
call   1040 <__cpuid@plt>
cmpl   $0x0,(%rsp)
je     119f <check_for_aes_instructions+0x7f>
lea    0x4(%rsp),%rdi
lea    0xebd(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
jne    119f <check_for_aes_instructions+0x7f>
lea    0xc(%rsp),%rdi
lea    0xea7(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
jne    119f <check_for_aes_instructions+0x7f>
lea    0x8(%rsp),%rdi
lea    0xe91(%rip),%rsi
mov    $0x4,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
jne    119f <check_for_aes_instructions+0x7f>
mov    %rsp,%rdi
mov    $0x1,%esi
call   1040 <__cpuid@plt>
mov    0x8(%rsp),%ebx
shr    $0x19,%ebx
and    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"Genu\00"
@.str.1 = [5 x i8] c"ineI\00"
@.str.2 = [5 x i8] c"ntel\00"
define i32 @check_for_aes_instructions() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 1, i32* %3
store i32 0, i32* %4
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%6 = call i32 @__cpuid(i32* %5, i32 0)
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%8 = load i32, i32* %7
%9 = icmp ult i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = load i32, i32* %4
store i32 %11, i32* %1
br label %40
12: ; preds = %0
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%14 = bitcast i32* %13 to i8*
%15 = call i64 @memcmp(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%16 = icmp ne i64 %15, 0
br i1 %16, label %27, label %17
17: ; preds = %12
%18 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%19 = bitcast i32* %18 to i8*
%20 = call i64 @memcmp(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%21 = icmp ne i64 %20, 0
br i1 %21, label %27, label %22
22: ; preds = %17
%23 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%24 = bitcast i32* %23 to i8*
%25 = call i64 @memcmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %22, %17, %12
%28 = load i32, i32* %4
store i32 %28, i32* %1
br label %40
29: ; preds = %22
%30 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%31 = call i32 @__cpuid(i32* %30, i32 1)
%32 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%33 = load i32, i32* %32
%34 = and i32 %33, 33554432
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %29
%37 = load i32, i32* %3
store i32 %37, i32* %1
br label %40
38: ; preds = %29
%39 = load i32, i32* %4
store i32 %39, i32* %1
br label %40
40: ; preds = %38, %36, %27, %10
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@.str = [5 x i8] c"Genu\00"
@.str.1 = [5 x i8] c"ineI\00"
@.str.2 = [5 x i8] c"ntel\00"
define i32 @check_for_aes_instructions() {
%1 = alloca [4 x i32]
%2 = bitcast [4 x i32]* %1 to i8*
%3 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%4 = call i32 @__cpuid(i32* %3, i32 0)
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %27, label %7
7: ; preds = %0
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%9 = bitcast i32* %8 to i8*
%10 = call i64 @memcmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %7
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%14 = bitcast i32* %13 to i8*
%15 = call i64 @memcmp(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %27
17: ; preds = %12
%18 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%19 = bitcast i32* %18 to i8*
%20 = call i64 @memcmp(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = call i32 @__cpuid(i32* %3, i32 1)
%24 = load i32, i32* %18
%25 = lshr i32 %24, 25
%26 = and i32 %25, 1
br label %27
27: ; preds = %22, %7, %12, %17, %0
%28 = phi i32 [ 0, %0 ], [ 0, %17 ], [ 0, %12 ], [ 0, %7 ], [ %26, %22 ]
ret i32 %28
}