// File: /workspace/github_c_makefile_star2_O2/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, %rbp
movl %ecx, %ebx
movq %rdx, %rax
movl %esi, %r15d
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), %r10d
leaq 0x41168(%rip), %rsi     # 0x104740
pushq $0x3
popq %rdi
xorl %eax, %eax
movq %r12, 0x30(%rsp)
pushq %r12
movq %rbp, 0x30(%rsp)
pushq %rbp
movq %rbx, 0x30(%rsp)
pushq %rbx
pushq %r10
pushq %r11
pushq 0x38(%rsp)
callq 0xc34c6
addq $0x30, %rsp
testl %r15d, %r15d
movl $0x0, %eax
cmovlel %eax, %r15d
movq %r15, 0x38(%rsp)
pushq $-0x1
popq %rax
movl %eax, 0x8(%rsp)
leaq 0x41294(%rip), %r13     # 0x1048b4
pushq $0x4
popq %rbp
xorl %ebx, %ebx
movl $0x0, 0xc(%rsp)
cmpq 0x38(%rsp), %rbx
je 0xc38c3
movq %rbx, 0x10(%rsp)
imulq $0x78, %rbx, %rax
leaq (%r14,%rax), %r12
leaq 0x4122a(%rip), %rcx     # 0x104876
movq %rcx, 0x40(%rsp)
movl (%r14,%rax), %ecx
movl %ecx, 0x48(%rsp)
movq 0x18(%rsp), %rdx
movl 0xd8(%rdx), %ecx
movl %ecx, 0x4c(%rsp)
pushq $0x2
popq %rsi
movl %esi, 0x50(%rsp)
leaq 0x4120b(%rip), %rcx     # 0x104881
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 0x411d0(%rip), %rcx     # 0x104869
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 0x411b3(%rip), %rcx     # 0x104872
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 0x4118f(%rip), %rcx     # 0x10487d
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 0x4116a(%rip), %rcx     # 0x104887
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 0x41142(%rip), %rcx     # 0x10488e
movq %rcx, 0xd0(%rsp)
movl 0x18(%r14,%rax), %ecx
movl %ecx, 0xd8(%rsp)
movl 0x100(%rdx), %ecx
movl %ecx, 0xdc(%rsp)
pushq $0x1
popq %rdi
movl %edi, 0xe0(%rsp)
leaq 0x41118(%rip), %rcx     # 0x104896
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 0x410f1(%rip), %rcx     # 0x10489e
movq %rcx, 0x100(%rsp)
movl 0x20(%r14,%rax), %ecx
movl %ecx, 0x108(%rsp)
movq 0x20(%rsp), %rcx
movl %ecx, 0x10c(%rsp)
movl %esi, 0x110(%rsp)
leaq 0x410ce(%rip), %rcx     # 0x1048a9
movq %rcx, 0x118(%rsp)
movl 0x30(%r14,%rax), %eax
movl %eax, 0x120(%rsp)
movq 0x30(%rsp), %rax
movl %eax, 0x124(%rsp)
movl %esi, 0x128(%rsp)
xorl %r15d, %r15d
pushq $0x10
popq %rbx
cmpq $0x100, %rbx            # imm = 0x100
je 0xc383c
movl 0x38(%rsp,%rbx), %eax
cmpl 0x3c(%rsp,%rbx), %eax
jne 0xc3836
movl 0x40(%rsp,%rbx), %ecx
addl %ecx, %r15d
movq 0x30(%rsp,%rbx), %rdx
movl %ebp, %edi
movq %r13, %rsi
movl %r15d, %r8d
xorl %eax, %eax
callq 0xc34c6
addq $0x18, %rbx
jmp 0xc3808
movq 0x28(%r12), %rax
andq 0x28(%rsp), %rax
xorl %ecx, %ecx
movq 0x10(%rsp), %rbx
testq %rax, %rax
je 0xc385e
leaq -0x1(%rax), %rdx
andq %rdx, %rax
addl $0x2, %ecx
jmp 0xc384d
addl %ecx, %r15d
movl %ebp, %edi
movq %r13, %rsi
leaq 0x4108d(%rip), %rdx     # 0x1048fa
movl %r15d, %r8d
xorl %eax, %eax
callq 0xc34c6
addq $0x34, %r12
pushq $0x3
popq %rdi
leaq 0x40f17(%rip), %rsi     # 0x10479c
movl %ebx, %edx
movq %r12, %rcx
movl %r15d, %r8d
xorl %eax, %eax
callq 0xc34c6
cmpl 0x8(%rsp), %r15d
jle 0xc38bb
pushq $0x2
popq %rdi
leaq 0x40f11(%rip), %rsi     # 0x1047b6
movq %r12, %rdx
movl %r15d, %ecx
xorl %eax, %eax
callq 0xc34c6
movl %ebx, 0xc(%rsp)
movl %r15d, 0x8(%rsp)
incq %rbx
jmp 0xc362d
movq 0x18(%rsp), %rdi
addq $0x150, %rdi            # imm = 0x150
movslq 0xc(%rsp), %rax
imulq $0x78, %rax, %rax
leaq (%r14,%rax), %rsi
addq $0x34, %rsi
pushq $0x40
popq %rdx
callq 0x566f0
movl 0x8(%rsp), %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq