#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 have_cpuid();
int have_excpuid();
int /*<<< orphan*/ support_avx();
int /*<<< orphan*/ support_avx2();
int /*<<< orphan*/ support_avx512();
int /*<<< orphan*/ support_avx512_bf16();
int get_cputype(int gettype) {
  int eax, ebx, ecx, edx;
  int extend_family, family;
  int extend_model, model;
  int type, stepping;
  int feature = 0;
  cpuid(1, &eax, &ebx, &ecx, &edx);
  switch (gettype) {
  case 1:
    return ((((eax) >> (20)) & (0xff)));
  case 2:
    return ((((eax) >> (16)) & (0x0f)));
  case 3:
    return ((((eax) >> (12)) & (0x03)));
  case 4:
    return ((((eax) >> (8)) & (0x0f)));
  case 5:
    return ((((eax) >> (4)) & (0x0f)));
  case 6:
    return ((((ebx) >> (24)) & (0x0f)));
  case 7:
    return ((((ebx) >> (16)) & (0x0f)));
  case 8:
    return ((((ebx) >> (8)) & (0x0f)));
  case 9:
    return ((((eax) >> (0)) & (0x0f)));
  case 10:
    return ((((ebx) >> (0)) & (0xff)));
  case 12:
    if (have_cpuid() < 4)
      return 0;
    cpuid(4, &eax, &ebx, &ecx, &edx);
    return ((((eax) >> (14)) & (0xfff)));
  case 13:
    if (have_cpuid() < 4)
      return 0;
    cpuid(4, &eax, &ebx, &ecx, &edx);
    return ((((eax) >> (26)) & (0x3f)));
  case 11:
    if ((edx & (1 << 3)) != 0)
      feature |= (1 << 12);
    if ((edx & (1 << 15)) != 0)
      feature |= (1 << 11);
    if ((edx & (1 << 19)) != 0)
      feature |= (1 << 13);
    if ((edx & (1 << 23)) != 0)
      feature |= (1 << 8);
    if ((edx & (1 << 25)) != 0)
      feature |= (1 << 0);
    if ((edx & (1 << 26)) != 0)
      feature |= (1 << 1);
    if ((edx & (1 << 27)) != 0) {
      if (((((ebx) >> (16)) & (0x0f))) > 0)
        feature |= (1 << 14);
    }
    if ((ecx & (1 << 0)) != 0)
      feature |= (1 << 2);
    if ((ecx & (1 << 9)) != 0)
      feature |= (1 << 3);
    if ((ecx & (1 << 19)) != 0)
      feature |= (1 << 4);
    if ((ecx & (1 << 20)) != 0)
      feature |= (1 << 5);
    if (support_avx())
      feature |= (1 << 18);
    if (support_avx2())
      feature |= (1 << 22);
    if (support_avx512())
      feature |= (1 << 21);
    if (support_avx512_bf16())
      feature |= (1 << 23);
    if ((ecx & (1 << 12)) != 0)
      feature |= (1 << 20);
    if (have_excpuid() >= 0x01) {
      cpuid(0x80000001, &eax, &ebx, &ecx, &edx);
      if ((ecx & (1 << 6)) != 0)
        feature |= (1 << 6);
      if ((ecx & (1 << 7)) != 0)
        feature |= (1 << 15);
      if ((ecx & (1 << 16)) != 0)
        feature |= (1 << 19);
      if ((edx & (1 << 30)) != 0)
        feature |= (1 << 10);
      if ((edx & (1 << 31)) != 0)
        feature |= (1 << 9);
    }
    if (have_excpuid() >= 0x1a) {
      cpuid(0x8000001a, &eax, &ebx, &ecx, &edx);
      if ((eax & (1 << 0)) != 0)
        feature |= (1 << 16);
      if ((eax & (1 << 1)) != 0)
        feature |= (1 << 17);
    }
  }
  return feature;
}


