#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 uint32_t;
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ __cpuid(int, int, int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  char n[4] = {'A', 'B', 'C', 'D'};
  uint32_t e[4];
  uint32_t leaf = 0x80000002u;
  __cpuid(leaf, e[0], e[1], e[2], e[3]);
  printf("------------------------------------------------------\n");
  printf("(hi-to-lo)   |1098|7654|3210|9876|5432|1098|7654|3210|\n");
  printf("------------------------------------------------------\n");
  for (int j = 0; j < 4; j++) {
    printf("E%cX=%8x=|", n[j], e[j]);
    for (int32_t i = 31; i >= 0; i--) {
      printf("%d", e[j] & (1 << i) ? 1 : 0);
      if ((i % 4) == 0)
        printf("|");
    }
    printf("\n");
  }
  printf("------------------------------------------------------\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xecb(%rip),%eax
mov    %eax,-0x8(%rbp)
movl   $0x80000002,-0x24(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
call   1040 <__cpuid@plt>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    1245 <main+0x125>
movslq -0x28(%rbp),%rax
movsbl -0x8(%rbp,%rax,1),%esi
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1f,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jl     1229 <main+0x109>
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    -0x30(%rbp),%ecx
and    %eax,%ecx
xor    %esi,%esi
mov    $0x1,%eax
cmp    $0x0,%ecx
cmovne %eax,%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1216 <main+0xf6>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121b <main+0xfb>
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    11b5 <main+0x95>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1185 <main+0x65>
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x80000002,%edi
call   1060 <__cpuid@plt>
lea    0xef1(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xeab(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xe89(%rip),%rdi
mov    $0x41,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1f,%ebp
lea    0xe7c(%rip),%rbx
jmp    11a5 <main+0x65>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
jae    11c3 <main+0x83>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   $0x3,%bpl
jne    11a0 <main+0x60>
mov    $0x7c,%edi
call   1030 <putchar@plt>
jmp    11a0 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe2c(%rip),%rdi
mov    $0x42,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1f,%ebp
lea    0xe1f(%rip),%rbx
jmp    11f5 <main+0xb5>
xchg   %ax,%ax
add    $0xffffffff,%ebp
jae    1213 <main+0xd3>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   $0x3,%bpl
jne    11f0 <main+0xb0>
mov    $0x7c,%edi
call   1030 <putchar@plt>
jmp    11f0 <main+0xb0>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xddc(%rip),%rdi
mov    $0x43,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1f,%ebp
lea    0xdcf(%rip),%rbx
jmp    1245 <main+0x105>
xchg   %ax,%ax
add    $0xffffffff,%ebp
jae    1263 <main+0x123>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   $0x3,%bpl
jne    1240 <main+0x100>
mov    $0x7c,%edi
call   1030 <putchar@plt>
jmp    1240 <main+0x100>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd8c(%rip),%rdi
mov    $0x44,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1f,%ebp
lea    0xd7f(%rip),%rbx
jmp    1295 <main+0x155>
xchg   %ax,%ax
add    $0xffffffff,%ebp
jae    12b3 <main+0x173>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   $0x3,%bpl
jne    1290 <main+0x150>
mov    $0x7c,%edi
call   1030 <putchar@plt>
jmp    1290 <main+0x150>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd81(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.n = [4 x i8] c"ABCD"
@.str = [56 x i8] c"------------------------------------------------------\0A\00"
@.str.1 = [56 x i8] c"(hi-to-lo) |1098|7654|3210|9876|5432|1098|7654|3210|\0A\00"
@.str.2 = [11 x i8] c"E%cX=%8x=|\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [2 x i8] c"|\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x i8]
%3 = alloca [4 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [4 x i8]* %2 to i8*
store i32 -2147483646, i32* %4
%8 = load i32, i32* %4
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
%12 = load i32, i32* %11
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
%14 = load i32, i32* %13
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
%16 = load i32, i32* %15
%17 = call i32 @__cpuid(i32 %8, i32 %10, i32 %12, i32 %14, i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %21
21: ; preds = %61, %0
%22 = load i32, i32* %5
%23 = icmp slt i32 %22, 4
br i1 %23, label %24, label %64
24: ; preds = %21
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %33)
store i32 31, i32* %6
br label %35
35: ; preds = %56, %24
%36 = load i32, i32* %6
%37 = icmp sge i32 %36, 0
br i1 %37, label %38, label %59
38: ; preds = %35
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = load i32, i32* %6
%44 = shl i32 1, %43
%45 = and i32 %42, %44
%46 = icmp ne i32 %45, 0
%47 = zext i1 %46 to i64
%48 = select i1 %46, i32 1, i32 0
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %6
%51 = srem i32 %50, 4
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %38
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %55
55: ; preds = %53, %38
br label %56
56: ; preds = %55
%57 = load i32, i32* %6
%58 = add nsw i32 %57, -1
store i32 %58, i32* %6
br label %35
59: ; preds = %35
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %61
61: ; preds = %59
%62 = load i32, i32* %5
%63 = add nsw i32 %62, 1
store i32 %63, i32* %5
br label %21
64: ; preds = %21
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [11 x i8] c"E%cX=%8x=|\00"
@.str.3 = [3 x i8] c"%d\00"
@str.6 = [55 x i8] c"(hi-to-lo) |1098|7654|3210|9876|5432|1098|7654|3210|\00"
@str.8 = [55 x i8] c"------------------------------------------------------\00"
define i32 @main() {
%1 = tail call i32 @__cpuid(i32 -2147483646, i32 undef, i32 undef, i32 undef, i32 undef)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.8, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.6, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.8, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 65, i32 undef)
br label %48
6: ; preds = %55
%7 = tail call i32 @putchar(i32 10)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 66, i32 undef)
br label %9
9: ; preds = %16, %6
%10 = phi i32 [ 31, %6 ], [ %17, %16 ]
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 0)
%12 = and i32 %10, 3
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 @putchar(i32 124)
br label %16
16: ; preds = %14, %9
%17 = add nsw i32 %10, -1
%18 = icmp eq i32 %10, 0
br i1 %18, label %19, label %9
19: ; preds = %16
%20 = tail call i32 @putchar(i32 10)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 67, i32 undef)
br label %22
22: ; preds = %29, %19
%23 = phi i32 [ 31, %19 ], [ %30, %29 ]
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 0)
%25 = and i32 %23, 3
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = tail call i32 @putchar(i32 124)
br label %29
29: ; preds = %27, %22
%30 = add nsw i32 %23, -1
%31 = icmp eq i32 %23, 0
br i1 %31, label %32, label %22
32: ; preds = %29
%33 = tail call i32 @putchar(i32 10)
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 68, i32 undef)
br label %35
35: ; preds = %42, %32
%36 = phi i32 [ 31, %32 ], [ %43, %42 ]
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 0)
%38 = and i32 %36, 3
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = tail call i32 @putchar(i32 124)
br label %42
42: ; preds = %40, %35
%43 = add nsw i32 %36, -1
%44 = icmp eq i32 %36, 0
br i1 %44, label %45, label %35
45: ; preds = %42
%46 = tail call i32 @putchar(i32 10)
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.8, i64 0, i64 0))
ret i32 0
48: ; preds = %0, %55
%49 = phi i32 [ 31, %0 ], [ %56, %55 ]
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 0)
%51 = and i32 %49, 3
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %48
%54 = tail call i32 @putchar(i32 124)
br label %55
55: ; preds = %48, %53
%56 = add nsw i32 %49, -1
%57 = icmp eq i32 %49, 0
br i1 %57, label %6, label %48
}