#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 */

/* Variables and functions */
int /*<<< orphan*/ cpuid(int /*<<< orphan*/, int *, int *, int *, int *);
int /*<<< orphan*/ strcmp(char *, char *);
int get_vendor(void) {
  int eax, ebx, ecx, edx;
  char vendor[13];
  cpuid(0, &eax, &ebx, &ecx, &edx);
  *(int *)(&vendor[0]) = ebx;
  *(int *)(&vendor[4]) = edx;
  *(int *)(&vendor[8]) = ecx;
  vendor[12] = (char)0;
  if (!strcmp(vendor, "GenuineIntel"))
    return 1;
  if (!strcmp(vendor, "AuthenticAMD"))
    return 2;
  if ((eax == 0) || ((eax & 0x500) != 0))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<get_vendor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xor    %edi,%edi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
call   1040 <cpuid@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x21(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1d(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x19(%rbp)
movb   $0x0,-0x15(%rbp)
lea    -0x21(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    117a <get_vendor+0x5a>
movl   $0x1,-0x4(%rbp)
jmp    11cd <get_vendor+0xad>
lea    -0x21(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    119f <get_vendor+0x7f>
movl   $0x2,-0x4(%rbp)
jmp    11cd <get_vendor+0xad>
cmpl   $0x0,-0x8(%rbp)
je     11ba <get_vendor+0x9a>
mov    -0x8(%rbp),%eax
and    $0x500,%eax
cmp    $0x0,%eax
je     11c6 <get_vendor+0xa6>
movl   $0x1,-0x4(%rbp)
jmp    11cd <get_vendor+0xad>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_vendor>:
sub    $0x28,%rsp
lea    0x24(%rsp),%rsi
lea    0x20(%rsp),%rdx
lea    0x1c(%rsp),%rcx
lea    0x18(%rsp),%r8
xor    %edi,%edi
call   1030 <cpuid@plt>
mov    0x20(%rsp),%eax
mov    %eax,0x8(%rsp)
mov    0x18(%rsp),%eax
mov    %eax,0xc(%rsp)
mov    0x1c(%rsp),%eax
mov    %eax,0x10(%rsp)
movb   $0x0,0x14(%rsp)
movabs $0x49656e69756e6547,%rax
6e 65 49
xor    0x8(%rsp),%rax
movabs $0x6c65746e49656e,%rcx
xor    0xd(%rsp),%rcx
or     %rax,%rcx
je     11ad <get_vendor+0x9d>
movabs $0x69746e6568747541,%rax
6e 74 69
xor    0x8(%rsp),%rax
movabs $0x444d416369746e,%rcx
xor    0xd(%rsp),%rcx
or     %rax,%rcx
je     11b7 <get_vendor+0xa7>
mov    0x24(%rsp),%eax
test   %eax,%eax
sete   %cl
test   $0x500,%eax
setne  %al
or     %cl,%al
movzbl %al,%eax
add    $0x28,%rsp
ret
mov    $0x1,%eax
add    $0x28,%rsp
ret
mov    $0x2,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"GenuineIntel\00"
@.str.1 = [13 x i8] c"AuthenticAMD\00"
define i32 @get_vendor() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [13 x i8]
%7 = call i32 @cpuid(i32 0, i32* %2, i32* %3, i32* %4, i32* %5)
%8 = load i32, i32* %3
%9 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 0
%10 = bitcast i8* %9 to i32*
store i32 %8, i32* %10
%11 = load i32, i32* %5
%12 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 4
%13 = bitcast i8* %12 to i32*
store i32 %11, i32* %13
%14 = load i32, i32* %4
%15 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 8
%16 = bitcast i8* %15 to i32*
store i32 %14, i32* %16
%17 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 12
store i8 0, i8* %17
%18 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 0
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %0
store i32 1, i32* %1
br label %36
22: ; preds = %0
%23 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 0
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %22
store i32 2, i32* %1
br label %36
27: ; preds = %22
%28 = load i32, i32* %2
%29 = icmp eq i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %27
%31 = load i32, i32* %2
%32 = and i32 %31, 1280
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30, %27
store i32 1, i32* %1
br label %36
35: ; preds = %30
store i32 0, i32* %1
br label %36
36: ; preds = %35, %34, %26, %21
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str = [13 x i8] c"GenuineIntel\00"
@.str.1 = [13 x i8] c"AuthenticAMD\00"
define i32 @get_vendor() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [13 x i8]
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = getelementptr inbounds [13 x i8], [13 x i8]* %5, i64 0, i64 0
%11 = call i32 @cpuid(i32 0, i32* %1, i32* %2, i32* %3, i32* %4)
%12 = load i32, i32* %2
%13 = bitcast [13 x i8]* %5 to i32*
store i32 %12, i32* %13
%14 = load i32, i32* %4
%15 = getelementptr inbounds [13 x i8], [13 x i8]* %5, i64 0, i64 4
%16 = bitcast i8* %15 to i32*
store i32 %14, i32* %16
%17 = load i32, i32* %3
%18 = getelementptr inbounds [13 x i8], [13 x i8]* %5, i64 0, i64 8
%19 = bitcast i8* %18 to i32*
store i32 %17, i32* %19
%20 = getelementptr inbounds [13 x i8], [13 x i8]* %5, i64 0, i64 12
store i8 0, i8* %20
%21 = call i32 @bcmp(i8* dereferenceable(13) %10, i8* dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i64 13)
%22 = icmp eq i32 %21, 0
br i1 %22, label %33, label %23
23: ; preds = %0
%24 = call i32 @bcmp(i8* dereferenceable(13) %10, i8* dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64 13)
%25 = icmp eq i32 %24, 0
br i1 %25, label %33, label %26
26: ; preds = %23
%27 = load i32, i32* %1
%28 = icmp eq i32 %27, 0
%29 = and i32 %27, 1280
%30 = icmp ne i32 %29, 0
%31 = or i1 %28, %30
%32 = zext i1 %31 to i32
br label %33
33: ; preds = %26, %23, %0
%34 = phi i32 [ 1, %0 ], [ 2, %23 ], [ %32, %26 ]
ret i32 %34
}