#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, unsigned int);
int /*<<< orphan*/ stderr;
unsigned int x86_cpuid(unsigned int a, unsigned int reg_num) {
  if (reg_num > 3) {
    fprintf(stderr, "not implemented x86_cpuid reg %x\n", reg_num);
    exit(EXIT_FAILURE);
  }
  if (a == 0) {
    switch (reg_num) {
    case 0:
      return 0xa;
    case 1:
      return 0x756E6547;
    case 2:
      return 0x6C65746E;
    case 3:
      return 0x49656E69;
    }
  } else if (a == 1) {
    switch (reg_num) {
    case 0:
      return 0x000006FB;
    case 1:
      return 0x00000800;
    case 2:
      return 0x00000209;
    case 3:
      return (1 << 0) | (1 << 4) | (1 << 8) | (1 << 15) | (1 << 23) |
             (1 << 25) | (1 << 26) | (1 << 30);
    }
  } else if (a == 2) {
    switch (reg_num) {
    case 0:
      return 0x00000000;
    case 1:
      return 0x00000000;
    case 2:
      return 0x00000000;
    case 3:
      return 0x00000000;
    }
  } else if (a == 4) {
    switch (reg_num) {
    case 0:
      return 0x00000000;
    case 1:
      return 0x00000000;
    case 2:
      return 0x00000000;
    case 3:
      return 0x00000000;
    }
  } else if (a == 7) {
    switch (reg_num) {
    case 0:
      return 0x00000000;
    case 1:
      return (1 << 0) | (1 << 3);
    case 2:
      return 0x00000000;
    case 3:
      return 0x00000000;
    }
  } else if (a == 0x80000000) {
    switch (reg_num) {
    case 0:
      return 0x80000008;
    case 1:
      return 0x00000000;
    case 2:
      return 0x00000000;
    case 3:
      return 0x00000000;
    }
  } else if (a == 0x80000001) {
    switch (reg_num) {
    case 0:
      return 0x00000000;
    case 1:
      return 0x00000000;
    case 2:
      return (1 << 0) | (0 << 5) | (1 << 8);
    case 3:
      return (1 << 11) | (0 << 20) | (0 << 26) | (0 << 27) | (1 << 29);
    }
  } else {
    fprintf(stderr, "WARNING not implemented x86_cpuid index %X!\n", a);
    exit(EXIT_FAILURE);
  }
  return 0;
}


