#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*/ amd_list_features();
int /*<<< orphan*/ configure_serial();
scalar_t__ cpuid_support();
unsigned long detect_cpu();
int /*<<< orphan*/ intel_list_features();
int /*<<< orphan*/ print(char *);
int /*<<< orphan*/ puts(int, char *);
int kmain() {
  configure_serial();
  if (cpuid_support()) {
    print("CPUID is supported! ");
    unsigned long cpu = detect_cpu();
    if (cpu == 0x756e6547) {
      print("Intel CPU!");
      intel_list_features();
    } else if (cpu == 0x68747541) {
      print("AMD CPU!");
      amd_list_features();
    } else {
      print("CPU make is not supported");
    }
  } else {
    print("CPUID is not supported, get a new CPU peasent.");
  }
  char *debug = "Finished - now looping forever :(";
  puts(1, debug);
  return 0;
}


x86 assembly (clang, -O0):
<kmain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <configure_serial@plt>
mov    $0x0,%al
call   1080 <cpuid_support@plt>
cmp    $0x0,%rax
je     1209 <kmain+0x99>
lea    0xe69(%rip),%rdi
call   1060 <print@plt>
mov    $0x0,%al
call   1050 <detect_cpu@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x756e6547,-0x8(%rbp)
75
jne    11cd <kmain+0x5d>
lea    0xe59(%rip),%rdi
call   1060 <print@plt>
mov    $0x0,%al
call   1070 <intel_list_features@plt>
jmp    1204 <kmain+0x94>
cmpq   $0x68747541,-0x8(%rbp)
68
jne    11f3 <kmain+0x83>
lea    0xe3e(%rip),%rdi
call   1060 <print@plt>
mov    $0x0,%al
call   1090 <amd_list_features@plt>
jmp    11ff <kmain+0x8f>
lea    0xe2f(%rip),%rdi
call   1060 <print@plt>
jmp    1204 <kmain+0x94>
jmp    1215 <kmain+0xa5>
lea    0xe33(%rip),%rdi
call   1060 <print@plt>
lea    0xe56(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    $0x1,%edi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kmain>:
push   %rax
xor    %eax,%eax
call   1040 <configure_serial@plt>
xor    %eax,%eax
call   1080 <cpuid_support@plt>
test   %rax,%rax
je     11bc <kmain+0x4c>
lea    0xe75(%rip),%rdi
call   1060 <print@plt>
xor    %eax,%eax
call   1050 <detect_cpu@plt>
cmp    $0x68747541,%rax
je     11c5 <kmain+0x55>
cmp    $0x756e6547,%rax
jne    11da <kmain+0x6a>
lea    0xe67(%rip),%rdi
call   1060 <print@plt>
xor    %eax,%eax
call   1070 <intel_list_features@plt>
jmp    11e6 <kmain+0x76>
lea    0xe80(%rip),%rdi
jmp    11e1 <kmain+0x71>
lea    0xe54(%rip),%rdi
call   1060 <print@plt>
xor    %eax,%eax
call   1090 <amd_list_features@plt>
jmp    11e6 <kmain+0x76>
lea    0xe48(%rip),%rdi
call   1060 <print@plt>
lea    0xe85(%rip),%rsi
mov    $0x1,%edi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"CPUID is supported! \00"
@.str.1 = [11 x i8] c"Intel CPU!\00"
@.str.2 = [9 x i8] c"AMD CPU!\00"
@.str.3 = [26 x i8] c"CPU make is not supported\00"
@.str.4 = [47 x i8] c"CPUID is not supported, get a new CPU peasent.\00"
@.str.5 = [34 x i8] c"Finished - now looping forever :(\00"
define i32 @kmain() {
%1 = alloca i64
%2 = alloca i8*
%3 = call i32 (...) @configure_serial()
%4 = call i64 (...) @cpuid_support()
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %24
6: ; preds = %0
%7 = call i32 @print(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%8 = call i64 (...) @detect_cpu()
store i64 %8, i64* %1
%9 = load i64, i64* %1
%10 = icmp eq i64 %9, 1970169159
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = call i32 @print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (...) @intel_list_features()
br label %23
14: ; preds = %6
%15 = load i64, i64* %1
%16 = icmp eq i64 %15, 1752462657
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = call i32 @print(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 (...) @amd_list_features()
br label %22
20: ; preds = %14
%21 = call i32 @print(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %20, %17
br label %23
23: ; preds = %22, %11
br label %26
24: ; preds = %0
%25 = call i32 @print(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
br label %26
26: ; preds = %24, %23
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i8** %2
%27 = load i8*, i8** %2
%28 = call i32 @puts(i32 1, i8* %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"CPUID is supported! \00"
@.str.1 = [11 x i8] c"Intel CPU!\00"
@.str.2 = [9 x i8] c"AMD CPU!\00"
@.str.3 = [26 x i8] c"CPU make is not supported\00"
@.str.4 = [47 x i8] c"CPUID is not supported, get a new CPU peasent.\00"
@.str.5 = [34 x i8] c"Finished - now looping forever :(\00"
define i32 @kmain() {
%1 = tail call i32 (...) @configure_serial()
%2 = tail call i64 (...) @cpuid_support()
%3 = icmp eq i64 %2, 0
br i1 %3, label %15, label %4
4: ; preds = %0
%5 = tail call i32 @print(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = tail call i64 (...) @detect_cpu()
switch i64 %6, label %13 [
i64 1970169159, label %7
i64 1752462657, label %10
]
7: ; preds = %4
%8 = tail call i32 @print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 (...) @intel_list_features()
br label %17
10: ; preds = %4
%11 = tail call i32 @print(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 (...) @amd_list_features()
br label %17
13: ; preds = %4
%14 = tail call i32 @print(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %17
15: ; preds = %0
%16 = tail call i32 @print(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0))
br label %17
17: ; preds = %7, %13, %10, %15
%18 = tail call i32 @puts(i32 1, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}