x86 assembly (clang, -O0):
<get_cputype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x0,-0x34(%rbp)
mov    $0x1,%edi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
call   1080 <cpuid@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0xc,%eax
ja     15e5 <get_cputype+0x475>
mov    -0x40(%rbp),%rax
lea    0xe44(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%eax
sar    $0x14,%eax
and    $0xff,%eax
mov    %eax,-0x4(%rbp)
jmp    15eb <get_cputype+0x47b>
mov    -0xc(%rbp),%eax
sar    $0x10,%eax
and    $0xf,%eax
mov    %eax,-0x4(%rbp)
jmp    15eb <get_cputype+0x47b>
mov    -0xc(%rbp),%eax
sar    $0xc,%eax
and    $0x3,%eax
mov    %eax,-0x4(%rbp)
jmp    15eb <get_cputype+0x47b>
mov    -0xc(%rbp),%eax
sar    $0x8,%eax
and    $0xf,%eax
mov    %eax,-0x4(%rbp)
jmp    15eb <get_cputype+0x47b>
mov    -0xc(%rbp),%eax
sar    $0x4,%eax
and    $0xf,%eax
mov    %eax,-0x4(%rbp)
jmp    15eb <get_cputype+0x47b>
mov    -0x10(%rbp),%eax
sar    $0x18,%eax
and    $0xf,%eax
mov    %eax,-0x4(%rbp)
jmp    15eb <get_cputype+0x47b>
mov    -0x10(%rbp),%eax
sar    $0x10,%eax
and    $0xf,%eax
mov    %eax,-0x4(%rbp)
jmp    15eb <get_cputype+0x47b>
mov    -0x10(%rbp),%eax
sar    $0x8,%eax
and    $0xf,%eax
mov    %eax,-0x4(%rbp)
jmp    15eb <get_cputype+0x47b>
mov    -0xc(%rbp),%eax
sar    $0x0,%eax
and    $0xf,%eax
mov    %eax,-0x4(%rbp)
jmp    15eb <get_cputype+0x47b>
mov    -0x10(%rbp),%eax
sar    $0x0,%eax
and    $0xff,%eax
mov    %eax,-0x4(%rbp)
jmp    15eb <get_cputype+0x47b>
mov    $0x0,%al
call   1090 <have_cpuid@plt>
cmp    $0x4,%eax
jge    128f <get_cputype+0x11f>
movl   $0x0,-0x4(%rbp)
jmp    15eb <get_cputype+0x47b>
mov    $0x4,%edi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
call   1080 <cpuid@plt>
mov    -0xc(%rbp),%eax
sar    $0xe,%eax
and    $0xfff,%eax
mov    %eax,-0x4(%rbp)
jmp    15eb <get_cputype+0x47b>
mov    $0x0,%al
call   1090 <have_cpuid@plt>
cmp    $0x4,%eax
jge    12d8 <get_cputype+0x168>
movl   $0x0,-0x4(%rbp)
jmp    15eb <get_cputype+0x47b>
mov    $0x4,%edi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
call   1080 <cpuid@plt>
mov    -0xc(%rbp),%eax
sar    $0x1a,%eax
and    $0x3f,%eax
mov    %eax,-0x4(%rbp)
jmp    15eb <get_cputype+0x47b>
mov    -0x18(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     131d <get_cputype+0x1ad>
mov    -0x34(%rbp),%eax
or     $0x1000,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     1339 <get_cputype+0x1c9>
mov    -0x34(%rbp),%eax
or     $0x800,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%eax
and    $0x80000,%eax
cmp    $0x0,%eax
je     1355 <get_cputype+0x1e5>
mov    -0x34(%rbp),%eax
or     $0x2000,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%eax
and    $0x800000,%eax
cmp    $0x0,%eax
je     1371 <get_cputype+0x201>
mov    -0x34(%rbp),%eax
or     $0x100,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%eax
and    $0x2000000,%eax
cmp    $0x0,%eax
je     138b <get_cputype+0x21b>
mov    -0x34(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%eax
and    $0x4000000,%eax
cmp    $0x0,%eax
je     13a5 <get_cputype+0x235>
mov    -0x34(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%eax
and    $0x8000000,%eax
cmp    $0x0,%eax
je     13d8 <get_cputype+0x268>
mov    -0x10(%rbp),%eax
sar    $0x10,%eax
and    $0xf,%eax
cmp    $0x0,%eax
jle    13d3 <get_cputype+0x263>
mov    -0x34(%rbp),%eax
or     $0x4000,%eax
mov    %eax,-0x34(%rbp)
jmp    13d8 <get_cputype+0x268>
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     13f0 <get_cputype+0x280>
mov    -0x34(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%eax
and    $0x200,%eax
cmp    $0x0,%eax
je     140a <get_cputype+0x29a>
mov    -0x34(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%eax
and    $0x80000,%eax
cmp    $0x0,%eax
je     1424 <get_cputype+0x2b4>
mov    -0x34(%rbp),%eax
or     $0x10,%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%eax
and    $0x100000,%eax
cmp    $0x0,%eax
je     143e <get_cputype+0x2ce>
mov    -0x34(%rbp),%eax
or     $0x20,%eax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1060 <support_avx@plt>
cmp    $0x0,%eax
je     1459 <get_cputype+0x2e9>
mov    -0x34(%rbp),%eax
or     $0x40000,%eax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1070 <support_avx2@plt>
cmp    $0x0,%eax
je     1474 <get_cputype+0x304>
mov    -0x34(%rbp),%eax
or     $0x400000,%eax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1030 <support_avx512@plt>
cmp    $0x0,%eax
je     148f <get_cputype+0x31f>
mov    -0x34(%rbp),%eax
or     $0x200000,%eax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1040 <support_avx512_bf16@plt>
cmp    $0x0,%eax
je     14aa <get_cputype+0x33a>
mov    -0x34(%rbp),%eax
or     $0x800000,%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
je     14c6 <get_cputype+0x356>
mov    -0x34(%rbp),%eax
or     $0x100000,%eax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1050 <have_excpuid@plt>
cmp    $0x1,%eax
jl     157d <get_cputype+0x40d>
mov    $0x80000001,%edi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
call   1080 <cpuid@plt>
mov    -0x14(%rbp),%eax
and    $0x40,%eax
cmp    $0x0,%eax
je     1508 <get_cputype+0x398>
mov    -0x34(%rbp),%eax
or     $0x40,%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1524 <get_cputype+0x3b4>
mov    -0x34(%rbp),%eax
or     $0x8000,%eax
mov    %eax,-0x34(%rbp)
mov    -0x14(%rbp),%eax
and    $0x10000,%eax
cmp    $0x0,%eax
je     1540 <get_cputype+0x3d0>
mov    -0x34(%rbp),%eax
or     $0x80000,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%eax
and    $0x40000000,%eax
cmp    $0x0,%eax
je     155c <get_cputype+0x3ec>
mov    -0x34(%rbp),%eax
or     $0x400,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
je     1578 <get_cputype+0x408>
mov    -0x34(%rbp),%eax
or     $0x200,%eax
mov    %eax,-0x34(%rbp)
jmp    157d <get_cputype+0x40d>
mov    $0x0,%al
call   1050 <have_excpuid@plt>
cmp    $0x1a,%eax
jl     15e0 <get_cputype+0x470>
mov    $0x8000001a,%edi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
lea    -0x18(%rbp),%r8
call   1080 <cpuid@plt>
mov    -0xc(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     15c1 <get_cputype+0x451>
mov    -0x34(%rbp),%eax
or     $0x10000,%eax
mov    %eax,-0x34(%rbp)
mov    -0xc(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     15db <get_cputype+0x46b>
mov    -0x34(%rbp),%eax
or     $0x20000,%eax
mov    %eax,-0x34(%rbp)
jmp    15e0 <get_cputype+0x470>
jmp    15e5 <get_cputype+0x475>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_cputype>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x14(%rsp),%r8
mov    $0x1,%edi
call   1080 <cpuid@plt>
add    $0xffffffff,%ebx
cmp    $0xc,%ebx
ja     11bd <get_cputype+0x4d>
lea    0xe5b(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    0x8(%rsp),%eax
shr    $0x14,%eax
movzbl %al,%ebx
jmp    1424 <get_cputype+0x2b4>
xor    %ebx,%ebx
jmp    1424 <get_cputype+0x2b4>
movzwl 0xa(%rsp),%ebx
jmp    1421 <get_cputype+0x2b1>
mov    0x8(%rsp),%ebx
shr    $0xc,%ebx
and    $0x3,%ebx
jmp    1424 <get_cputype+0x2b4>
mov    0x8(%rsp),%ebx
jmp    1207 <get_cputype+0x97>
mov    0x8(%rsp),%ebx
shr    $0x4,%ebx
jmp    1421 <get_cputype+0x2b1>
movzbl 0xf(%rsp),%ebx
jmp    1421 <get_cputype+0x2b1>
movzwl 0xe(%rsp),%ebx
jmp    1421 <get_cputype+0x2b1>
mov    0xc(%rsp),%ebx
shr    $0x8,%ebx
jmp    1421 <get_cputype+0x2b1>
movzbl 0xc(%rsp),%ebx
jmp    1424 <get_cputype+0x2b4>
mov    0x14(%rsp),%eax
mov    %eax,%ecx
and    $0x8,%ecx
shl    $0x9,%ecx
mov    %eax,%edx
shr    $0x4,%edx
and    $0x800,%edx
or     %ecx,%edx
mov    %eax,%ecx
shr    $0x6,%ecx
and    $0x2000,%ecx
or     %edx,%ecx
mov    %eax,%edx
shr    $0xf,%edx
and    $0x100,%edx
or     %ecx,%edx
mov    %eax,%ecx
shr    $0x19,%ecx
mov    %ecx,%esi
and    $0x1,%esi
or     %edx,%esi
and    $0x2,%ecx
or     %esi,%ecx
test   $0x8000000,%eax
je     1274 <get_cputype+0x104>
lea    0x4000(%rcx),%eax
testb  $0xf,0xe(%rsp)
cmove  %ecx,%eax
mov    %eax,%ecx
mov    0x10(%rsp),%ebx
lea    0x0(,%rbx,4),%eax
and    $0x4,%eax
mov    %ebx,%edx
shr    $0x6,%edx
and    $0x8,%edx
or     %ecx,%edx
shr    $0xf,%ebx
mov    %ebx,%ecx
and    $0x10,%ecx
or     %eax,%ecx
and    $0x20,%ebx
or     %ecx,%ebx
or     %edx,%ebx
xor    %eax,%eax
call   1060 <support_avx@plt>
lea    0x40000(%rbx),%ebp
test   %eax,%eax
cmove  %ebx,%ebp
xor    %eax,%eax
call   1070 <support_avx2@plt>
mov    %ebp,%ebx
or     $0x400000,%ebx
test   %eax,%eax
cmove  %ebp,%ebx
xor    %eax,%eax
call   1030 <support_avx512@plt>
mov    %ebx,%ebp
or     $0x200000,%ebp
test   %eax,%eax
cmove  %ebx,%ebp
xor    %eax,%eax
call   1040 <support_avx512_bf16@plt>
mov    %ebp,%ecx
or     $0x800000,%ecx
test   %eax,%eax
cmove  %ebp,%ecx
mov    0x10(%rsp),%ebx
shl    $0x8,%ebx
and    $0x100000,%ebx
or     %ecx,%ebx
xor    %eax,%eax
call   1050 <have_excpuid@plt>
test   %eax,%eax
jle    1363 <get_cputype+0x1f3>
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x14(%rsp),%r8
mov    $0x80000001,%edi
call   1080 <cpuid@plt>
mov    0x10(%rsp),%eax
mov    %eax,%ecx
and    $0x40,%ecx
or     %ebx,%ecx
mov    %eax,%edx
shl    $0x8,%edx
and    $0x8000,%edx
shl    $0x3,%eax
and    $0x80000,%eax
or     %edx,%eax
mov    0x14(%rsp),%edx
mov    %edx,%esi
shr    $0x14,%esi
and    $0x400,%esi
or     %eax,%esi
or     %ecx,%esi
mov    %esi,%ebx
or     $0x200,%ebx
test   %edx,%edx
cmovns %esi,%ebx
xor    %eax,%eax
call   1050 <have_excpuid@plt>
cmp    $0x1a,%eax
jl     1424 <get_cputype+0x2b4>
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x14(%rsp),%r8
mov    $0x8000001a,%edi
call   1080 <cpuid@plt>
mov    0x8(%rsp),%eax
shl    $0x10,%eax
mov    %eax,%ecx
and    $0x10000,%ecx
or     %ebx,%ecx
and    $0x20000,%eax
or     %ecx,%eax
mov    %eax,%ebx
jmp    1424 <get_cputype+0x2b4>
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <have_cpuid@plt>
cmp    $0x4,%eax
jl     1424 <get_cputype+0x2b4>
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x14(%rsp),%r8
mov    $0x4,%edi
call   1080 <cpuid@plt>
mov    0x8(%rsp),%ebx
shr    $0xe,%ebx
and    $0xfff,%ebx
jmp    1424 <get_cputype+0x2b4>
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <have_cpuid@plt>
cmp    $0x4,%eax
jl     1424 <get_cputype+0x2b4>
lea    0x8(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x14(%rsp),%r8
mov    $0x4,%edi
call   1080 <cpuid@plt>
mov    0x8(%rsp),%ebx
shr    $0x1a,%ebx
jmp    1424 <get_cputype+0x2b4>
mov    0x8(%rsp),%ebx
and    $0xf,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_cputype(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %14
%15 = call i32 @cpuid(i32 1, i32* %4, i32* %5, i32* %6, i32* %7)
%16 = load i32, i32* %3
switch i32 %16, label %249 [
i32 1, label %17
i32 2, label %21
i32 3, label %25
i32 4, label %29
i32 5, label %33
i32 6, label %37
i32 7, label %41
i32 8, label %45
i32 9, label %49
i32 10, label %53
i32 12, label %57
i32 13, label %66
i32 11, label %75
]
17: ; preds = %1
%18 = load i32, i32* %4
%19 = ashr i32 %18, 20
%20 = and i32 %19, 255
store i32 %20, i32* %2
br label %251
21: ; preds = %1
%22 = load i32, i32* %4
%23 = ashr i32 %22, 16
%24 = and i32 %23, 15
store i32 %24, i32* %2
br label %251
25: ; preds = %1
%26 = load i32, i32* %4
%27 = ashr i32 %26, 12
%28 = and i32 %27, 3
store i32 %28, i32* %2
br label %251
29: ; preds = %1
%30 = load i32, i32* %4
%31 = ashr i32 %30, 8
%32 = and i32 %31, 15
store i32 %32, i32* %2
br label %251
33: ; preds = %1
%34 = load i32, i32* %4
%35 = ashr i32 %34, 4
%36 = and i32 %35, 15
store i32 %36, i32* %2
br label %251
37: ; preds = %1
%38 = load i32, i32* %5
%39 = ashr i32 %38, 24
%40 = and i32 %39, 15
store i32 %40, i32* %2
br label %251
41: ; preds = %1
%42 = load i32, i32* %5
%43 = ashr i32 %42, 16
%44 = and i32 %43, 15
store i32 %44, i32* %2
br label %251
45: ; preds = %1
%46 = load i32, i32* %5
%47 = ashr i32 %46, 8
%48 = and i32 %47, 15
store i32 %48, i32* %2
br label %251
49: ; preds = %1
%50 = load i32, i32* %4
%51 = ashr i32 %50, 0
%52 = and i32 %51, 15
store i32 %52, i32* %2
br label %251
53: ; preds = %1
%54 = load i32, i32* %5
%55 = ashr i32 %54, 0
%56 = and i32 %55, 255
store i32 %56, i32* %2
br label %251
57: ; preds = %1
%58 = call i32 (...) @have_cpuid()
%59 = icmp slt i32 %58, 4
br i1 %59, label %60, label %61
60: ; preds = %57
store i32 0, i32* %2
br label %251
61: ; preds = %57
%62 = call i32 @cpuid(i32 4, i32* %4, i32* %5, i32* %6, i32* %7)
%63 = load i32, i32* %4
%64 = ashr i32 %63, 14
%65 = and i32 %64, 4095
store i32 %65, i32* %2
br label %251
66: ; preds = %1
%67 = call i32 (...) @have_cpuid()
%68 = icmp slt i32 %67, 4
br i1 %68, label %69, label %70
69: ; preds = %66
store i32 0, i32* %2
br label %251
70: ; preds = %66
%71 = call i32 @cpuid(i32 4, i32* %4, i32* %5, i32* %6, i32* %7)
%72 = load i32, i32* %4
%73 = ashr i32 %72, 26
%74 = and i32 %73, 63
store i32 %74, i32* %2
br label %251
75: ; preds = %1
%76 = load i32, i32* %7
%77 = and i32 %76, 8
%78 = icmp ne i32 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %75
%80 = load i32, i32* %14
%81 = or i32 %80, 4096
store i32 %81, i32* %14
br label %82
82: ; preds = %79, %75
%83 = load i32, i32* %7
%84 = and i32 %83, 32768
%85 = icmp ne i32 %84, 0
br i1 %85, label %86, label %89
86: ; preds = %82
%87 = load i32, i32* %14
%88 = or i32 %87, 2048
store i32 %88, i32* %14
br label %89
89: ; preds = %86, %82
%90 = load i32, i32* %7
%91 = and i32 %90, 524288
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %96
93: ; preds = %89
%94 = load i32, i32* %14
%95 = or i32 %94, 8192
store i32 %95, i32* %14
br label %96
96: ; preds = %93, %89
%97 = load i32, i32* %7
%98 = and i32 %97, 8388608
%99 = icmp ne i32 %98, 0
br i1 %99, label %100, label %103
100: ; preds = %96
%101 = load i32, i32* %14
%102 = or i32 %101, 256
store i32 %102, i32* %14
br label %103
103: ; preds = %100, %96
%104 = load i32, i32* %7
%105 = and i32 %104, 33554432
%106 = icmp ne i32 %105, 0
br i1 %106, label %107, label %110
107: ; preds = %103
%108 = load i32, i32* %14
%109 = or i32 %108, 1
store i32 %109, i32* %14
br label %110
110: ; preds = %107, %103
%111 = load i32, i32* %7
%112 = and i32 %111, 67108864
%113 = icmp ne i32 %112, 0
br i1 %113, label %114, label %117
114: ; preds = %110
%115 = load i32, i32* %14
%116 = or i32 %115, 2
store i32 %116, i32* %14
br label %117
117: ; preds = %114, %110
%118 = load i32, i32* %7
%119 = and i32 %118, 134217728
%120 = icmp ne i32 %119, 0
br i1 %120, label %121, label %130
121: ; preds = %117
%122 = load i32, i32* %5
%123 = ashr i32 %122, 16
%124 = and i32 %123, 15
%125 = icmp sgt i32 %124, 0
br i1 %125, label %126, label %129
126: ; preds = %121
%127 = load i32, i32* %14
%128 = or i32 %127, 16384
store i32 %128, i32* %14
br label %129
129: ; preds = %126, %121
br label %130
130: ; preds = %129, %117
%131 = load i32, i32* %6
%132 = and i32 %131, 1
%133 = icmp ne i32 %132, 0
br i1 %133, label %134, label %137
134: ; preds = %130
%135 = load i32, i32* %14
%136 = or i32 %135, 4
store i32 %136, i32* %14
br label %137
137: ; preds = %134, %130
%138 = load i32, i32* %6
%139 = and i32 %138, 512
%140 = icmp ne i32 %139, 0
br i1 %140, label %141, label %144
141: ; preds = %137
%142 = load i32, i32* %14
%143 = or i32 %142, 8
store i32 %143, i32* %14
br label %144
144: ; preds = %141, %137
%145 = load i32, i32* %6
%146 = and i32 %145, 524288
%147 = icmp ne i32 %146, 0
br i1 %147, label %148, label %151
148: ; preds = %144
%149 = load i32, i32* %14
%150 = or i32 %149, 16
store i32 %150, i32* %14
br label %151
151: ; preds = %148, %144
%152 = load i32, i32* %6
%153 = and i32 %152, 1048576
%154 = icmp ne i32 %153, 0
br i1 %154, label %155, label %158
155: ; preds = %151
%156 = load i32, i32* %14
%157 = or i32 %156, 32
store i32 %157, i32* %14
br label %158
158: ; preds = %155, %151
%159 = call i32 (...) @support_avx()
%160 = icmp ne i32 %159, 0
br i1 %160, label %161, label %164
161: ; preds = %158
%162 = load i32, i32* %14
%163 = or i32 %162, 262144
store i32 %163, i32* %14
br label %164
164: ; preds = %161, %158
%165 = call i32 (...) @support_avx2()
%166 = icmp ne i32 %165, 0
br i1 %166, label %167, label %170
167: ; preds = %164
%168 = load i32, i32* %14
%169 = or i32 %168, 4194304
store i32 %169, i32* %14
br label %170
170: ; preds = %167, %164
%171 = call i32 (...) @support_avx512()
%172 = icmp ne i32 %171, 0
br i1 %172, label %173, label %176
173: ; preds = %170
%174 = load i32, i32* %14
%175 = or i32 %174, 2097152
store i32 %175, i32* %14
br label %176
176: ; preds = %173, %170
%177 = call i32 (...) @support_avx512_bf16()
%178 = icmp ne i32 %177, 0
br i1 %178, label %179, label %182
179: ; preds = %176
%180 = load i32, i32* %14
%181 = or i32 %180, 8388608
store i32 %181, i32* %14
br label %182
182: ; preds = %179, %176
%183 = load i32, i32* %6
%184 = and i32 %183, 4096
%185 = icmp ne i32 %184, 0
br i1 %185, label %186, label %189
186: ; preds = %182
%187 = load i32, i32* %14
%188 = or i32 %187, 1048576
store i32 %188, i32* %14
br label %189
189: ; preds = %186, %182
%190 = call i32 (...) @have_excpuid()
%191 = icmp sge i32 %190, 1
br i1 %191, label %192, label %229
192: ; preds = %189
%193 = call i32 @cpuid(i32 -2147483647, i32* %4, i32* %5, i32* %6, i32* %7)
%194 = load i32, i32* %6
%195 = and i32 %194, 64
%196 = icmp ne i32 %195, 0
br i1 %196, label %197, label %200
197: ; preds = %192
%198 = load i32, i32* %14
%199 = or i32 %198, 64
store i32 %199, i32* %14
br label %200
200: ; preds = %197, %192
%201 = load i32, i32* %6
%202 = and i32 %201, 128
%203 = icmp ne i32 %202, 0
br i1 %203, label %204, label %207
204: ; preds = %200
%205 = load i32, i32* %14
%206 = or i32 %205, 32768
store i32 %206, i32* %14
br label %207
207: ; preds = %204, %200
%208 = load i32, i32* %6
%209 = and i32 %208, 65536
%210 = icmp ne i32 %209, 0
br i1 %210, label %211, label %214
211: ; preds = %207
%212 = load i32, i32* %14
%213 = or i32 %212, 524288
store i32 %213, i32* %14
br label %214
214: ; preds = %211, %207
%215 = load i32, i32* %7
%216 = and i32 %215, 1073741824
%217 = icmp ne i32 %216, 0
br i1 %217, label %218, label %221
218: ; preds = %214
%219 = load i32, i32* %14
%220 = or i32 %219, 1024
store i32 %220, i32* %14
br label %221
221: ; preds = %218, %214
%222 = load i32, i32* %7
%223 = and i32 %222, -2147483648
%224 = icmp ne i32 %223, 0
br i1 %224, label %225, label %228
225: ; preds = %221
%226 = load i32, i32* %14
%227 = or i32 %226, 512
store i32 %227, i32* %14
br label %228
228: ; preds = %225, %221
br label %229
229: ; preds = %228, %189
%230 = call i32 (...) @have_excpuid()
%231 = icmp sge i32 %230, 26
br i1 %231, label %232, label %248
232: ; preds = %229
%233 = call i32 @cpuid(i32 -2147483622, i32* %4, i32* %5, i32* %6, i32* %7)
%234 = load i32, i32* %4
%235 = and i32 %234, 1
%236 = icmp ne i32 %235, 0
br i1 %236, label %237, label %240
237: ; preds = %232
%238 = load i32, i32* %14
%239 = or i32 %238, 65536
store i32 %239, i32* %14
br label %240
240: ; preds = %237, %232
%241 = load i32, i32* %4
%242 = and i32 %241, 2
%243 = icmp ne i32 %242, 0
br i1 %243, label %244, label %247
244: ; preds = %240
%245 = load i32, i32* %14
%246 = or i32 %245, 131072
store i32 %246, i32* %14
br label %247
247: ; preds = %244, %240
br label %248
248: ; preds = %247, %229
br label %249
249: ; preds = %248, %1
%250 = load i32, i32* %14
store i32 %250, i32* %2
br label %251
251: ; preds = %249, %70, %69, %61, %60, %53, %49, %45, %41, %37, %33, %29, %25, %21, %17
%252 = load i32, i32* %2
ret i32 %252
}

LLVM IR (-O2):
define i32 @get_cputype(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 1, i32* %2, i32* %3, i32* %4, i32* %5)
switch i32 %0, label %156 [
i32 1, label %11
i32 2, label %15
i32 3, label %19
i32 4, label %23
i32 5, label %27
i32 6, label %31
i32 7, label %35
i32 8, label %39
i32 9, label %43
i32 10, label %46
i32 12, label %49
i32 13, label %57
i32 11, label %64
]
11: ; preds = %1
%12 = load i32, i32* %2
%13 = lshr i32 %12, 20
%14 = and i32 %13, 255
br label %156
15: ; preds = %1
%16 = load i32, i32* %2
%17 = lshr i32 %16, 16
%18 = and i32 %17, 15
br label %156
19: ; preds = %1
%20 = load i32, i32* %2
%21 = lshr i32 %20, 12
%22 = and i32 %21, 3
br label %156
23: ; preds = %1
%24 = load i32, i32* %2
%25 = lshr i32 %24, 8
%26 = and i32 %25, 15
br label %156
27: ; preds = %1
%28 = load i32, i32* %2
%29 = lshr i32 %28, 4
%30 = and i32 %29, 15
br label %156
31: ; preds = %1
%32 = load i32, i32* %3
%33 = lshr i32 %32, 24
%34 = and i32 %33, 15
br label %156
35: ; preds = %1
%36 = load i32, i32* %3
%37 = lshr i32 %36, 16
%38 = and i32 %37, 15
br label %156
39: ; preds = %1
%40 = load i32, i32* %3
%41 = lshr i32 %40, 8
%42 = and i32 %41, 15
br label %156
43: ; preds = %1
%44 = load i32, i32* %2
%45 = and i32 %44, 15
br label %156
46: ; preds = %1
%47 = load i32, i32* %3
%48 = and i32 %47, 255
br label %156
49: ; preds = %1
%50 = call i32 (...) @have_cpuid()
%51 = icmp slt i32 %50, 4
br i1 %51, label %156, label %52
52: ; preds = %49
%53 = call i32 @cpuid(i32 4, i32* %2, i32* %3, i32* %4, i32* %5)
%54 = load i32, i32* %2
%55 = lshr i32 %54, 14
%56 = and i32 %55, 4095
br label %156
57: ; preds = %1
%58 = call i32 (...) @have_cpuid()
%59 = icmp slt i32 %58, 4
br i1 %59, label %156, label %60
60: ; preds = %57
%61 = call i32 @cpuid(i32 4, i32* %2, i32* %3, i32* %4, i32* %5)
%62 = load i32, i32* %2
%63 = lshr i32 %62, 26
br label %156
64: ; preds = %1
%65 = load i32, i32* %5
%66 = shl i32 %65, 9
%67 = and i32 %66, 4096
%68 = lshr i32 %65, 4
%69 = and i32 %68, 2048
%70 = or i32 %69, %67
%71 = lshr i32 %65, 6
%72 = and i32 %71, 8192
%73 = or i32 %70, %72
%74 = lshr i32 %65, 15
%75 = and i32 %74, 256
%76 = or i32 %73, %75
%77 = lshr i32 %65, 25
%78 = and i32 %77, 1
%79 = or i32 %76, %78
%80 = and i32 %77, 2
%81 = or i32 %79, %80
%82 = and i32 %65, 134217728
%83 = icmp eq i32 %82, 0
br i1 %83, label %90, label %84
84: ; preds = %64
%85 = load i32, i32* %3
%86 = and i32 %85, 983040
%87 = icmp eq i32 %86, 0
%88 = or i32 %81, 16384
%89 = select i1 %87, i32 %81, i32 %88
br label %90
90: ; preds = %84, %64
%91 = phi i32 [ %81, %64 ], [ %89, %84 ]
%92 = load i32, i32* %4
%93 = shl i32 %92, 2
%94 = and i32 %93, 4
%95 = or i32 %94, %91
%96 = lshr i32 %92, 6
%97 = and i32 %96, 8
%98 = or i32 %95, %97
%99 = lshr i32 %92, 15
%100 = and i32 %99, 16
%101 = or i32 %98, %100
%102 = and i32 %99, 32
%103 = or i32 %101, %102
%104 = call i32 (...) @support_avx()
%105 = icmp eq i32 %104, 0
%106 = or i32 %103, 262144
%107 = select i1 %105, i32 %103, i32 %106
%108 = call i32 (...) @support_avx2()
%109 = icmp eq i32 %108, 0
%110 = or i32 %107, 4194304
%111 = select i1 %109, i32 %107, i32 %110
%112 = call i32 (...) @support_avx512()
%113 = icmp eq i32 %112, 0
%114 = or i32 %111, 2097152
%115 = select i1 %113, i32 %111, i32 %114
%116 = call i32 (...) @support_avx512_bf16()
%117 = icmp eq i32 %116, 0
%118 = or i32 %115, 8388608
%119 = select i1 %117, i32 %115, i32 %118
%120 = load i32, i32* %4
%121 = shl i32 %120, 8
%122 = and i32 %121, 1048576
%123 = or i32 %119, %122
%124 = call i32 (...) @have_excpuid()
%125 = icmp sgt i32 %124, 0
br i1 %125, label %126, label %144
126: ; preds = %90
%127 = call i32 @cpuid(i32 -2147483647, i32* %2, i32* %3, i32* %4, i32* %5)
%128 = load i32, i32* %4
%129 = and i32 %128, 64
%130 = or i32 %129, %123
%131 = shl i32 %128, 8
%132 = and i32 %131, 32768
%133 = or i32 %130, %132
%134 = shl i32 %128, 3
%135 = and i32 %134, 524288
%136 = or i32 %133, %135
%137 = load i32, i32* %5
%138 = lshr i32 %137, 20
%139 = and i32 %138, 1024
%140 = or i32 %136, %139
%141 = icmp sgt i32 %137, -1
%142 = or i32 %140, 512
%143 = select i1 %141, i32 %140, i32 %142
br label %144
144: ; preds = %126, %90
%145 = phi i32 [ %123, %90 ], [ %143, %126 ]
%146 = call i32 (...) @have_excpuid()
%147 = icmp sgt i32 %146, 25
br i1 %147, label %148, label %156
148: ; preds = %144
%149 = call i32 @cpuid(i32 -2147483622, i32* %2, i32* %3, i32* %4, i32* %5)
%150 = load i32, i32* %2
%151 = shl i32 %150, 16
%152 = and i32 %151, 65536
%153 = or i32 %152, %145
%154 = and i32 %151, 131072
%155 = or i32 %153, %154
br label %156
156: ; preds = %148, %1, %144, %57, %49, %60, %52, %46, %43, %39, %35, %31, %27, %23, %19, %15, %11
%157 = phi i32 [ %63, %60 ], [ %56, %52 ], [ %48, %46 ], [ %45, %43 ], [ %42, %39 ], [ %38, %35 ], [ %34, %31 ], [ %30, %27 ], [ %26, %23 ], [ %22, %19 ], [ %18, %15 ], [ %14, %11 ], [ 0, %49 ], [ 0, %57 ], [ 0, %1 ], [ %145, %144 ], [ %155, %148 ]
ret i32 %157
}