#include <stdio.h>
#include <libcpuid.h>

void get_cpu_info(char *vendor_str, char *cpu_codename) {
    if (!cpuid_present()) {
        sprintf(vendor_str, "Unsupported");
        sprintf(cpu_codename, "Unsupported");
        return;
    }

    struct cpu_raw_data_t raw;
    struct cpu_id_t data;

    if (cpuid_get_raw_data(&raw) < 0) {
        sprintf(vendor_str, "Error");
        sprintf(cpu_codename, "Cannot get raw data");
        return;
    }

    if (cpu_identify(&raw, &data) < 0) {
        sprintf(vendor_str, "Error");
        sprintf(cpu_codename, "Identification failed");
        return;
    }

    sprintf(vendor_str, "%s", data.vendor_str);
    sprintf(cpu_codename, "%s", data.cpu_codename);
}
