#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 uint64_t;
typedef scalar_t__ rdx;
typedef scalar_t__ rcx;
typedef scalar_t__ rbx;

/* Variables and functions */
int /*<<< orphan*/ cpuid(int, int *, int *, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
void cpuid_printVendorID() {
  uint64_t rax, rbx, rcx, rdx;
  int leaf = 0, i = 0;
  cpuid(leaf, &rax, &rbx, &rcx, &rdx);
  for (i = 0; i < 32; i += 8) {
    printf("%c", (int)(((uint64_t)(rbx) &
                        ((((uint64_t)1 << (((7 + i)) - ((0 + i)) + 1)) - 1)
                         << ((0 + i)))) >>
                       (0 + i)));
  }
  for (i = 0; i < 32; i += 8) {
    printf("%lc", (int)(((uint64_t)(rdx) &
                         ((((uint64_t)1 << (((7 + i)) - ((0 + i)) + 1)) - 1)
                          << ((0 + i)))) >>
                        (0 + i)));
  }
  for (i = 0; i < 32; i += 8) {
    printf("%lc", (int)(((uint64_t)(rcx) &
                         ((((uint64_t)1 << (((7 + i)) - ((0 + i)) + 1)) - 1)
                          << ((0 + i)))) >>
                        (0 + i)));
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<cpuid_printVendorID>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
lea    -0x10(%rbp),%r8
call   1040 <cpuid@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x20,-0x18(%rbp)
jge    11ab <cpuid_printVendorID+0x8b>
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%ecx
add    $0x7,%ecx
mov    -0x18(%rbp),%eax
add    $0x0,%eax
sub    %eax,%ecx
add    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
mov    -0x18(%rbp),%ecx
add    $0x0,%ecx
shl    %cl,%eax
and    %eax,%esi
mov    -0x18(%rbp),%ecx
add    $0x0,%ecx
sar    %cl,%esi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x18(%rbp)
jmp    1155 <cpuid_printVendorID+0x35>
movl   $0x0,-0x18(%rbp)
cmpl   $0x20,-0x18(%rbp)
jge    1208 <cpuid_printVendorID+0xe8>
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%ecx
add    $0x7,%ecx
mov    -0x18(%rbp),%eax
add    $0x0,%eax
sub    %eax,%ecx
add    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
mov    -0x18(%rbp),%ecx
add    $0x0,%ecx
shl    %cl,%eax
and    %eax,%esi
mov    -0x18(%rbp),%ecx
add    $0x0,%ecx
sar    %cl,%esi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x18(%rbp)
jmp    11b2 <cpuid_printVendorID+0x92>
movl   $0x0,-0x18(%rbp)
cmpl   $0x20,-0x18(%rbp)
jge    1265 <cpuid_printVendorID+0x145>
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%ecx
add    $0x7,%ecx
mov    -0x18(%rbp),%eax
add    $0x0,%eax
sub    %eax,%ecx
add    $0x1,%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
mov    -0x18(%rbp),%ecx
add    $0x0,%ecx
shl    %cl,%eax
and    %eax,%esi
mov    -0x18(%rbp),%ecx
add    $0x0,%ecx
sar    %cl,%esi
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x18(%rbp)
jmp    120f <cpuid_printVendorID+0xef>
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpuid_printVendorID>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
mov    %rsp,%r8
xor    %edi,%edi
call   1050 <cpuid@plt>
movzbl 0x8(%rsp),%edi
call   1030 <putchar@plt>
movzbl 0x9(%rsp),%edi
call   1030 <putchar@plt>
movzbl 0xa(%rsp),%edi
call   1030 <putchar@plt>
movsbl 0xb(%rsp),%edi
call   1030 <putchar@plt>
movzbl (%rsp),%esi
lea    0xe7f(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x1(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x2(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x3(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x5(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x6(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x7(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [4 x i8] c"%lc\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @cpuid_printVendorID() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %5
store i32 0, i32* %6
%7 = load i32, i32* %5
%8 = call i32 @cpuid(i32 %7, i32* %1, i32* %2, i32* %3, i32* %4)
store i32 0, i32* %6
br label %9
9: ; preds = %30, %0
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 32
br i1 %11, label %12, label %33
12: ; preds = %9
%13 = load i32, i32* %2
%14 = load i32, i32* %6
%15 = add nsw i32 7, %14
%16 = load i32, i32* %6
%17 = add nsw i32 0, %16
%18 = sub nsw i32 %15, %17
%19 = add nsw i32 %18, 1
%20 = shl i32 1, %19
%21 = sub nsw i32 %20, 1
%22 = load i32, i32* %6
%23 = add nsw i32 0, %22
%24 = shl i32 %21, %23
%25 = and i32 %13, %24
%26 = load i32, i32* %6
%27 = add nsw i32 0, %26
%28 = ashr i32 %25, %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %12
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 8
store i32 %32, i32* %6
br label %9
33: ; preds = %9
store i32 0, i32* %6
br label %34
34: ; preds = %55, %33
%35 = load i32, i32* %6
%36 = icmp slt i32 %35, 32
br i1 %36, label %37, label %58
37: ; preds = %34
%38 = load i32, i32* %4
%39 = load i32, i32* %6
%40 = add nsw i32 7, %39
%41 = load i32, i32* %6
%42 = add nsw i32 0, %41
%43 = sub nsw i32 %40, %42
%44 = add nsw i32 %43, 1
%45 = shl i32 1, %44
%46 = sub nsw i32 %45, 1
%47 = load i32, i32* %6
%48 = add nsw i32 0, %47
%49 = shl i32 %46, %48
%50 = and i32 %38, %49
%51 = load i32, i32* %6
%52 = add nsw i32 0, %51
%53 = ashr i32 %50, %52
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %37
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 8
store i32 %57, i32* %6
br label %34
58: ; preds = %34
store i32 0, i32* %6
br label %59
59: ; preds = %80, %58
%60 = load i32, i32* %6
%61 = icmp slt i32 %60, 32
br i1 %61, label %62, label %83
62: ; preds = %59
%63 = load i32, i32* %3
%64 = load i32, i32* %6
%65 = add nsw i32 7, %64
%66 = load i32, i32* %6
%67 = add nsw i32 0, %66
%68 = sub nsw i32 %65, %67
%69 = add nsw i32 %68, 1
%70 = shl i32 1, %69
%71 = sub nsw i32 %70, 1
%72 = load i32, i32* %6
%73 = add nsw i32 0, %72
%74 = shl i32 %71, %73
%75 = and i32 %63, %74
%76 = load i32, i32* %6
%77 = add nsw i32 0, %76
%78 = ashr i32 %75, %77
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %78)
br label %80
80: ; preds = %62
%81 = load i32, i32* %6
%82 = add nsw i32 %81, 8
store i32 %82, i32* %6
br label %59
83: ; preds = %59
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%lc\00"
define void @cpuid_printVendorID() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 @cpuid(i32 0, i32* %1, i32* %2, i32* %3, i32* %4)
%10 = load i32, i32* %2
%11 = and i32 %10, 255
%12 = call i32 @putchar(i32 %11)
%13 = load i32, i32* %2
%14 = lshr i32 %13, 8
%15 = and i32 %14, 255
%16 = call i32 @putchar(i32 %15)
%17 = load i32, i32* %2
%18 = lshr i32 %17, 16
%19 = and i32 %18, 255
%20 = call i32 @putchar(i32 %19)
%21 = load i32, i32* %2
%22 = ashr i32 %21, 24
%23 = call i32 @putchar(i32 %22)
%24 = load i32, i32* %4
%25 = and i32 %24, 255
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %4
%28 = lshr i32 %27, 8
%29 = and i32 %28, 255
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %4
%32 = lshr i32 %31, 16
%33 = and i32 %32, 255
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %4
%36 = ashr i32 %35, 24
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %3
%39 = and i32 %38, 255
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %3
%42 = lshr i32 %41, 8
%43 = and i32 %42, 255
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %3
%46 = lshr i32 %45, 16
%47 = and i32 %46, 255
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %3
%50 = ashr i32 %49, 24
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %50)
%52 = call i32 @putchar(i32 10)
ret void
}