int main() {
  int i;
  unsigned int index = 0;
  unsigned int regs[4];
  int sum;
  __asm__ __volatile__("pushq %%rbx     \n\t"
                       "cpuid            \n\t"
                       "movl %%ebx ,%[ebx]  \n\t"
                       "popq %%rbx \n\t"
                       : "=a"(regs[0]), [ebx] "=r"(regs[1]), "=c"(regs[2]),
                         "=d"(regs[3])
                       : "a"(index));
  for (i = 4; i < 8; i++) {
    printf("%c", ((char *)regs)[i]);
  }
  for (i = 12; i < 16; i++) {
    printf("%c", ((char *)regs)[i]);
  }
  for (i = 8; i < 12; i++) {
    printf("%c", ((char *)regs)[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
push   %rbx
cpuid
mov    %ebx,%esi
pop    %rbx
mov    %esi,-0x28(%rbp)
mov    %eax,%esi
mov    -0x28(%rbp),%eax
mov    %esi,-0x20(%rbp)
mov    %eax,-0x1c(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x4,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    1179 <main+0x69>
movslq -0x8(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114a <main+0x3a>
movl   $0xc,-0x8(%rbp)
cmpl   $0x10,-0x8(%rbp)
jge    11af <main+0x9f>
movslq -0x8(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1180 <main+0x70>
movl   $0x8,-0x8(%rbp)
cmpl   $0xc,-0x8(%rbp)
jge    11e5 <main+0xd5>
movslq -0x8(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b6 <main+0xa6>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
push   %rbx
cpuid
mov    %ebx,%ebx
pop    %rbx
mov    %ecx,%r14d
mov    %edx,%ebp
movsbl %bl,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
shr    $0x8,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
shr    $0x10,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
sar    $0x18,%ebx
mov    %ebx,%edi
call   1030 <putchar@plt>
movsbl %bpl,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
shr    $0x8,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %ebp,%eax
shr    $0x10,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
sar    $0x18,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
movsbl %r14b,%edi
call   1030 <putchar@plt>
mov    %r14d,%eax
shr    $0x8,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %r14d,%eax
shr    $0x10,%eax
movsbl %al,%edi
call   1030 <putchar@plt>
sar    $0x18,%r14d
mov    %r14d,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [4 x i32]
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 1
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 2
%9 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 3
%10 = load i32, i32* %3
%11 = call { i32, i32, i32, i32 } asm sideeffect "pushq %rbx \0A\09cpuid \0A\09movl %ebx ,$1 \0A\09popq %rbx \0A\09", "={ax},=r,={cx},={dx},{ax},~{dirflag},~{fpsr},~{flags}"(i32 %10)
%12 = extractvalue { i32, i32, i32, i32 } %11, 0
%13 = extractvalue { i32, i32, i32, i32 } %11, 1
%14 = extractvalue { i32, i32, i32, i32 } %11, 2
%15 = extractvalue { i32, i32, i32, i32 } %11, 3
store i32 %12, i32* %6
store i32 %13, i32* %7
store i32 %14, i32* %8
store i32 %15, i32* %9
store i32 4, i32* %2
br label %16
16: ; preds = %28, %0
%17 = load i32, i32* %2
%18 = icmp slt i32 %17, 8
br i1 %18, label %19, label %31
19: ; preds = %16
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%21 = bitcast i32* %20 to i8*
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %19
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
br label %16
31: ; preds = %16
store i32 12, i32* %2
br label %32
32: ; preds = %44, %31
%33 = load i32, i32* %2
%34 = icmp slt i32 %33, 16
br i1 %34, label %35, label %47
35: ; preds = %32
%36 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%37 = bitcast i32* %36 to i8*
%38 = load i32, i32* %2
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %35
%45 = load i32, i32* %2
%46 = add nsw i32 %45, 1
store i32 %46, i32* %2
br label %32
47: ; preds = %32
store i32 8, i32* %2
br label %48
48: ; preds = %60, %47
%49 = load i32, i32* %2
%50 = icmp slt i32 %49, 12
br i1 %50, label %51, label %63
51: ; preds = %48
%52 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%53 = bitcast i32* %52 to i8*
%54 = load i32, i32* %2
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %58)
br label %60
60: ; preds = %51
%61 = load i32, i32* %2
%62 = add nsw i32 %61, 1
store i32 %62, i32* %2
br label %48
63: ; preds = %48
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%65 = load i32, i32* %1
ret i32 %65
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call { i32, i32, i32, i32 } asm sideeffect "pushq %rbx \0A\09cpuid \0A\09movl %ebx ,$1 \0A\09popq %rbx \0A\09", "={ax},=r,={cx},={dx},{ax},~{dirflag},~{fpsr},~{flags}"(i32 0)
%2 = extractvalue { i32, i32, i32, i32 } %1, 1
%3 = extractvalue { i32, i32, i32, i32 } %1, 2
%4 = extractvalue { i32, i32, i32, i32 } %1, 3
%5 = shl i32 %2, 24
%6 = ashr exact i32 %5, 24
%7 = tail call i32 @putchar(i32 %6)
%8 = shl i32 %2, 16
%9 = ashr i32 %8, 24
%10 = tail call i32 @putchar(i32 %9)
%11 = shl i32 %2, 8
%12 = ashr i32 %11, 24
%13 = tail call i32 @putchar(i32 %12)
%14 = ashr i32 %2, 24
%15 = tail call i32 @putchar(i32 %14)
%16 = shl i32 %4, 24
%17 = ashr exact i32 %16, 24
%18 = tail call i32 @putchar(i32 %17)
%19 = shl i32 %4, 16
%20 = ashr i32 %19, 24
%21 = tail call i32 @putchar(i32 %20)
%22 = shl i32 %4, 8
%23 = ashr i32 %22, 24
%24 = tail call i32 @putchar(i32 %23)
%25 = ashr i32 %4, 24
%26 = tail call i32 @putchar(i32 %25)
%27 = shl i32 %3, 24
%28 = ashr exact i32 %27, 24
%29 = tail call i32 @putchar(i32 %28)
%30 = shl i32 %3, 16
%31 = ashr i32 %30, 24
%32 = tail call i32 @putchar(i32 %31)
%33 = shl i32 %3, 8
%34 = ashr i32 %33, 24
%35 = tail call i32 @putchar(i32 %34)
%36 = ashr i32 %3, 24
%37 = tail call i32 @putchar(i32 %36)
%38 = tail call i32 @putchar(i32 10)
ret i32 0
}