#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 */
unsigned int cpuid(unsigned int, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ puts(char *);
void cpu_sig(void) {
  char sig[13];
  unsigned int base = 0x40000000, leaf = base;
  unsigned int max_entries;
  memset(sig, 0, sizeof sig);
  max_entries = cpuid(leaf, sig);
  puts(sig);
  if (max_entries > 3 && max_entries < 0x10000) {
    for (leaf = base + 0x100; leaf <= base + max_entries; leaf += 0x100) {
      memset(sig, 0, sizeof sig);
      cpuid(leaf, sig);
      puts(sig);
    }
  }
}


x86 assembly (clang, -O0):
<cpu_sig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x40000000,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0xd(%rbp),%rdi
xor    %esi,%esi
mov    $0xd,%edx
call   1040 <memset@plt>
mov    -0x18(%rbp),%edi
lea    -0xd(%rbp),%rsi
call   1050 <cpuid@plt>
mov    %eax,-0x1c(%rbp)
lea    -0xd(%rbp),%rdi
call   1030 <puts@plt>
cmpl   $0x3,-0x1c(%rbp)
jbe    11da <cpu_sig+0xaa>
cmpl   $0x10000,-0x1c(%rbp)
jae    11da <cpu_sig+0xaa>
mov    -0x14(%rbp),%eax
add    $0x100,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    -0x1c(%rbp),%ecx
cmp    %ecx,%eax
ja     11d5 <cpu_sig+0xa5>
lea    -0xd(%rbp),%rdi
xor    %esi,%esi
mov    $0xd,%edx
call   1040 <memset@plt>
mov    -0x18(%rbp),%edi
lea    -0xd(%rbp),%rsi
call   1050 <cpuid@plt>
lea    -0xd(%rbp),%rdi
call   1030 <puts@plt>
mov    -0x18(%rbp),%eax
add    $0x100,%eax
mov    %eax,-0x18(%rbp)
jmp    118f <cpu_sig+0x5f>
jmp    11da <cpu_sig+0xaa>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpu_sig>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0x3(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xd,%edx
call   1040 <memset@plt>
mov    $0x40000000,%edi
mov    %rbx,%rsi
call   1050 <cpuid@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    -0x4(%r14),%eax
cmp    $0xfffb,%eax
ja     11bc <cpu_sig+0x8c>
cmp    $0x100,%r14d
jb     11bc <cpu_sig+0x8c>
add    $0x40000000,%r14d
mov    $0x40000100,%ebp
lea    0x3(%rsp),%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xd,%edx
call   1040 <memset@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <cpuid@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
add    $0x100,%ebp
cmp    %r14d,%ebp
jbe    1190 <cpu_sig+0x60>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @cpu_sig() {
%1 = alloca [13 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 1073741824, i32* %2
%5 = load i32, i32* %2
store i32 %5, i32* %3
%6 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i32 0, i32 13)
%8 = load i32, i32* %3
%9 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%10 = call i32 @cpuid(i32 %8, i8* %9)
store i32 %10, i32* %4
%11 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%12 = call i32 @puts(i8* %11)
%13 = load i32, i32* %4
%14 = icmp ugt i32 %13, 3
br i1 %14, label %15, label %39
15: ; preds = %0
%16 = load i32, i32* %4
%17 = icmp ult i32 %16, 65536
br i1 %17, label %18, label %39
18: ; preds = %15
%19 = load i32, i32* %2
%20 = add i32 %19, 256
store i32 %20, i32* %3
br label %21
21: ; preds = %35, %18
%22 = load i32, i32* %3
%23 = load i32, i32* %2
%24 = load i32, i32* %4
%25 = add i32 %23, %24
%26 = icmp ule i32 %22, %25
br i1 %26, label %27, label %38
27: ; preds = %21
%28 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%29 = call i32 @memset(i8* %28, i32 0, i32 13)
%30 = load i32, i32* %3
%31 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%32 = call i32 @cpuid(i32 %30, i8* %31)
%33 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%34 = call i32 @puts(i8* %33)
br label %35
35: ; preds = %27
%36 = load i32, i32* %3
%37 = add i32 %36, 256
store i32 %37, i32* %3
br label %21
38: ; preds = %21
br label %39
39: ; preds = %38, %15, %0
ret void
}

LLVM IR (-O2):
define void @cpu_sig() {
%1 = alloca [13 x i8]
%2 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%3 = call i32 @memset(i8* %2, i32 0, i32 13)
%4 = call i32 @cpuid(i32 1073741824, i8* %2)
%5 = call i32 @puts(i8* %2)
%6 = add i32 %4, -4
%7 = icmp ult i32 %6, 65532
br i1 %7, label %8, label %18
8: ; preds = %0
%9 = add nuw nsw i32 %4, 1073741824
%10 = icmp ult i32 %4, 256
br i1 %10, label %18, label %11
11: ; preds = %8, %11
%12 = phi i32 [ %16, %11 ], [ 1073742080, %8 ]
%13 = call i32 @memset(i8* %2, i32 0, i32 13)
%14 = call i32 @cpuid(i32 %12, i8* %2)
%15 = call i32 @puts(i8* %2)
%16 = add i32 %12, 256
%17 = icmp ugt i32 %16, %9
br i1 %17, label %18, label %11
18: ; preds = %11, %8, %0
ret void
}