// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libcpuid/cpuid_main.c
// Function: cpuid_basic_identify
static int cpuid_basic_identify(struct cpu_raw_data_t* raw, struct cpu_id_t* data)
{
	int i, j, basic, xmodel, xfamily, ext;
	char brandstr[64] = {0};
	data->vendor = cpuid_vendor_identify(raw->basic_cpuid[0], data->vendor_str);

	if (data->vendor == VENDOR_UNKNOWN)
		return cpuid_set_error(ERR_CPU_UNKN);
	data->architecture = ARCHITECTURE_X86;
	basic = raw->basic_cpuid[0][EAX];
	if (basic >= 1) {
		data->family = (raw->basic_cpuid[1][EAX] >> 8) & 0xf;
		data->model = (raw->basic_cpuid[1][EAX] >> 4) & 0xf;
		data->stepping = raw->basic_cpuid[1][EAX] & 0xf;
		xmodel = (raw->basic_cpuid[1][EAX] >> 16) & 0xf;
		xfamily = (raw->basic_cpuid[1][EAX] >> 20) & 0xff;
		if (data->vendor == VENDOR_AMD && data->family < 0xf)
			data->ext_family = data->family;
		else
			data->ext_family = data->family + xfamily;
		data->ext_model = data->model + (xmodel << 4);
	}
	ext = raw->ext_cpuid[0][EAX] - 0x80000000;

	/* obtain the brand string, if present: */
	if (ext >= 4) {
		for (i = 0; i < 3; i++)
			for (j = 0; j < 4; j++)
				memcpy(brandstr + i * 16 + j * 4,
				       &raw->ext_cpuid[2 + i][j], 4);
		brandstr[48] = 0;
		i = 0;
		while (brandstr[i] == ' ') i++;
		strncpy(data->brand_str, brandstr + i, sizeof(data->brand_str));
		data->brand_str[48] = 0;
	}
	load_features_common(raw, data);
	data->total_logical_cpus = get_total_cpus();
	return cpuid_set_error(ERR_OK);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x5a200
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
addq $0x4, %rsi
callq 0x134d30
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x54(%rax)
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x54(%rax)
jne 0x133666
movl $0xfffffff9, %edi       # imm = 0xFFFFFFF9
callq 0x131660
movl %eax, -0x4(%rbp)
jmp 0x133844
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x24(%rbp)
cmpl $0x1, -0x24(%rbp)
jl 0x133747
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
shrl $0x8, %ecx
andl $0xf, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xd8(%rax)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
shrl $0x4, %ecx
andl $0xf, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xdc(%rax)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %ecx
andl $0xf, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xe0(%rax)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
shrl $0x10, %eax
andl $0xf, %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
shrl $0x14, %eax
andl $0xff, %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x1, 0x54(%rax)
jne 0x133714
movq -0x18(%rbp), %rax
cmpl $0xf, 0xd8(%rax)
jge 0x133714
movq -0x18(%rbp), %rax
movl 0xd8(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xe4(%rax)
jmp 0x13372b
movq -0x18(%rbp), %rax
movl 0xd8(%rax), %ecx
addl -0x2c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xe4(%rax)
movq -0x18(%rbp), %rax
movl 0xdc(%rax), %ecx
movl -0x28(%rbp), %eax
shll $0x4, %eax
addl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xe8(%rax)
movq -0x10(%rbp), %rax
movl 0x200(%rax), %eax
subl $0x80000000, %eax       # imm = 0x80000000
movl %eax, -0x30(%rbp)
cmpl $0x4, -0x30(%rbp)
jl 0x13381c
movl $0x0, -0x1c(%rbp)
cmpl $0x3, -0x1c(%rbp)
jge 0x1337d3
movl $0x0, -0x20(%rbp)
cmpl $0x4, -0x20(%rbp)
jge 0x1337c6
leaq -0x70(%rbp), %rax
movl -0x1c(%rbp), %ecx
shll $0x4, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movl -0x20(%rbp), %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
movq -0x10(%rbp), %rdx
addq $0x200, %rdx            # imm = 0x200
movl -0x1c(%rbp), %esi
addl $0x2, %esi
movslq %esi, %rsi
shlq $0x4, %rsi
addq %rsi, %rdx
movslq -0x20(%rbp), %rsi
movl (%rdx,%rsi,4), %edx
movl %edx, (%rax,%rcx)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x133777
jmp 0x1337c8
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x13376a
movb $0x0, -0x40(%rbp)
movl $0x0, -0x1c(%rbp)
movslq -0x1c(%rbp), %rax
movsbl -0x70(%rbp,%rax), %eax
cmpl $0x20, %eax
jne 0x1337f7
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1337de
movq -0x18(%rbp), %rdi
addq $0x14, %rdi
leaq -0x70(%rbp), %rsi
movslq -0x1c(%rbp), %rax
addq %rax, %rsi
movl $0x40, %edx
callq 0x59810
movq -0x18(%rbp), %rax
movb $0x0, 0x44(%rax)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x135330
callq 0x1316d0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xf4(%rax)
xorl %edi, %edi
callq 0x131660
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)