#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ cpuid(int, int *, int *, int *, int *);
void cryptonite_aesni_initialize_hw(void (*init_table)(int, int)) {
  static int inited = 0;
  if (inited == 0) {
    uint32_t eax, ebx, ecx, edx;
    int aesni, pclmul;
    inited = 1;
    cpuid(1, &eax, &ebx, &ecx, &edx);
    aesni = (ecx & 0x02000000);
    pclmul = (ecx & 0x00000001);
    init_table(aesni, pclmul);
  }
}


x86 assembly (clang, -O0):
<cryptonite_aesni_initialize_hw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpl   $0x0,0x2f09(%rip)
jne    116d <cryptonite_aesni_initialize_hw+0x5d>
movl   $0x1,0x2ef9(%rip)
mov    $0x1,%edi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
call   1030 <cpuid@plt>
mov    -0x14(%rbp),%eax
and    $0x2000000,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   *%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cryptonite_aesni_initialize_hw>:
push   %rbx
sub    $0x10,%rsp
cmpb   $0x0,0x2f10(%rip)
jne    1154 <cryptonite_aesni_initialize_hw+0x44>
mov    %rdi,%rbx
movb   $0x1,0x2f04(%rip)
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
lea    0x4(%rsp),%r8
mov    $0x1,%edi
call   1030 <cpuid@plt>
mov    (%rsp),%esi
mov    %esi,%edi
and    $0x2000000,%edi
and    $0x1,%esi
call   *%rbx
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@cryptonite_aesni_initialize_hw.inited = internal global i32 0
define void @cryptonite_aesni_initialize_hw(void (i32, i32)* %0) {
%2 = alloca void (i32, i32)*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store void (i32, i32)* %0, void (i32, i32)** %2
%9 = load i32, i32* @cryptonite_aesni_initialize_hw.inited
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %1
store i32 1, i32* @cryptonite_aesni_initialize_hw.inited
%12 = call i32 @cpuid(i32 1, i32* %3, i32* %4, i32* %5, i32* %6)
%13 = load i32, i32* %5
%14 = and i32 %13, 33554432
store i32 %14, i32* %7
%15 = load i32, i32* %5
%16 = and i32 %15, 1
store i32 %16, i32* %8
%17 = load void (i32, i32)*, void (i32, i32)** %2
%18 = load i32, i32* %7
%19 = load i32, i32* %8
br label %20
20: ; preds = %11, %1
ret void
}

LLVM IR (-O2):
@cryptonite_aesni_initialize_hw.inited = internal unnamed_addr global i1 false
define void @cryptonite_aesni_initialize_hw(void (i32, i32)* nocapture %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = load i1, i1* @cryptonite_aesni_initialize_hw.inited
br i1 %6, label %16, label %7
7: ; preds = %1
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
store i1 true, i1* @cryptonite_aesni_initialize_hw.inited
%12 = call i32 @cpuid(i32 1, i32* %2, i32* %3, i32* %4, i32* %5)
%13 = load i32, i32* %4
%14 = and i32 %13, 33554432
%15 = and i32 %13, 1
br label %16
16: ; preds = %7, %1
ret void
}