#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_fn(int, void *);
int /*<<< orphan*/ printf(char *, ...);
void cpuid_brand_string() {
  unsigned int results[4];
  char str[48];
  unsigned int max;
  cpuid_fn(0x80000000, results);
  max = results[0];
  if (!((max & 0x80000000) && (max > 0x80000004))) {
    printf("Processor Brand String Not Supported\n");
    return;
  }
  cpuid_fn(0x80000002, (void *)str);
  cpuid_fn(0x80000003, (void *)(str + 16));
  cpuid_fn(0x80000004, (void *)(str + 32));
  printf("%s\n", str);
}


x86 assembly (clang, -O0):
<cpuid_brand_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x10(%rbp),%rsi
mov    $0x80000000,%edi
call   1030 <cpuid_fn@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
and    $0x80000000,%eax
cmp    $0x0,%eax
je     115a <cpuid_brand_string+0x3a>
cmpl   $0x80000004,-0x44(%rbp)
ja     116d <cpuid_brand_string+0x4d>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b1 <cpuid_brand_string+0x91>
lea    -0x40(%rbp),%rsi
mov    $0x80000002,%edi
call   1030 <cpuid_fn@plt>
lea    -0x40(%rbp),%rsi
add    $0x10,%rsi
mov    $0x80000003,%edi
call   1030 <cpuid_fn@plt>
lea    -0x40(%rbp),%rsi
add    $0x20,%rsi
mov    $0x80000004,%edi
call   1030 <cpuid_fn@plt>
lea    -0x40(%rbp),%rsi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpuid_brand_string>:
push   %rbx
sub    $0x40,%rsp
mov    %rsp,%rsi
mov    $0x80000000,%edi
call   1030 <cpuid_fn@plt>
cmpl   $0x80000004,(%rsp)
jbe    1170 <cpuid_brand_string+0x50>
lea    0x10(%rsp),%rbx
mov    $0x80000002,%edi
mov    %rbx,%rsi
call   1030 <cpuid_fn@plt>
lea    0x20(%rsp),%rsi
mov    $0x80000003,%edi
call   1030 <cpuid_fn@plt>
lea    0x30(%rsp),%rsi
mov    $0x80000004,%edi
call   1030 <cpuid_fn@plt>
mov    %rbx,%rdi
jmp    1177 <cpuid_brand_string+0x57>
lea    0xe89(%rip),%rdi
call   1040 <puts@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Processor Brand String Not Supported\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @cpuid_brand_string() {
%1 = alloca [4 x i32]
%2 = alloca [48 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%5 = bitcast i32* %4 to i8*
%6 = call i32 @cpuid_fn(i32 -2147483648, i8* %5)
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%8 = load i32, i32* %7
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = and i32 %9, -2147483648
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = load i32, i32* %3
%14 = icmp ugt i32 %13, -2147483644
br i1 %14, label %17, label %15
15: ; preds = %12, %0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %28
17: ; preds = %12
%18 = getelementptr inbounds [48 x i8], [48 x i8]* %2, i64 0, i64 0
%19 = call i32 @cpuid_fn(i32 -2147483646, i8* %18)
%20 = getelementptr inbounds [48 x i8], [48 x i8]* %2, i64 0, i64 0
%21 = getelementptr inbounds i8, i8* %20, i64 16
%22 = call i32 @cpuid_fn(i32 -2147483645, i8* %21)
%23 = getelementptr inbounds [48 x i8], [48 x i8]* %2, i64 0, i64 0
%24 = getelementptr inbounds i8, i8* %23, i64 32
%25 = call i32 @cpuid_fn(i32 -2147483644, i8* %24)
%26 = getelementptr inbounds [48 x i8], [48 x i8]* %2, i64 0, i64 0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %17, %15
ret void
}

LLVM IR (-O2):
@str = [37 x i8] c"Processor Brand String Not Supported\00"
define void @cpuid_brand_string() {
%1 = alloca [4 x i32]
%2 = alloca [48 x i8]
%3 = bitcast [4 x i32]* %1 to i8*
%4 = getelementptr inbounds [48 x i8], [48 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%6 = call i32 @cpuid_fn(i32 -2147483648, i8* %3)
%7 = load i32, i32* %5
%8 = icmp ugt i32 %7, -2147483644
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %18
11: ; preds = %0
%12 = call i32 @cpuid_fn(i32 -2147483646, i8* %4)
%13 = getelementptr inbounds [48 x i8], [48 x i8]* %2, i64 0, i64 16
%14 = call i32 @cpuid_fn(i32 -2147483645, i8* %13)
%15 = getelementptr inbounds [48 x i8], [48 x i8]* %2, i64 0, i64 32
%16 = call i32 @cpuid_fn(i32 -2147483644, i8* %15)
%17 = call i32 @puts(i8* %4)
br label %18
18: ; preds = %11, %9
ret void
}