#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 uint8_t;

/* Variables and functions */
int /*<<< orphan*/ cpuid_get(int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int main(void) {
  uint8_t id[(12)];
  puts("Test for the CPUID driver");
  puts("This test is reading out the CPUID of the platforms CPU\n");
  cpuid_get(id);
  printf("CPUID:");
  for (unsigned int i = 0; i < (12); i++) {
    printf(" 0x%02x", id[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
lea    0xec8(%rip),%rdi
call   1030 <puts@plt>
lea    -0x40(%rbp),%rdi
call   1050 <cpuid_get@plt>
lea    0xeec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0xc,-0x44(%rbp)
jae    11a2 <main+0x72>
mov    -0x44(%rbp),%eax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1175 <main+0x45>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xeb4(%rip),%rdi
call   1040 <puts@plt>
lea    0xec2(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rdi
call   1060 <cpuid_get@plt>
lea    0xee7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%esi
lea    0xedd(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Test for the CPUID driver\00"
@.str.1 = [57 x i8] c"This test is reading out the CPUID of the platforms CPU\0A\00"
@.str.2 = [7 x i8] c"CPUID:\00"
@.str.3 = [8 x i8] c" 0x%02x\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [12 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @puts(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
%6 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 0
%7 = call i32 @cpuid_get(i32* %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %9
9: ; preds = %18, %0
%10 = load i32, i32* %3
%11 = icmp ult i32 %10, 12
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = load i32, i32* %3
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %12
%19 = load i32, i32* %3
%20 = add i32 %19, 1
store i32 %20, i32* %3
br label %9
21: ; preds = %9
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Test for the CPUID driver\00"
@.str.1 = [57 x i8] c"This test is reading out the CPUID of the platforms CPU\0A\00"
@.str.2 = [7 x i8] c"CPUID:\00"
@.str.3 = [8 x i8] c" 0x%02x\00"
define i32 @main() {
%1 = alloca [12 x i32]
%2 = bitcast [12 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
%5 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 0
%6 = call i32 @cpuid_get(i32* %5)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%8 = load i32, i32* %5
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 1
%11 = load i32, i32* %10
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 2
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 3
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 4
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 5
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 6
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 7
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 8
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 9
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 10
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 11
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = call i32 @putchar(i32 10)
ret i32 0
}