#include <stdio.h>
#include <stdint.h>
#include <cpuid.h>
#include <string.h>
int main(int argc, char **argv)
{
// a função opcode CPUID:
int op;
// registradores:
int eax;
int ebx;
int ecx;
int edx;
// parâmetro zero para CPUID indica que você quer o fabricante.
op = 0;
__asm__ ("cpuid" : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
: "a" (op));
// Receberá os valores de EBX, ECX e EDX para sistemas 32bits:
char vendor[sizeof(int) * 3 + 1];
strncpy(vendor
, (const char*) &ebx
, sizeof(int)); strncpy(&vendor
[8], (const char*) &ecx
, sizeof(int)); strncpy(&vendor
[4], (const char*) &edx
, sizeof(int)); vendor[12] = '\0'; // terminador nulo
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRpbnQuaD4KI2luY2x1ZGUgPGNwdWlkLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KCmludCBtYWluKGludCBhcmdjLCBjaGFyICoqYXJndikKewogICAgLy8gYSBmdW7Dp8OjbyBvcGNvZGUgQ1BVSUQ6CiAgICBpbnQgb3A7ICAKICAgIAogICAgLy8gcmVnaXN0cmFkb3JlczoKICAgIGludCBlYXg7IAogICAgaW50IGVieDsgCiAgICBpbnQgZWN4OyAKICAgIGludCBlZHg7CgogICAgLy8gcGFyw6JtZXRybyB6ZXJvIHBhcmEgQ1BVSUQgaW5kaWNhIHF1ZSB2b2PDqiBxdWVyIG8gZmFicmljYW50ZS4KICAgIG9wID0gMDsgCiAgICAKICAgIF9fYXNtX18gKCJjcHVpZCIgOiAiPWEiIChlYXgpLCAiPWIiIChlYngpLCAiPWMiIChlY3gpLCAiPWQiIChlZHgpCiAgICAgICAgICAgICAgICAgICAgIDogImEiIChvcCkpOwoKICAgIC8vIFJlY2ViZXLDoSBvcyB2YWxvcmVzIGRlIEVCWCwgRUNYIGUgRURYIHBhcmEgc2lzdGVtYXMgMzJiaXRzOgogICAgY2hhciB2ZW5kb3Jbc2l6ZW9mKGludCkgKiAzICsgMV07IAogICAgc3RybmNweSh2ZW5kb3IsIChjb25zdCBjaGFyKikgJmVieCwgc2l6ZW9mKGludCkpOwogICAgc3RybmNweSgmdmVuZG9yWzhdLCAoY29uc3QgY2hhciopICZlY3gsIHNpemVvZihpbnQpKTsKICAgIHN0cm5jcHkoJnZlbmRvcls0XSwgKGNvbnN0IGNoYXIqKSAmZWR4LCBzaXplb2YoaW50KSk7CiAgICB2ZW5kb3JbMTJdID0gJ1wwJzsgLy8gdGVybWluYWRvciBudWxvCiAgICAgICAgCiAgICBwcmludGYoIkNQVTogJXMiLCB2ZW5kb3IpOwogICAgCiAgICByZXR1cm4gMDsKfQo=