// File: rpavlik[P]edid-decode/parse-ls-ext-block.cpp
// Function: edid_state::parse_string_table(unsigned char const*)
void edid_state::parse_string_table(const unsigned char *x)
{
	printf("  UTF Type: ");
	switch (x[0] & 7) {
	case 0: printf("UTF 8\n"); break;
	case 1: printf("UTF 16BE\n"); break;
	case 2: printf("UTF 32BE\n"); break;
	default:
		printf("Unknown (0x%02x)\n", x[0] & 7);
		fail("Unknown UTF Type (0x%02x).\n", x[0] & 7);
		break;
	}
	printf("  Country Code ID (ISO 3166-3): %u\n", ((x[1] & 0x3f) << 8) | x[2]);

	if (x[3] || x[4]) {
		char name[4];

		name[0] = ((x[3] & 0x7c) >> 2) + '@';
		name[1] = ((x[3] & 0x03) << 3) + ((x[4] & 0xe0) >> 5) + '@';
		name[2] = (x[4] & 0x1f) + '@';
		name[3] = 0;
		if (name[0] == '@') name[0] = ' ';
		if (name[1] == '@') name[1] = ' ';
		if (name[2] == '@') name[2] = ' ';
		printf("  Language ID: '%s'\n", name);
	}
	x += 5;
	parse_string("Manufacturer Name", x);
	x += x[0] + 1;
	parse_string("Model Name", x);
	x += x[0] + 1;
	if (hide_serial_numbers)
		printf("  Serial Number: ...\n");
	else
		parse_string("Serial Number", x);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
leaq 0x16317(%rip), %rdi     # 0x41046
xorl %eax, %eax
callq 0x4050
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
andl $0x7, %eax
movl %eax, -0x18(%rbp)
je 0x2ad5b
jmp 0x2ad47
movl -0x18(%rbp), %eax
subl $0x1, %eax
je 0x2ad6b
jmp 0x2ad51
movl -0x18(%rbp), %eax
subl $0x2, %eax
je 0x2ad7b
jmp 0x2ad8b
leaq 0x162f1(%rip), %rdi     # 0x41053
movb $0x0, %al
callq 0x4050
jmp 0x2adbd
leaq 0x162e8(%rip), %rdi     # 0x4105a
movb $0x0, %al
callq 0x4050
jmp 0x2adbd
leaq 0x162e2(%rip), %rdi     # 0x41064
movb $0x0, %al
callq 0x4050
jmp 0x2adbd
movq -0x10(%rbp), %rax
movzbl (%rax), %esi
andl $0x7, %esi
leaq 0x949c(%rip), %rdi      # 0x34238
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl (%rax), %edx
andl $0x7, %edx
xorl %edi, %edi
leaq 0x162b8(%rip), %rsi     # 0x4106e
movb $0x0, %al
callq 0x47d0
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %esi
andl $0x3f, %esi
shll $0x8, %esi
movq -0x10(%rbp), %rax
movzbl 0x2(%rax), %eax
orl %eax, %esi
leaq 0x162ae(%rip), %rdi     # 0x4108a
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
cmpb $0x0, 0x3(%rax)
jne 0x2adfb
movq -0x10(%rbp), %rax
cmpb $0x0, 0x4(%rax)
je 0x2ae84
movq -0x10(%rbp), %rax
movzbl 0x3(%rax), %eax
andl $0x7c, %eax
sarl $0x2, %eax
addl $0x40, %eax
movb %al, -0x14(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x3(%rax), %eax
andl $0x3, %eax
shll $0x3, %eax
movq -0x10(%rbp), %rcx
movzbl 0x4(%rcx), %ecx
andl $0xe0, %ecx
sarl $0x5, %ecx
addl %ecx, %eax
addl $0x40, %eax
movb %al, -0x13(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %eax
andl $0x1f, %eax
addl $0x40, %eax
movb %al, -0x12(%rbp)
movb $0x0, -0x11(%rbp)
movsbl -0x14(%rbp), %eax
cmpl $0x40, %eax
jne 0x2ae58
movb $0x20, -0x14(%rbp)
movsbl -0x13(%rbp), %eax
cmpl $0x40, %eax
jne 0x2ae65
movb $0x20, -0x13(%rbp)
movsbl -0x12(%rbp), %eax
cmpl $0x40, %eax
jne 0x2ae72
movb $0x20, -0x12(%rbp)
leaq -0x14(%rbp), %rsi
leaq 0x16231(%rip), %rdi     # 0x410ae
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
addq $0x5, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rsi
leaq 0x16228(%rip), %rdi     # 0x410c3
callq 0x2af10
movq -0x10(%rbp), %rax
movzbl (%rax), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rsi
leaq 0x16212(%rip), %rdi     # 0x410d5
callq 0x2af10
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
movzbl (%rcx), %edx
addl $0x1, %edx
movq -0x10(%rbp), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, -0x10(%rbp)
testb $0x1, 0x52(%rax)
je 0x2aefa
leaq 0x9f1b(%rip), %rdi      # 0x34e0c
movb $0x0, %al
callq 0x4050
jmp 0x2af0a
movq -0x10(%rbp), %rsi
leaq 0x9d99(%rip), %rdi      # 0x34c9e
callq 0x2af10
addq $0x20, %rsp
popq %rbp
retq