// File: rpavlik[P]edid-decode/edid-decode.cpp
// Function: edid_state::parse_extension(unsigned char const*)
void edid_state::parse_extension(const unsigned char *x)
{
	block = block_name(x[0]);
	data_block.clear();

	printf("\n");
	if (block_nr && x[0] == 0)
		block = "Unknown EDID Extension Block 0x00";
	printf("Block %u, %s:\n", block_nr, block.c_str());

	switch (x[0]) {
	case 0x02:
		parse_cta_block(x);
		break;
	case 0x10:
		parse_vtb_ext_block(x);
		break;
	case 0x20:
		fail("Deprecated extension block for EDID 2.0, do not use.\n");
		break;
	case 0x40:
		parse_di_ext_block(x);
		break;
	case 0x50:
		parse_ls_ext_block(x);
		break;
	case 0x70:
		parse_displayid_block(x);
		break;
	case 0xf0:
		parse_block_map(x);
		if (block_nr != 1 && block_nr != 128)
			fail("Must be used in block 1 and 128.\n");
		break;
	default:
		hex_block("  ", x, EDID_PAGE_SIZE);
		fail("Unknown Extension Block.\n");
		break;
	}

	data_block.clear();
	do_checksum("", x, EDID_PAGE_SIZE);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
leaq -0x30(%rbp), %rdi
movzbl (%rax), %esi
callq 0x7a10
movq -0x38(%rbp), %rdi
addq $0x10, %rdi
leaq -0x30(%rbp), %rsi
callq 0x43d0
leaq -0x30(%rbp), %rdi
callq 0x41f0
movq -0x38(%rbp), %rdi
addq $0x30, %rdi
callq 0x4400
leaq 0x277a3(%rip), %rdi     # 0x2f909
movb $0x0, %al
callq 0x4050
movq -0x38(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x8197
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x8197
movq -0x38(%rbp), %rdi
addq $0x10, %rdi
leaq 0x276ae(%rip), %rsi     # 0x2f840
callq 0x4420
movq -0x38(%rbp), %rdi
movl 0x8(%rdi), %eax
movl %eax, -0x40(%rbp)
addq $0x10, %rdi
callq 0x4150
movl -0x40(%rbp), %esi
movq %rax, %rdx
leaq 0x276ab(%rip), %rdi     # 0x2f862
xorl %eax, %eax
callq 0x4050
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x3c(%rbp)
subl $0x2, %eax
je 0x8210
jmp 0x81cf
movl -0x3c(%rbp), %eax
subl $0x10, %eax
je 0x8222
jmp 0x81d9
movl -0x3c(%rbp), %eax
subl $0x20, %eax
je 0x8234
jmp 0x81e3
movl -0x3c(%rbp), %eax
subl $0x40, %eax
je 0x8249
jmp 0x81ed
movl -0x3c(%rbp), %eax
subl $0x50, %eax
je 0x825b
jmp 0x81f7
movl -0x3c(%rbp), %eax
subl $0x70, %eax
je 0x826a
jmp 0x8201
movl -0x3c(%rbp), %eax
subl $0xf0, %eax
je 0x8279
jmp 0x82af
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1db00
jmp 0x82df
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x2ce60
jmp 0x82df
xorl %edi, %edi
leaq 0x27634(%rip), %rsi     # 0x2f871
movb $0x0, %al
callq 0x47d0
jmp 0x82df
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x2cd60
jmp 0x82df
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x2af70
jmp 0x82df
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x28870
jmp 0x82df
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x7e90
movq -0x38(%rbp), %rax
cmpl $0x1, 0x8(%rax)
je 0x82ad
movq -0x38(%rbp), %rax
cmpl $0x80, 0x8(%rax)
je 0x82ad
xorl %edi, %edi
leaq 0x27601(%rip), %rsi     # 0x2f8a7
movb $0x0, %al
callq 0x47d0
jmp 0x82df
movq -0x10(%rbp), %rsi
leaq 0x2c527(%rip), %rdi     # 0x347e1
movl $0x80, %edx
movl $0x1, %ecx
movl $0x10, %r8d
callq 0x7860
xorl %edi, %edi
leaq 0x275f1(%rip), %rsi     # 0x2f8c9
movb $0x0, %al
callq 0x47d0
movq -0x38(%rbp), %rdi
addq $0x30, %rdi
callq 0x4400
movq -0x10(%rbp), %rsi
leaq 0x27bc2(%rip), %rdi     # 0x2feb9
movl $0x80, %edx
callq 0x4b50
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)