// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libcpuid/recog_centaur.c
// Function: get_brand_code_and_bits
static centaur_code_and_bits_t get_brand_code_and_bits(struct cpu_id_t* data)
{
	centaur_code_t code = (centaur_code_t) NC;
	centaur_code_and_bits_t result;
	uint64_t bits = 0;
	int i = 0;

	const char* bs = data->brand_str;
	const struct { centaur_code_t c; const char *search; } code_matchtable[] = {
		{ VIA, "VIA" },
		{ ZHAOXIN, "ZHAOXIN" },
	};

	const struct { uint64_t bit; const char* search; } bit_matchtable_via[] = {
		{ SAMUEL_, "Samuel" },
		{ EZRA_, "Ezra" },
		{ NEHEMIAH_, "Nehemiah" },
		{ ESTHER_, "Esther" },
		{ EDEN_, "Eden" },
		{ CNA_, "CNA" },
		{ NANO_, "Nano" },
		{ QUADCORE_, "QuadCore" },
	};
	const struct { uint64_t bit; const char* search; } bit_matchtable_zhaoxin[] = {
		{ KAISHENG_, "KaisHeng" },
		{ KAIXIAN_, "KaiXian" },
		{ _KH_, "KH" },
		{ _KX_, "KX" },
		{ _ZX_, "ZX" },
		{ _C,   "-C" },
		{ _D,   "-D" },
		{ _E,   "-E" },
	};

	for (i = 0; i < COUNT_OF(code_matchtable); i++) {
		if (match_pattern(bs, code_matchtable[i].search)) {
			code = code_matchtable[i].c;
			break;
		}
	}

	if (code == VIA) {
		for (i = 0; i < COUNT_OF(bit_matchtable_via); i++) {
			if (match_pattern(bs, bit_matchtable_via[i].search))
				bits |= bit_matchtable_via[i].bit;
		}
	}
	else if (code == ZHAOXIN) {
		for (i = 0; i < COUNT_OF(bit_matchtable_zhaoxin); i++) {
			if (match_pattern(bs, bit_matchtable_zhaoxin[i].search))
				bits |= bit_matchtable_zhaoxin[i].bit;
		}
	}

	result.code = code;
	result.bits = bits;
	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x18(%rbp)
movl $0x1, -0x1c(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x18(%rbp), %rax
addq $0x14, %rax
movq %rax, -0x38(%rbp)
movq 0xcfa48(%rip), %rax     # 0x207ba0
movq %rax, -0x60(%rbp)
movq 0xcfa45(%rip), %rax     # 0x207ba8
movq %rax, -0x58(%rbp)
movq 0xcfa42(%rip), %rax     # 0x207bb0
movq %rax, -0x50(%rbp)
movq 0xcfa3f(%rip), %rax     # 0x207bb8
movq %rax, -0x48(%rbp)
leaq -0xe0(%rbp), %rdi
leaq 0xcfa35(%rip), %rsi     # 0x207bc0
movl $0x80, %edx
callq 0x593a0
leaq -0x160(%rbp), %rdi
leaq 0xcfa9d(%rip), %rsi     # 0x207c40
movl $0x80, %edx
callq 0x593a0
movl $0x0, -0x2c(%rbp)
movslq -0x2c(%rbp), %rax
cmpq $0x2, %rax
jae 0x138202
movq -0x38(%rbp), %rdi
movslq -0x2c(%rbp), %rcx
leaq -0x60(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x135ec0
cmpl $0x0, %eax
je 0x1381f5
movslq -0x2c(%rbp), %rcx
leaq -0x60(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
jmp 0x138202
jmp 0x1381f7
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1381b4
cmpl $0xbb8, -0x1c(%rbp)     # imm = 0xBB8
jne 0x13826c
movl $0x0, -0x2c(%rbp)
movslq -0x2c(%rbp), %rax
cmpq $0x8, %rax
jae 0x13826a
movq -0x38(%rbp), %rdi
movslq -0x2c(%rbp), %rcx
leaq -0xe0(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x135ec0
cmpl $0x0, %eax
je 0x13825d
movslq -0x2c(%rbp), %rcx
leaq -0xe0(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
orq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x13825f
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x138212
jmp 0x1382d8
cmpl $0xbb9, -0x1c(%rbp)     # imm = 0xBB9
jne 0x1382d6
movl $0x0, -0x2c(%rbp)
movslq -0x2c(%rbp), %rax
cmpq $0x8, %rax
jae 0x1382d4
movq -0x38(%rbp), %rdi
movslq -0x2c(%rbp), %rcx
leaq -0x160(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x135ec0
cmpl $0x0, %eax
je 0x1382c7
movslq -0x2c(%rbp), %rcx
leaq -0x160(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
orq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x1382c9
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x13827c
jmp 0x1382d6
jmp 0x1382d8
movl -0x1c(%rbp), %eax
movl %eax, -0x10(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rdx
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopw %cs:(%rax,%rax)