// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libcpuid/recog_amd.c
// Function: decode_amd_codename_part1
static struct amd_code_and_bits_t decode_amd_codename_part1(const char *bs)
{
	amd_code_t code = (amd_code_t) NC;
	struct amd_code_and_bits_t result;
	uint64_t bits = 0;
	int i = 0;
	const size_t n = strlen(bs);

	const struct { amd_code_t c; const char *search; } code_matchtable[] = {
		{ PHENOM2, "Phenom(tm) II" },
		{ PHENOM, "Phenom(tm)" },
		{ FUSION_C, "C-##" },
		{ FUSION_E, "E-###" },
		{ FUSION_Z, "Z-##" },
		{ FUSION_EA, "[EA]#-####" },
		{ FUSION_RX, "RX-###" },
		{ FUSION_GX, "GX-###" },
	};

	const struct { uint64_t bit; const char *search; } bit_matchtable[] = {
		{ _X2, "Dual[- ]Core" },
		{ _X2, " X2 " },
		{ _X3, " X3 " },
		{ _X4, " X4 " },
		{ OPTERON_, "Opteron" },
		{ ATHLON_, "Athlon" },
		{ SEMPRON_, "Sempron(tm)" },
		{ DURON_, "Duron" },
		{ _64_, " 64 " },
		{ _FX, " FX" },
		{ _MP_, " MP" },
		{ ATHLON_|_64_, "Athlon(tm) 64" },
		{ ATHLON_|_64_, "Athlon(tm) II X" },
		{ ATHLON_|_64_, "Athlon(tm) X#" },
		{ TURION_, "Turion" },
		{ MOBILE_, "[mM]obile" },
		{ _XP_, "XP" },
		{ _M_, "XP-M" },
		{ _LV_, "(LV)" },
		{ _APU_, " APU " },
		{ EPYC_, "EPYC" },
		{ RYZEN_TR_, "Ryzen Threadripper" },
		{ C86_, "C86" },
	};

	for (i = 0; i < COUNT_OF(bit_matchtable); i++) {
		if (match_pattern(bs, bit_matchtable[i].search))
			bits |= bit_matchtable[i].bit;
	}
	if (amd_has_turion_modelname(bs)) {
		bits |= TURION_;
	}
	if ((i = match_pattern(bs, "Ryzen [3579Z]")) != 0) {
		bits |= RYZEN_;
		i--;
		switch (bs[i + 6]) {
			case '3': bits |= _3; break;
			case '5': bits |= _5; break;
			case '7': bits |= _7; break;
			case '9': bits |= _9; break;
			case 'Z': bits |= _Z; break;
		}
		for(i = i + 7; i < n; i++) {
			switch (bs[i]) {
				case 'H': bits |= _H; break;
				case 'S': bits |= _S; break;
				case 'U': bits |= _U; break;
				case 'X': bits |= _X; break;
			}
		}
	}

