int main() {
  unsigned int cpuid[4];
  char vendor_id[13];
  memset(cpuid, 0, sizeof(unsigned int) * 4);
  memset(vendor_id, 0, sizeof(char) * 13);
  get_cpuid(0x40000000, cpuid);
  u32_to_char_arr(vendor_id, cpuid[1]);
  u32_to_char_arr(vendor_id + 4, cpuid[2]);
  u32_to_char_arr(vendor_id + 8, cpuid[3]);
  printf("%s\n", vendor_id);
  memset(cpuid, 0, sizeof(unsigned int) * 4);
  get_cpuid(0x40000001, cpuid);
  if (0x31237648 != cpuid[0]) {
    return 1;
  }
  memset(cpuid, 0, sizeof(unsigned int) * 4);
  get_cpuid(0x40000002, cpuid);
  printf("%d.%d\n", (cpuid[1] >> 16) & 0xFF, (cpuid[1]) & 0xFF);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
lea    -0x2d(%rbp),%rdi
xor    %esi,%esi
mov    $0xd,%edx
call   1050 <memset@plt>
lea    -0x20(%rbp),%rsi
mov    $0x40000000,%edi
mov    $0x0,%al
call   1030 <get_cpuid@plt>
lea    -0x2d(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x0,%al
call   1060 <u32_to_char_arr@plt>
lea    -0x2d(%rbp),%rdi
add    $0x4,%rdi
mov    -0x18(%rbp),%esi
mov    $0x0,%al
call   1060 <u32_to_char_arr@plt>
lea    -0x2d(%rbp),%rdi
add    $0x8,%rdi
mov    -0x14(%rbp),%esi
mov    $0x0,%al
call   1060 <u32_to_char_arr@plt>
lea    -0x2d(%rbp),%rsi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
lea    -0x20(%rbp),%rsi
mov    $0x40000001,%edi
mov    $0x0,%al
call   1030 <get_cpuid@plt>
mov    $0x31237648,%eax
cmp    -0x20(%rbp),%eax
je     11fd <main+0xbd>
movl   $0x1,-0x4(%rbp)
jmp    1247 <main+0x107>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
lea    -0x20(%rbp),%rsi
mov    $0x40000002,%edi
mov    $0x0,%al
call   1030 <get_cpuid@plt>
mov    -0x1c(%rbp),%esi
shr    $0x10,%esi
and    $0xff,%esi
mov    -0x1c(%rbp),%edx
and    $0xff,%edx
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x18(%rsp)
movq   $0x0,0x1d(%rsp)
mov    %rsp,%r14
mov    $0x40000000,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <get_cpuid@plt>
mov    0x4(%rsp),%esi
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <u32_to_char_arr@plt>
lea    0x1c(%rsp),%rdi
mov    0x8(%rsp),%esi
xor    %eax,%eax
call   1060 <u32_to_char_arr@plt>
lea    0x20(%rsp),%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1060 <u32_to_char_arr@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    $0x40000001,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <get_cpuid@plt>
mov    $0x1,%eax
cmpl   $0x31237648,(%rsp)
jne    1204 <main+0xc4>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
mov    $0x40000002,%edi
xor    %eax,%eax
call   1040 <get_cpuid@plt>
mov    0x4(%rsp),%eax
movzbl %al,%edx
shr    $0x10,%eax
movzbl %al,%esi
lea    0xe15(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [7 x i8] c"%d.%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i32]
%3 = alloca [13 x i8]
store i32 0, i32* %1
%4 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%5 = bitcast i32* %4 to i8*
%6 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%8 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @get_cpuid to i32 (i32, i32*, ...)*)(i32 1073741824, i32* %7)
%9 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%11 = load i32, i32* %10
%12 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @u32_to_char_arr to i32 (i8*, i32, ...)*)(i8* %9, i32 %11)
%13 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds i8, i8* %13, i64 4
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%16 = load i32, i32* %15
%17 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @u32_to_char_arr to i32 (i8*, i32, ...)*)(i8* %14, i32 %16)
%18 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%19 = getelementptr inbounds i8, i8* %18, i64 8
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%21 = load i32, i32* %20
%22 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @u32_to_char_arr to i32 (i8*, i32, ...)*)(i8* %19, i32 %21)
%23 = getelementptr inbounds [13 x i8], [13 x i8]* %3, i64 0, i64 0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%26 = bitcast i32* %25 to i8*
%27 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%28 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @get_cpuid to i32 (i32, i32*, ...)*)(i32 1073741825, i32* %27)
%29 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%30 = load i32, i32* %29
%31 = icmp ne i32 824407624, %30
br i1 %31, label %32, label %33
32: ; preds = %0
store i32 1, i32* %1
br label %46
33: ; preds = %0
%34 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%35 = bitcast i32* %34 to i8*
%36 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%37 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @get_cpuid to i32 (i32, i32*, ...)*)(i32 1073741826, i32* %36)
%38 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%39 = load i32, i32* %38
%40 = lshr i32 %39, 16
%41 = and i32 %40, 255
%42 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%43 = load i32, i32* %42
%44 = and i32 %43, 255
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %41, i32 %44)
store i32 0, i32* %1
br label %46
46: ; preds = %33, %32
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%d.%d\0A\00"
define i32 @main() {
%1 = alloca [4 x i32]
%2 = alloca [13 x i8]
%3 = bitcast [4 x i32]* %1 to i8*
%4 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%6 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @get_cpuid to i32 (i32, i32*, ...)*)(i32 1073741824, i32* %5)
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%8 = load i32, i32* %7
%9 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @u32_to_char_arr to i32 (i8*, i32, ...)*)(i8* %4, i32 %8)
%10 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 4
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%12 = load i32, i32* %11
%13 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @u32_to_char_arr to i32 (i8*, i32, ...)*)(i8* %10, i32 %12)
%14 = getelementptr inbounds [13 x i8], [13 x i8]* %2, i64 0, i64 8
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%16 = load i32, i32* %15
%17 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @u32_to_char_arr to i32 (i8*, i32, ...)*)(i8* %14, i32 %16)
%18 = call i32 @puts(i8* %4)
%19 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @get_cpuid to i32 (i32, i32*, ...)*)(i32 1073741825, i32* %5)
%20 = load i32, i32* %5
%21 = icmp eq i32 %20, 824407624
br i1 %21, label %22, label %29
22: ; preds = %0
%23 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @get_cpuid to i32 (i32, i32*, ...)*)(i32 1073741826, i32* %5)
%24 = load i32, i32* %7
%25 = lshr i32 %24, 16
%26 = and i32 %25, 255
%27 = and i32 %24, 255
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %27)
br label %29
29: ; preds = %0, %22
%30 = phi i32 [ 0, %22 ], [ 1, %0 ]
ret i32 %30
}