#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 __get_cpuid(int /*<<< orphan*/, unsigned int *, unsigned int *,
                unsigned int *, unsigned int *);
int vendorid(char *buffer) {
  int value;
  unsigned int eax;
  unsigned int ebx;
  unsigned int ecx;
  unsigned int edx;
  value = __get_cpuid(0, &eax, &ebx, &ecx, &edx);
  if (value == 0)
    return (1);
  ((unsigned int *)buffer)[0] = ebx;
  ((unsigned int *)buffer)[1] = edx;
  ((unsigned int *)buffer)[2] = ecx;
  return (0);
}


x86 assembly (clang, -O0):
<vendorid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
xor    %edi,%edi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x24(%rbp),%r8
call   1030 <__get_cpuid@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    114c <vendorid+0x3c>
movl   $0x1,-0x4(%rbp)
jmp    1170 <vendorid+0x60>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x20(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vendorid>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
xor    %ebp,%ebp
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
xor    %edi,%edi
call   1030 <__get_cpuid@plt>
test   %eax,%eax
je     1150 <vendorid+0x40>
mov    0x10(%rsp),%eax
mov    %eax,(%rbx)
mov    0x8(%rsp),%eax
mov    %eax,0x4(%rbx)
mov    0xc(%rsp),%eax
mov    %eax,0x8(%rbx)
jmp    1155 <vendorid+0x45>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @vendorid(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
%9 = call i32 @__get_cpuid(i32 0, i32* %5, i32* %6, i32* %7, i32* %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 1, i32* %2
br label %26
13: ; preds = %1
%14 = load i32, i32* %6
%15 = load i8*, i8** %3
%16 = bitcast i8* %15 to i32*
%17 = getelementptr inbounds i32, i32* %16, i64 0
store i32 %14, i32* %17
%18 = load i32, i32* %8
%19 = load i8*, i8** %3
%20 = bitcast i8* %19 to i32*
%21 = getelementptr inbounds i32, i32* %20, i64 1
store i32 %18, i32* %21
%22 = load i32, i32* %7
%23 = load i8*, i8** %3
%24 = bitcast i8* %23 to i32*
%25 = getelementptr inbounds i32, i32* %24, i64 2
store i32 %22, i32* %25
store i32 0, i32* %2
br label %26
26: ; preds = %13, %12
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
define i32 @vendorid(i8* nocapture writeonly %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = call i32 @__get_cpuid(i32 0, i32* %2, i32* %3, i32* %4, i32* %5)
%11 = icmp eq i32 %10, 0
br i1 %11, label %21, label %12
12: ; preds = %1
%13 = load i32, i32* %3
%14 = bitcast i8* %0 to i32*
store i32 %13, i32* %14
%15 = load i32, i32* %5
%16 = getelementptr inbounds i8, i8* %0, i64 4
%17 = bitcast i8* %16 to i32*
store i32 %15, i32* %17
%18 = load i32, i32* %4
%19 = getelementptr inbounds i8, i8* %0, i64 8
%20 = bitcast i8* %19 to i32*
store i32 %18, i32* %20
br label %21
21: ; preds = %1, %12
%22 = phi i32 [ 0, %12 ], [ 1, %1 ]
ret i32 %22
}