x86 assembly (clang, -O0):
<x86_cpuid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jbe    115e <x86_cpuid+0x3e>
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xf25(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
cmpl   $0x0,-0x8(%rbp)
jne    11c2 <x86_cpuid+0xa2>
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%rax
ja     11bd <x86_cpuid+0x9d>
mov    -0x18(%rbp),%rax
lea    0xedc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0xa,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x756e6547,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x6c65746e,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x49656e69,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
jmp    1464 <x86_cpuid+0x344>
cmpl   $0x1,-0x8(%rbp)
jne    1226 <x86_cpuid+0x106>
mov    -0xc(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x3,%rax
ja     1221 <x86_cpuid+0x101>
mov    -0x20(%rbp),%rax
lea    0xe68(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x6fb,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x800,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x209,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x46808111,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
jmp    145f <x86_cpuid+0x33f>
cmpl   $0x2,-0x8(%rbp)
jne    128a <x86_cpuid+0x16a>
mov    -0xc(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x3,%rax
ja     1285 <x86_cpuid+0x165>
mov    -0x28(%rbp),%rax
lea    0xdf4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x0,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x0,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x0,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
jmp    145a <x86_cpuid+0x33a>
cmpl   $0x4,-0x8(%rbp)
jne    12ee <x86_cpuid+0x1ce>
mov    -0xc(%rbp),%eax
mov    %rax,-0x30(%rbp)
sub    $0x3,%rax
ja     12e9 <x86_cpuid+0x1c9>
mov    -0x30(%rbp),%rax
lea    0xd80(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x0,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x0,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x0,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
jmp    1455 <x86_cpuid+0x335>
cmpl   $0x7,-0x8(%rbp)
jne    1352 <x86_cpuid+0x232>
mov    -0xc(%rbp),%eax
mov    %rax,-0x38(%rbp)
sub    $0x3,%rax
ja     134d <x86_cpuid+0x22d>
mov    -0x38(%rbp),%rax
lea    0xd0c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x9,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x0,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x0,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
jmp    1450 <x86_cpuid+0x330>
cmpl   $0x80000000,-0x8(%rbp)
jne    13b9 <x86_cpuid+0x299>
mov    -0xc(%rbp),%eax
mov    %rax,-0x40(%rbp)
sub    $0x3,%rax
ja     13b4 <x86_cpuid+0x294>
mov    -0x40(%rbp),%rax
lea    0xc95(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x80000008,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x0,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x0,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x0,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
jmp    144b <x86_cpuid+0x32b>
cmpl   $0x80000001,-0x8(%rbp)
jne    1420 <x86_cpuid+0x300>
mov    -0xc(%rbp),%eax
mov    %rax,-0x48(%rbp)
sub    $0x3,%rax
ja     141b <x86_cpuid+0x2fb>
mov    -0x48(%rbp),%rax
lea    0xc1e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x0,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x101,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
movl   $0x20000800,-0x4(%rbp)
jmp    146b <x86_cpuid+0x34b>
jmp    1446 <x86_cpuid+0x326>
mov    0x2bb9(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xc5f(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2b99(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
jmp    144b <x86_cpuid+0x32b>
jmp    1450 <x86_cpuid+0x330>
jmp    1455 <x86_cpuid+0x335>
jmp    145a <x86_cpuid+0x33a>
jmp    145f <x86_cpuid+0x33f>
jmp    1464 <x86_cpuid+0x344>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<x86_cpuid>:
push   %rax
mov    %esi,%edx
cmp    $0x4,%esi
jae    11a1 <x86_cpuid+0x81>
mov    %edi,%ecx
xor    %eax,%eax
cmp    $0x7,%edi
ja     1145 <x86_cpuid+0x25>
mov    %ecx,%esi
lea    0xec6(%rip),%rdi
movslq (%rdi,%rsi,4),%rsi
add    %rdi,%rsi
jmp    *%rsi
pop    %rcx
ret
cmp    $0x80000000,%ecx
je     118d <x86_cpuid+0x6d>
cmp    $0x80000001,%ecx
jne    11c4 <x86_cpuid+0xa4>
cmp    $0x4,%edx
jae    1143 <x86_cpuid+0x23>
lea    0xf4f(%rip),%rax
jmp    1199 <x86_cpuid+0x79>
cmp    $0x4,%edx
jae    1143 <x86_cpuid+0x23>
lea    0xf01(%rip),%rax
jmp    1199 <x86_cpuid+0x79>
cmp    $0x4,%edx
jae    1143 <x86_cpuid+0x23>
lea    0xf03(%rip),%rax
jmp    1199 <x86_cpuid+0x79>
cmp    $0x4,%edx
jae    1143 <x86_cpuid+0x23>
lea    0xf05(%rip),%rax
jmp    1199 <x86_cpuid+0x79>
cmp    $0x4,%edx
jae    1143 <x86_cpuid+0x23>
lea    0xf07(%rip),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,4),%eax
pop    %rcx
ret
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0xe6f(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
mov    %ecx,%edx
jmp    11b1 <x86_cpuid+0x91>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"not implemented x86_cpuid reg %x\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [45 x i8] c"WARNING not implemented x86_cpuid index %X!\0A\00"
define i32 @x86_cpuid(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp ugt i32 %6, 3
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i32, i32* %5
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i32, i32* %5
switch i32 %18, label %23 [
i32 0, label %19
i32 1, label %20
i32 2, label %21
i32 3, label %22
]
19: ; preds = %17
store i32 10, i32* %3
br label %97
20: ; preds = %17
store i32 1970169159, i32* %3
br label %97
21: ; preds = %17
store i32 1818588270, i32* %3
br label %97
22: ; preds = %17
store i32 1231384169, i32* %3
br label %97
23: ; preds = %17
br label %96
24: ; preds = %14
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = load i32, i32* %5
switch i32 %28, label %33 [
i32 0, label %29
i32 1, label %30
i32 2, label %31
i32 3, label %32
]
29: ; preds = %27
store i32 1787, i32* %3
br label %97
30: ; preds = %27
store i32 2048, i32* %3
br label %97
31: ; preds = %27
store i32 521, i32* %3
br label %97
32: ; preds = %27
store i32 1182826769, i32* %3
br label %97
33: ; preds = %27
br label %95
34: ; preds = %24
%35 = load i32, i32* %4
%36 = icmp eq i32 %35, 2
br i1 %36, label %37, label %44
37: ; preds = %34
%38 = load i32, i32* %5
switch i32 %38, label %43 [
i32 0, label %39
i32 1, label %40
i32 2, label %41
i32 3, label %42
]
39: ; preds = %37
store i32 0, i32* %3
br label %97
40: ; preds = %37
store i32 0, i32* %3
br label %97
41: ; preds = %37
store i32 0, i32* %3
br label %97
42: ; preds = %37
store i32 0, i32* %3
br label %97
43: ; preds = %37
br label %94
44: ; preds = %34
%45 = load i32, i32* %4
%46 = icmp eq i32 %45, 4
br i1 %46, label %47, label %54
47: ; preds = %44
%48 = load i32, i32* %5
switch i32 %48, label %53 [
i32 0, label %49
i32 1, label %50
i32 2, label %51
i32 3, label %52
]
49: ; preds = %47
store i32 0, i32* %3
br label %97
50: ; preds = %47
store i32 0, i32* %3
br label %97
51: ; preds = %47
store i32 0, i32* %3
br label %97
52: ; preds = %47
store i32 0, i32* %3
br label %97
53: ; preds = %47
br label %93
54: ; preds = %44
%55 = load i32, i32* %4
%56 = icmp eq i32 %55, 7
br i1 %56, label %57, label %64
57: ; preds = %54
%58 = load i32, i32* %5
switch i32 %58, label %63 [
i32 0, label %59
i32 1, label %60
i32 2, label %61
i32 3, label %62
]
59: ; preds = %57
store i32 0, i32* %3
br label %97
60: ; preds = %57
store i32 9, i32* %3
br label %97
61: ; preds = %57
store i32 0, i32* %3
br label %97
62: ; preds = %57
store i32 0, i32* %3
br label %97
63: ; preds = %57
br label %92
64: ; preds = %54
%65 = load i32, i32* %4
%66 = icmp eq i32 %65, -2147483648
br i1 %66, label %67, label %74
67: ; preds = %64
%68 = load i32, i32* %5
switch i32 %68, label %73 [
i32 0, label %69
i32 1, label %70
i32 2, label %71
i32 3, label %72
]
69: ; preds = %67
store i32 -2147483640, i32* %3
br label %97
70: ; preds = %67
store i32 0, i32* %3
br label %97
71: ; preds = %67
store i32 0, i32* %3
br label %97
72: ; preds = %67
store i32 0, i32* %3
br label %97
73: ; preds = %67
br label %91
74: ; preds = %64
%75 = load i32, i32* %4
%76 = icmp eq i32 %75, -2147483647
br i1 %76, label %77, label %84
77: ; preds = %74
%78 = load i32, i32* %5
switch i32 %78, label %83 [
i32 0, label %79
i32 1, label %80
i32 2, label %81
i32 3, label %82
]
79: ; preds = %77
store i32 0, i32* %3
br label %97
80: ; preds = %77
store i32 0, i32* %3
br label %97
81: ; preds = %77
store i32 257, i32* %3
br label %97
82: ; preds = %77
store i32 536872960, i32* %3
br label %97
83: ; preds = %77
br label %90
84: ; preds = %74
%85 = load i32, i32* @stderr
%86 = load i32, i32* %4
%87 = call i32 @fprintf(i32 %85, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %86)
%88 = load i32, i32* @EXIT_FAILURE
%89 = call i32 @exit(i32 %88)
unreachable
90: ; preds = %83
br label %91
91: ; preds = %90, %73
br label %92
92: ; preds = %91, %63
br label %93
93: ; preds = %92, %53
br label %94
94: ; preds = %93, %43
br label %95
95: ; preds = %94, %33
br label %96
96: ; preds = %95, %23
store i32 0, i32* %3
br label %97
97: ; preds = %96, %82, %81, %80, %79, %72, %71, %70, %69, %62, %61, %60, %59, %52, %51, %50, %49, %42, %41, %40, %39, %32, %31, %30, %29, %22, %21, %20, %19
%98 = load i32, i32* %3
ret i32 %98
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"not implemented x86_cpuid reg %x\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [45 x i8] c"WARNING not implemented x86_cpuid index %X!\0A\00"
@switch.table.x86_cpuid = [4 x i32] [i32 10, i32 1970169159, i32 1818588270, i32 1231384169]
@switch.table.x86_cpuid.2 = [4 x i32] [i32 1787, i32 2048, i32 521, i32 1182826769]
@switch.table.x86_cpuid.3 = [4 x i32] [i32 0, i32 9, i32 0, i32 0]
@switch.table.x86_cpuid.4 = [4 x i32] [i32 -2147483640, i32 0, i32 0, i32 0]
@switch.table.x86_cpuid.5 = [4 x i32] [i32 0, i32 0, i32 257, i32 536872960]
define i32 @x86_cpuid(i32 %0, i32 %1) {
%3 = icmp ugt i32 %1, 3
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %1)
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
switch i32 %0, label %20 [
i32 0, label %10
i32 1, label %12
i32 2, label %30
i32 4, label %30
i32 7, label %14
i32 -2147483648, label %16
i32 -2147483647, label %18
]
10: ; preds = %9
%11 = icmp ult i32 %1, 4
br i1 %11, label %25, label %30
12: ; preds = %9
%13 = icmp ult i32 %1, 4
br i1 %13, label %25, label %30
14: ; preds = %9
%15 = icmp ult i32 %1, 4
br i1 %15, label %25, label %30
16: ; preds = %9
%17 = icmp ult i32 %1, 4
br i1 %17, label %25, label %30
18: ; preds = %9
%19 = icmp ult i32 %1, 4
br i1 %19, label %25, label %30
20: ; preds = %9
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %18, %16, %14, %12, %10
%26 = phi [4 x i32]* [ @switch.table.x86_cpuid, %10 ], [ @switch.table.x86_cpuid.2, %12 ], [ @switch.table.x86_cpuid.3, %14 ], [ @switch.table.x86_cpuid.4, %16 ], [ @switch.table.x86_cpuid.5, %18 ]
%27 = sext i32 %1 to i64
%28 = getelementptr inbounds [4 x i32], [4 x i32]* %26, i64 0, i64 %27
%29 = load i32, i32* %28
br label %30
30: ; preds = %25, %10, %12, %14, %16, %18, %9, %9
%31 = phi i32 [ 0, %9 ], [ 0, %9 ], [ 0, %18 ], [ 0, %16 ], [ 0, %14 ], [ 0, %12 ], [ 0, %10 ], [ %29, %25 ]
ret i32 %31
}