int is_cpu_genuine_intel(void) {
  unsigned cpuinfo[4] = {0};
  union {
    char name[0x20];
    unsigned cpuinfo[3];
  } vendor;
  memset(&vendor, 0, sizeof(vendor));
  cpuid(0x0, 0x0, cpuinfo);
  vendor.cpuinfo[0] = cpuinfo[1];
  vendor.cpuinfo[1] = cpuinfo[3];
  vendor.cpuinfo[2] = cpuinfo[2];
  return (strncmp(vendor.name, "GenuineIntel", sizeof(vendor.name))) == 0;
}


x86 assembly (clang, -O0):
<is_cpu_genuine_intel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
lea    -0x10(%rbp),%rdx
xor    %esi,%esi
mov    %esi,%edi
mov    $0x0,%al
call   1050 <cpuid@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe7c(%rip),%rsi
mov    $0x20,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_cpu_genuine_intel>:
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movups %xmm0,0x24(%rsp)
movl   $0x0,0x34(%rsp)
mov    %rsp,%rdx
xor    %edi,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <cpuid@plt>
mov    0x4(%rsp),%eax
mov    %eax,0x18(%rsp)
mov    0x8(%rsp),%rax
rol    $0x20,%rax
mov    %rax,0x1c(%rsp)
movabs $0x49656e69756e6547,%rcx
6e 65 49
xor    0x18(%rsp),%rcx
movabs $0x6c65746e49656e,%rdx
xor    0x1d(%rsp),%rdx
xor    %eax,%eax
or     %rcx,%rdx
sete   %al
add    $0x38,%rsp
ret

LLVM IR (-O0):
%union.anon = type { [3 x i32], [20 x i8] }
@.str = [13 x i8] c"GenuineIntel\00"
define i32 @is_cpu_genuine_intel() {
%1 = alloca [4 x i32]
%2 = alloca %union.anon
%3 = bitcast [4 x i32]* %1 to i8*
%4 = bitcast %union.anon* %2 to i8*
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%6 = call i32 (i32, i32, i32*, ...) bitcast (i32 (...)* @cpuid to i32 (i32, i32, i32*, ...)*)(i32 0, i32 0, i32* %5)
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%8 = load i32, i32* %7
%9 = bitcast %union.anon* %2 to [3 x i32]*
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %9, i64 0, i64 0
store i32 %8, i32* %10
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%12 = load i32, i32* %11
%13 = bitcast %union.anon* %2 to [3 x i32]*
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %13, i64 0, i64 1
store i32 %12, i32* %14
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%16 = load i32, i32* %15
%17 = bitcast %union.anon* %2 to [3 x i32]*
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %17, i64 0, i64 2
store i32 %16, i32* %18
%19 = bitcast %union.anon* %2 to [32 x i8]*
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %19, i64 0, i64 0
%21 = call i32 @strncmp(i8* %20, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 32)
%22 = icmp eq i32 %21, 0
%23 = zext i1 %22 to i32
ret i32 %23
}

LLVM IR (-O2):
%union.anon = type { [3 x i32], [20 x i8] }
@.str = [13 x i8] c"GenuineIntel\00"
define i32 @is_cpu_genuine_intel() {
%1 = alloca [4 x i32]
%2 = alloca %union.anon
%3 = bitcast [4 x i32]* %1 to i8*
%4 = bitcast %union.anon* %2 to i8*
%5 = getelementptr inbounds %union.anon, %union.anon* %2, i64 0, i32 1, i64 0
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%7 = call i32 (i32, i32, i32*, ...) bitcast (i32 (...)* @cpuid to i32 (i32, i32, i32*, ...)*)(i32 0, i32 0, i32* %6)
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%9 = load i32, i32* %8
%10 = getelementptr inbounds %union.anon, %union.anon* %2, i64 0, i32 0, i64 0
store i32 %9, i32* %10
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%12 = load i32, i32* %11
%13 = getelementptr inbounds %union.anon, %union.anon* %2, i64 0, i32 0, i64 1
store i32 %12, i32* %13
%14 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%15 = load i32, i32* %14
%16 = getelementptr inbounds %union.anon, %union.anon* %2, i64 0, i32 0, i64 2
store i32 %15, i32* %16
%17 = call i32 @bcmp(i8* dereferenceable(13) %4, i8* dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 13)
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i32
ret i32 %19
}