	if ((i = match_pattern(bs, "C86 [357]")) != 0) {
		bits |= C86_;
		i--;
		switch (bs[i + 6]) {
			case '3': bits |= _3; break;
			case '5': bits |= _5; break;
			case '7': bits |= _7; break;
		}
	}

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

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movq %rdi, -0x18(%rbp)
movl $0x1, -0x1c(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5a790
movq %rax, -0x38(%rbp)
leaq -0xc0(%rbp), %rdi
leaq 0xcfec0(%rip), %rsi     # 0x207950
movl $0x80, %edx
callq 0x593a0
leaq -0x230(%rbp), %rdi
leaq 0xcff28(%rip), %rsi     # 0x2079d0
movl $0x170, %edx            # imm = 0x170
callq 0x593a0
movl $0x0, -0x2c(%rbp)
movslq -0x2c(%rbp), %rax
cmpq $0x17, %rax
jae 0x137b11
movq -0x18(%rbp), %rdi
movslq -0x2c(%rbp), %rcx
leaq -0x230(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x135ec0
cmpl $0x0, %eax
je 0x137b04
movslq -0x2c(%rbp), %rcx
leaq -0x230(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
orq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x137b06
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x137ab9
movq -0x18(%rbp), %rdi
callq 0x137d70
cmpl $0x0, %eax
je 0x137b2d
movq -0x28(%rbp), %rax
orq $0x8000, %rax           # imm = 0x8000
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x78880(%rip), %rsi     # 0x1b03b8
callq 0x135ec0
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
je 0x137c6f
movb -0x26(%rbp), %al
orb $0x1, %al
movb %al, -0x26(%rbp)
movl -0x2c(%rbp), %eax
decl %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rcx
movslq -0x2c(%rbp), %rax
movsbl 0x6(%rax,%rcx), %eax
addl $-0x33, %eax
movl %eax, %ecx
movq %rcx, -0x238(%rbp)
subl $0x27, %eax
ja 0x137bd4
movq -0x238(%rbp), %rax
leaq 0x708ab(%rip), %rcx     # 0x1a8430
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x28(%rbp), %rax
orq $0x8, %rax
movq %rax, -0x28(%rbp)
jmp 0x137bd4
movq -0x28(%rbp), %rax
orq $0x10, %rax
movq %rax, -0x28(%rbp)
jmp 0x137bd4
movq -0x28(%rbp), %rax
orq $0x20, %rax
movq %rax, -0x28(%rbp)
jmp 0x137bd4
movq -0x28(%rbp), %rax
orq $0x40, %rax
movq %rax, -0x28(%rbp)
jmp 0x137bd4
movq -0x28(%rbp), %rax
orq $0x10000000, %rax       # imm = 0x10000000
movq %rax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
addl $0x7, %eax
movl %eax, -0x2c(%rbp)
movslq -0x2c(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x137c6d
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
addl $-0x48, %eax
movl %eax, %ecx
movq %rcx, -0x240(%rbp)
subl $0x10, %eax
ja 0x137c5d
movq -0x240(%rbp), %rax
leaq 0x708ba(%rip), %rcx     # 0x1a84d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x28(%rbp), %rax
orq $0x80, %rax
movq %rax, -0x28(%rbp)
jmp 0x137c5d
movq -0x28(%rbp), %rax
orq $0x100, %rax            # imm = 0x100
movq %rax, -0x28(%rbp)
jmp 0x137c5d
movq -0x28(%rbp), %rax
orq $0x200, %rax            # imm = 0x200
movq %rax, -0x28(%rbp)
jmp 0x137c5d
movq -0x28(%rbp), %rax
orq $0x400, %rax            # imm = 0x400
movq %rax, -0x28(%rbp)
jmp 0x137c5f
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x137bdd
jmp 0x137c6f
movq -0x18(%rbp), %rdi
leaq 0x7874c(%rip), %rsi     # 0x1b03c6
callq 0x135ec0
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
je 0x137cf5
movb -0x25(%rbp), %al
orb $0x8, %al
movb %al, -0x25(%rbp)
movl -0x2c(%rbp), %eax
decl %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rcx
movslq -0x2c(%rbp), %rax
movsbl 0x6(%rax,%rcx), %eax
movl %eax, -0x244(%rbp)
subl $0x33, %eax
je 0x137ccb
jmp 0x137cb1
movl -0x244(%rbp), %eax
subl $0x35, %eax
je 0x137cd9
jmp 0x137cbe
movl -0x244(%rbp), %eax
subl $0x37, %eax
je 0x137ce7
jmp 0x137cf3
movq -0x28(%rbp), %rax
orq $0x8, %rax
movq %rax, -0x28(%rbp)
jmp 0x137cf3
movq -0x28(%rbp), %rax
orq $0x10, %rax
movq %rax, -0x28(%rbp)
jmp 0x137cf3
movq -0x28(%rbp), %rax
orq $0x20, %rax
movq %rax, -0x28(%rbp)
jmp 0x137cf5
movl $0x0, -0x2c(%rbp)
movslq -0x2c(%rbp), %rax
cmpq $0x8, %rax
jae 0x137d50
movq -0x18(%rbp), %rdi
movslq -0x2c(%rbp), %rcx
leaq -0xc0(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rsi
callq 0x135ec0
cmpl $0x0, %eax
je 0x137d43
movslq -0x2c(%rbp), %rcx
leaq -0xc0(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x1c(%rbp)
jmp 0x137d50
jmp 0x137d45
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x137cfc
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 $0x250, %rsp            # imm = 0x250
popq %rbp
retq
nop