void __cpuid(int CPUInfo[4], int InfoType) {
  int *eax = CPUInfo + 0;
  int *ebx = CPUInfo + 1;
  int *ecx = CPUInfo + 2;
  int *edx = CPUInfo + 3;
  *eax = InfoType;
  *ecx = 0;
  __asm__("cpuid"
          : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx)
          : "0"(*eax), "2"(*ecx));
}


x86 assembly (clang, -O0):
<__cpuid>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%ecx
cpuid
mov    %eax,%r9d
mov    -0x48(%rbp),%rax
mov    %ecx,%esi
mov    -0x40(%rbp),%rcx
mov    %r9d,(%r8)
mov    %ebx,(%rdi)
mov    %esi,(%rcx)
mov    %edx,(%rax)
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<__cpuid>:
push   %rbx
mov    %esi,%eax
xor    %ecx,%ecx
cpuid
mov    %eax,(%rdi)
mov    %ebx,0x4(%rdi)
mov    %ecx,0x8(%rdi)
mov    %edx,0xc(%rdi)
pop    %rbx
ret

LLVM IR (-O0):
define void @__cpuid(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
store i32* %0, i32** %3
store i32 %1, i32* %4
%9 = load i32*, i32** %3
%10 = getelementptr inbounds i32, i32* %9, i64 0
store i32* %10, i32** %5
%11 = load i32*, i32** %3
%12 = getelementptr inbounds i32, i32* %11, i64 1
store i32* %12, i32** %6
%13 = load i32*, i32** %3
%14 = getelementptr inbounds i32, i32* %13, i64 2
store i32* %14, i32** %7
%15 = load i32*, i32** %3
%16 = getelementptr inbounds i32, i32* %15, i64 3
store i32* %16, i32** %8
%17 = load i32, i32* %4
%18 = load i32*, i32** %5
store i32 %17, i32* %18
%19 = load i32*, i32** %7
store i32 0, i32* %19
%20 = load i32*, i32** %5
%21 = load i32*, i32** %6
%22 = load i32*, i32** %7
%23 = load i32*, i32** %8
%24 = load i32*, i32** %5
%25 = load i32, i32* %24
%26 = load i32*, i32** %7
%27 = load i32, i32* %26
%28 = call { i32, i32, i32, i32 } asm "cpuid", "={ax},={bx},={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %25, i32 %27)
%29 = extractvalue { i32, i32, i32, i32 } %28, 0
%30 = extractvalue { i32, i32, i32, i32 } %28, 1
%31 = extractvalue { i32, i32, i32, i32 } %28, 2
%32 = extractvalue { i32, i32, i32, i32 } %28, 3
store i32 %29, i32* %20
store i32 %30, i32* %21
store i32 %31, i32* %22
store i32 %32, i32* %23
ret void
}

LLVM IR (-O2):
define void @__cpuid(i32* nocapture writeonly %0, i32 %1) {
%3 = getelementptr inbounds i32, i32* %0, i64 1
%4 = getelementptr inbounds i32, i32* %0, i64 2
%5 = getelementptr inbounds i32, i32* %0, i64 3
%6 = tail call { i32, i32, i32, i32 } asm "cpuid", "={ax},={bx},={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %1, i32 0)
%7 = extractvalue { i32, i32, i32, i32 } %6, 0
%8 = extractvalue { i32, i32, i32, i32 } %6, 1
%9 = extractvalue { i32, i32, i32, i32 } %6, 2
%10 = extractvalue { i32, i32, i32, i32 } %6, 3
store i32 %7, i32* %0
store i32 %8, i32* %3
store i32 %9, i32* %4
store i32 %10, i32* %5
ret void
}