// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/libraries/libcpuid/libcpuid_util.c
// Function: match_cpu_codename
int match_cpu_codename(const struct match_entry_t* matchtable, int count,
                       struct cpu_id_t* data, int brand_code, uint64_t bits,
                       int model_code)
{
	int bestscore = -1;
	int bestindex = 0;
	int i, t;

	debugf(3, "Matching cpu f:%d, m:%d, s:%d, xf:%d, xm:%d, ncore:%d, l2:%d, bcode:%d, bits:%llu, code:%d\n",
		data->family, data->model, data->stepping, data->ext_family,
		data->ext_model, data->num_cores, data->l2_cache, brand_code, (unsigned long long) bits, model_code);

	for (i = 0; i < count; i++) {
		t = score(&matchtable[i], data, brand_code, bits, model_code);
		debugf(3, "Entry %d, `%s', score %d\n", i, matchtable[i].name, t);
		if (t > bestscore) {
			debugf(2, "Entry `%s' selected - best score so far (%d)\n", matchtable[i].name, t);
			bestscore = t;
			bestindex = i;
		}
	}
	strncpy(data->cpu_codename, matchtable[bestindex].name, CODENAME_STR_MAX);
	return bestscore;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movl %r9d, %r12d
movq %r8, %r10
movl %ecx, %r15d
movq %rdx, %rax
movl %esi, %ebp
movq %rdi, %r14
movl 0xd8(%rdx), %edx
movl 0xdc(%rax), %ecx
movl 0xe0(%rax), %r8d
movl 0xe4(%rax), %r9d
movl 0xe8(%rax), %esi
movq %rsi, 0x10(%rsp)
movl 0xec(%rax), %r11d
movq %rax, 0x18(%rsp)
movl 0x100(%rax), %ebx
leaq 0x4ab79(%rip), %rsi     # 0x1156a0
movl $0x3, %edi
xorl %eax, %eax
movq %r12, 0x38(%rsp)
pushq %r12
movq %r10, 0x38(%rsp)
pushq %r10
movq %r15, 0x38(%rsp)
pushq %r15
pushq %rbx
pushq %r11
pushq 0x38(%rsp)
callq 0xcaa16
addq $0x30, %rsp
testl %ebp, %ebp
jle 0xcae19
movl %ebp, %eax
movq %rax, 0x20(%rsp)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq 0x4aca6(%rip), %r15     # 0x115814
xorl %r12d, %r12d
movl $0x0, 0xc(%rsp)
movl %ebx, 0x10(%rsp)
imulq $0x78, %r12, %rax
leaq (%r14,%rax), %r13
leaq 0x4ac4a(%rip), %rcx     # 0x1157d6
movq %rcx, 0x40(%rsp)
movl (%r14,%rax), %ecx
movl %ecx, 0x48(%rsp)
movq 0x18(%rsp), %rdx
movl 0xd8(%rdx), %ecx
movl %ecx, 0x4c(%rsp)
movl $0x2, %esi
movl %esi, 0x50(%rsp)
leaq 0x4ac29(%rip), %rcx     # 0x1157e1
movq %rcx, 0x58(%rsp)
movl 0x4(%r14,%rax), %ecx
movl %ecx, 0x60(%rsp)
movl 0xdc(%rdx), %ecx
movl %ecx, 0x64(%rsp)
movl %esi, 0x68(%rsp)
leaq 0x4abee(%rip), %rcx     # 0x1157c9
movq %rcx, 0x70(%rsp)
movl 0x8(%r14,%rax), %ecx
movl %ecx, 0x78(%rsp)
movl 0xe0(%rdx), %ecx
movl %ecx, 0x7c(%rsp)
movl %esi, 0x80(%rsp)
leaq 0x4abd1(%rip), %rcx     # 0x1157d2
movq %rcx, 0x88(%rsp)
movl 0xc(%r14,%rax), %ecx
movl %ecx, 0x90(%rsp)
movl 0xe4(%rdx), %ecx
movl %ecx, 0x94(%rsp)
movl %esi, 0x98(%rsp)
leaq 0x4abad(%rip), %rcx     # 0x1157dd
movq %rcx, 0xa0(%rsp)
movl 0x10(%r14,%rax), %ecx
movl %ecx, 0xa8(%rsp)
movl 0xe8(%rdx), %ecx
movl %ecx, 0xac(%rsp)
movl %esi, 0xb0(%rsp)
leaq 0x4ab88(%rip), %rcx     # 0x1157e7
movq %rcx, 0xb8(%rsp)
movl 0x14(%r14,%rax), %ecx
movl %ecx, 0xc0(%rsp)
movl 0xec(%rdx), %ecx
movl %ecx, 0xc4(%rsp)
movl %esi, 0xc8(%rsp)
leaq 0x4ab60(%rip), %rcx     # 0x1157ee
movq %rcx, 0xd0(%rsp)
movl 0x18(%r14,%rax), %ecx
movl %ecx, 0xd8(%rsp)
movl 0x100(%rdx), %ecx
movl %ecx, 0xdc(%rsp)
movl $0x1, %edi
movl %edi, 0xe0(%rsp)
leaq 0x4ab34(%rip), %rcx     # 0x1157f6
movq %rcx, 0xe8(%rsp)
movl 0x1c(%r14,%rax), %ecx
movl %ecx, 0xf0(%rsp)
movl 0x104(%rdx), %ecx
movl %ecx, 0xf4(%rsp)
movl %edi, 0xf8(%rsp)
leaq 0x4ab0d(%rip), %rcx     # 0x1157fe
movq %rcx, 0x100(%rsp)
movl 0x20(%r14,%rax), %ecx
movl %ecx, 0x108(%rsp)
movq 0x28(%rsp), %rcx
movl %ecx, 0x10c(%rsp)
movl %esi, 0x110(%rsp)
leaq 0x4aaea(%rip), %rcx     # 0x115809
movq %rcx, 0x118(%rsp)
movl 0x30(%r14,%rax), %eax
movl %eax, 0x120(%rsp)
movq 0x38(%rsp), %rax
movl %eax, 0x124(%rsp)
movl %esi, 0x128(%rsp)
xorl %ebp, %ebp
movl $0x10, %ebx
movl 0x38(%rsp,%rbx), %eax
cmpl 0x3c(%rsp,%rbx), %eax
jne 0xcad74
movl 0x40(%rsp,%rbx), %ecx
addl %ecx, %ebp
movq 0x30(%rsp,%rbx), %rdx
movl $0x4, %edi
movq %r15, %rsi
movl %ebp, %r8d
xorl %eax, %eax
callq 0xcaa16
addq $0x18, %rbx
cmpq $0x100, %rbx            # imm = 0x100
jne 0xcad4d
movq 0x28(%r13), %rax
andq 0x30(%rsp), %rax
je 0xcada0
xorl %ecx, %ecx
movl 0x10(%rsp), %ebx
leaq -0x1(%rax), %rdx
addl $0x2, %ecx
andq %rdx, %rax
jne 0xcad92
jmp 0xcada6
xorl %ecx, %ecx
movl 0x10(%rsp), %ebx
addl %ecx, %ebp
movl $0x4, %edi
movq %r15, %rsi
leaq 0x4aaa3(%rip), %rdx     # 0x11585a
movl %ebp, %r8d
xorl %eax, %eax
callq 0xcaa16
addq $0x34, %r13
movl $0x3, %edi
leaq 0x4a92b(%rip), %rsi     # 0x1156fc
movl %r12d, %edx
movq %r13, %rcx
movl %ebp, %r8d
xorl %eax, %eax
callq 0xcaa16
cmpl %ebx, %ebp
jle 0xcae04
movl $0x2, %edi
leaq 0x4a925(%rip), %rsi     # 0x115716
movq %r13, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0xcaa16
movl %r12d, 0xc(%rsp)
movl %ebp, %ebx
incq %r12
cmpq 0x20(%rsp), %r12
jne 0xcab79
movslq 0xc(%rsp), %rax
jmp 0xcae20
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
xorl %eax, %eax
movq 0x18(%rsp), %rdi
addq $0x150, %rdi            # imm = 0x150
imulq $0x78, %rax, %rax
leaq (%r14,%rax), %rsi
addq $0x34, %rsi
movl $0x40, %edx
callq 0x556a0
movl %ebx, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq