int main(void) {
  int cpuid;
  asm("movl $1, %%eax;"
      "cpuid;"
      "movl %%edx, %0;"
      : "=&r"(cpuid)
      :
      : "%ebx");
  if (cpuid & 0x800000)
    printf("Found MMX capabilities\n");
  if (cpuid & 0x2000000)
    printf("Found SSE capabilities\n");
  if (cpuid & 0x4000000)
    printf("Found SSE2 capabilities\n");
  if (cpuid & 0x1)
    printf("Found SSE3 capabilities\n");
  if (cpuid & 0x200)
    printf("Found SSE3+ capabilities\n");
  if (cpuid & 0x80000)
    printf("Found SSE4.1 capabilities\n");
  asm("movl $1, %%eax;"
      "cpuid;"
      "movl %%ecx, %0;"
      : "=&r"(cpuid)
      :
      : "%ebx");
  if (cpuid & 0x80000) {
    printf("Found SSE4.2 capabilities\n");
    if (cpuid & 0x1)
      printf("Found PCMPGTQ & CRC32 capabilities\n");
    if (cpuid & 0x400000)
      printf("Found POPCNT capabilities\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
movl   $0x0,-0xc(%rbp)
mov    $0x1,%eax
cpuid
mov    %edx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
and    $0x800000,%eax
cmp    $0x0,%eax
je     1148 <main+0x38>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
and    $0x2000000,%eax
cmp    $0x0,%eax
je     1167 <main+0x57>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
and    $0x4000000,%eax
cmp    $0x0,%eax
je     1186 <main+0x76>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11a3 <main+0x93>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
and    $0x200,%eax
cmp    $0x0,%eax
je     11c2 <main+0xb2>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
and    $0x80000,%eax
cmp    $0x0,%eax
je     11e1 <main+0xd1>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%eax
cpuid
mov    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
and    $0x80000,%eax
cmp    $0x0,%eax
je     124d <main+0x13d>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1229 <main+0x119>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
and    $0x400000,%eax
cmp    $0x0,%eax
je     1248 <main+0x138>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124d <main+0x13d>
mov    -0xc(%rbp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%eax
cpuid
mov    %edx,%ebp
test   $0x800000,%ebp
jne    11b6 <main+0xa6>
test   $0x2000000,%ebp
jne    11ce <main+0xbe>
test   $0x4000000,%ebp
jne    11e6 <main+0xd6>
test   $0x1,%bpl
jne    11fc <main+0xec>
test   $0x200,%ebp
jne    1214 <main+0x104>
test   $0x80000,%ebp
je     116a <main+0x5a>
lea    0xef2(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
cpuid
mov    %ecx,%ebp
test   $0x80000,%ebp
je     11ad <main+0x9d>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
test   $0x1,%bpl
je     1199 <main+0x89>
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
test   $0x400000,%ebp
je     11ad <main+0x9d>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xf14(%rip),%rdi
call   1030 <puts@plt>
test   $0x2000000,%ebp
je     1134 <main+0x24>
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
test   $0x4000000,%ebp
je     1140 <main+0x30>
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
test   $0x1,%bpl
je     114a <main+0x3a>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
test   $0x200,%ebp
je     1156 <main+0x46>
lea    0xe56(%rip),%rdi
call   1030 <puts@plt>
test   $0x80000,%ebp
jne    115e <main+0x4e>
jmp    116a <main+0x5a>

LLVM IR (-O0):
@.str = [24 x i8] c"Found MMX capabilities\0A\00"
@.str.1 = [24 x i8] c"Found SSE capabilities\0A\00"
@.str.2 = [25 x i8] c"Found SSE2 capabilities\0A\00"
@.str.3 = [25 x i8] c"Found SSE3 capabilities\0A\00"
@.str.4 = [26 x i8] c"Found SSE3+ capabilities\0A\00"
@.str.5 = [27 x i8] c"Found SSE4.1 capabilities\0A\00"
@.str.6 = [27 x i8] c"Found SSE4.2 capabilities\0A\00"
@.str.7 = [36 x i8] c"Found PCMPGTQ & CRC32 capabilities\0A\00"
@.str.8 = [27 x i8] c"Found POPCNT capabilities\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 asm "movl $$1, %eax;cpuid;movl %edx, $0;", "=&r,~{ebx},~{dirflag},~{fpsr},~{flags}"()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = and i32 %4, 8388608
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = load i32, i32* %2
%11 = and i32 %10, 33554432
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %9
%16 = load i32, i32* %2
%17 = and i32 %16, 67108864
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %15
%22 = load i32, i32* %2
%23 = and i32 %22, 1
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %21
%28 = load i32, i32* %2
%29 = and i32 %28, 512
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %33
33: ; preds = %31, %27
%34 = load i32, i32* %2
%35 = and i32 %34, 524288
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %39
39: ; preds = %37, %33
%40 = call i32 asm "movl $$1, %eax;cpuid;movl %ecx, $0;", "=&r,~{ebx},~{dirflag},~{fpsr},~{flags}"()
store i32 %40, i32* %2
%41 = load i32, i32* %2
%42 = and i32 %41, 524288
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %58
44: ; preds = %39
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%46 = load i32, i32* %2
%47 = and i32 %46, 1
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %44
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
br label %51
51: ; preds = %49, %44
%52 = load i32, i32* %2
%53 = and i32 %52, 4194304
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
br label %57
57: ; preds = %55, %51
br label %58
58: ; preds = %57, %39
%59 = load i32, i32* %1
ret i32 %59
}

LLVM IR (-O2):
@str = [26 x i8] c"Found SSE4.2 capabilities\00"
@str.9 = [26 x i8] c"Found POPCNT capabilities\00"
@str.10 = [35 x i8] c"Found PCMPGTQ & CRC32 capabilities\00"
@str.11 = [26 x i8] c"Found SSE4.1 capabilities\00"
@str.12 = [25 x i8] c"Found SSE3+ capabilities\00"
@str.13 = [24 x i8] c"Found SSE3 capabilities\00"
@str.14 = [24 x i8] c"Found SSE2 capabilities\00"
@str.15 = [23 x i8] c"Found SSE capabilities\00"
@str.16 = [23 x i8] c"Found MMX capabilities\00"
define i32 @main() {
%1 = tail call i32 asm "movl $$1, %eax;cpuid;movl %edx, $0;", "=&r,~{ebx},~{dirflag},~{fpsr},~{flags}"()
%2 = and i32 %1, 8388608
%3 = icmp eq i32 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.16, i64 0, i64 0))
br label %6
6: ; preds = %4, %0
%7 = and i32 %1, 33554432
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.15, i64 0, i64 0))
br label %11
11: ; preds = %9, %6
%12 = and i32 %1, 67108864
%13 = icmp eq i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.14, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = and i32 %1, 1
%18 = icmp eq i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.13, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
%22 = and i32 %1, 512
%23 = icmp eq i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.12, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
%27 = and i32 %1, 524288
%28 = icmp eq i32 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.11, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
%32 = tail call i32 asm "movl $$1, %eax;cpuid;movl %ecx, $0;", "=&r,~{ebx},~{dirflag},~{fpsr},~{flags}"()
%33 = and i32 %32, 524288
%34 = icmp eq i32 %33, 0
br i1 %34, label %46, label %35
35: ; preds = %31
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%37 = and i32 %32, 1
%38 = icmp eq i32 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %35
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.10, i64 0, i64 0))
br label %41
41: ; preds = %39, %35
%42 = and i32 %32, 4194304
%43 = icmp eq i32 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %41
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.9, i64 0, i64 0))
br label %46
46: ; preds = %41, %44, %31
ret i32 0
}