// File: rpavlik[P]edid-decode/parse-cta-block.cpp
// Function: edid_state::cta_hdmi_block(unsigned char const*, unsigned int)
void edid_state::cta_hdmi_block(const unsigned char *x, unsigned length)
{
	unsigned len_vic, len_3d;

	if (length < 4) {
		fail("Empty Data Block with length %u.\n", length);
		return;
	}
	printf("    Source physical address: %x.%x.%x.%x\n", x[3] >> 4, x[3] & 0x0f,
	       x[4] >> 4, x[4] & 0x0f);

	if (length < 6)
		return;

	if (x[5] & 0x80)
		printf("    Supports_AI\n");
	if (x[5] & 0x40)
		printf("    DC_48bit\n");
	if (x[5] & 0x20)
		printf("    DC_36bit\n");
	if (x[5] & 0x10)
		printf("    DC_30bit\n");
	if (x[5] & 0x08)
		printf("    DC_Y444\n");
	/* two reserved bits */
	if (x[5] & 0x01)
		printf("    DVI_Dual\n");

	if (length < 7)
		return;

	printf("    Maximum TMDS clock: %u MHz\n", x[6] * 5);
	if (x[6] * 5 > 340)
		fail("HDMI VSDB Max TMDS rate is > 340.\n");

	if (length < 8)
		return;

	if (x[7] & 0x0f) {
		printf("    Supported Content Types:\n");
		if (x[7] & 0x01)
			printf("      Graphics\n");
		if (x[7] & 0x02)
			printf("      Photo\n");
		if (x[7] & 0x04)
			printf("      Cinema\n");
		if (x[7] & 0x08)
			printf("      Game\n");
	}

	unsigned b = 8;
	if (x[7] & 0x80) {
		hdmi_latency(x[b], x[b + 1], false);

		if (x[7] & 0x40) {
			if (x[b] == x[b + 2] &&
			    x[b + 1] == x[b + 3])
				warn("Progressive and Interlaced latency values are identical, no need for both.\n");
			b += 2;
			hdmi_latency(x[b], x[b + 1], true);
		}
		b += 2;
	}

	if (!(x[7] & 0x20))
		return;

	bool mask = false;
	bool formats = false;

	printf("    Extended HDMI video details:\n");
	if (x[b] & 0x80)
		printf("      3D present\n");
	if ((x[b] & 0x60) == 0x20) {
		printf("      All advertised VICs are 3D-capable\n");
		formats = true;
	}
	if ((x[b] & 0x60) == 0x40) {
		printf("      3D-capable-VIC mask present\n");
		formats = true;
		mask = true;
	}
	switch (x[b] & 0x18) {
	case 0x00: break;
	case 0x08:
		   printf("      Base EDID image size is aspect ratio\n");
		   break;
	case 0x10:
		   printf("      Base EDID image size is in units of 1 cm\n");
		   break;
	case 0x18:
		   printf("      Base EDID image size is in units of 5 cm\n");
		   base.max_display_width_mm *= 5;
		   base.max_display_height_mm *= 5;
		   printf("        Recalculated image size: %u cm x %u cm\n",
			  base.max_display_width_mm / 10, base.max_display_height_mm / 10);
		   break;
	}
	b++;
	len_vic = (x[b] & 0xe0) >> 5;
	len_3d = (x[b] & 0x1f) >> 0;
	b++;

	if (len_vic) {
		unsigned i;

		printf("      HDMI VICs:\n");
		for (i = 0; i < len_vic; i++) {
			unsigned char vic = x[b + i];
			const struct timings *t;

			if (vic && vic <= ARRAY_SIZE(edid_hdmi_mode_map)) {
				std::string suffix = "HDMI VIC " + std::to_string(vic);
				cta.supported_hdmi_vic_codes |= 1 << (vic - 1);
				t = find_vic_id(edid_hdmi_mode_map[vic - 1]);
				print_timings("        ", t, suffix.c_str());
			} else {
				printf("         Unknown (HDMI VIC %u)\n", vic);
				fail("Unknown HDMI VIC %u.\n", vic);
			}
		}

		b += len_vic;
	}

	if (!len_3d)
		return;

	if (formats) {
		/* 3D_Structure_ALL_15..8 */
		if (x[b] & 0x80)
			printf("      3D: Side-by-side (half, quincunx)\n");
		if (x[b] & 0x01)
			printf("      3D: Side-by-side (half, horizontal)\n");
		/* 3D_Structure_ALL_7..0 */
		b++;
		if (x[b] & 0x40)
			printf("      3D: Top-and-bottom\n");
		if (x[b] & 0x20)
			printf("      3D: L + depth + gfx + gfx-depth\n");
		if (x[b] & 0x10)
			printf("      3D: L + depth\n");
		if (x[b] & 0x08)
			printf("      3D: Side-by-side (full)\n");
		if (x[b] & 0x04)
			printf("      3D: Line-alternative\n");
		if (x[b] & 0x02)
			printf("      3D: Field-alternative\n");
		if (x[b] & 0x01)
			printf("      3D: Frame-packing\n");
		b++;
		len_3d -= 2;
	}

	if (mask) {
		int max_idx = -1;
		unsigned i;

		printf("      3D VIC indices that support these capabilities:\n");
		/* worst bit ordering ever */
		for (i = 0; i < 8; i++)
			if (x[b + 1] & (1 << i)) {
				print_vic_index("        ", i, "");
				max_idx = i;
			}
		for (i = 0; i < 8; i++)
			if (x[b] & (1 << i)) {
				print_vic_index("        ", i + 8, "");
				max_idx = i + 8;
			}
		b += 2;
		len_3d -= 2;
		if (max_idx >= (int)cta.preparsed_svds[0].size())
			fail("HDMI 3D VIC indices max index %d > %u (#SVDs).\n",
			     max_idx + 1, cta.preparsed_svds[0].size());
	}

	/*
	 * list of nibbles:
	 * 2D_VIC_Order_X
	 * 3D_Structure_X
	 * (optionally: 3D_Detail_X and reserved)
	 */
	if (!len_3d)
		return;

	unsigned end = b + len_3d;
	int max_idx = -1;

	printf("      3D VIC indices with specific capabilities:\n");
	while (b < end) {
		unsigned char idx = x[b] >> 4;
		std::string s;

		if (idx > max_idx)
			max_idx = idx;
		switch (x[b] & 0x0f) {
		case 0: s = "frame packing"; break;
		case 1: s = "field alternative"; break;
		case 2: s = "line alternative"; break;
		case 3: s = "side-by-side (full)"; break;
		case 4: s = "L + depth"; break;
		case 5: s = "L + depth + gfx + gfx-depth"; break;
		case 6: s = "top-and-bottom"; break;
		case 8:
			s = "side-by-side";
			switch (x[b + 1] >> 4) {
			case 0x00: s += ", any subsampling"; break;
			case 0x01: s += ", horizontal"; break;
			case 0x02: case 0x03: case 0x04: case 0x05:
				   s += ", not in use";
				   fail("not-in-use 3D_Detail_X value 0x%02x.\n",
					x[b + 1] >> 4);
				   break;
			case 0x06: s += ", all quincunx combinations"; break;
			case 0x07: s += ", quincunx odd/left, odd/right"; break;
			case 0x08: s += ", quincunx odd/left, even/right"; break;
			case 0x09: s += ", quincunx even/left, odd/right"; break;
			case 0x0a: s += ", quincunx even/left, even/right"; break;
			default:
				   s += ", reserved";
				   fail("reserved 3D_Detail_X value 0x%02x.\n",
					x[b + 1] >> 4);
				   break;
			}
			break;
		default:
			s = "unknown (";
			s += utohex(x[b] & 0x0f) + ")";
			fail("Unknown 3D_Structure_X value 0x%02x.\n", x[b] & 0x0f);
			break;
		}
		print_vic_index("        ", idx, s.c_str());
		if ((x[b] & 0x0f) >= 8)
			b++;
		b++;
	}
	if (max_idx >= (int)cta.preparsed_svds[0].size())
		fail("HDMI 2D VIC indices max index %d > %u (#SVDs).\n",
		     max_idx + 1, cta.preparsed_svds[0].size());
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x100(%rbp)
cmpl $0x4, -0x14(%rbp)
jae 0x1709f
movl -0x14(%rbp), %edx
xorl %edi, %edi
leaq 0x2251c(%rip), %rsi     # 0x395af
movb $0x0, %al
callq 0x47d0
jmp 0x17e61
movq -0x10(%rbp), %rax
movzbl 0x3(%rax), %esi
sarl $0x4, %esi
movq -0x10(%rbp), %rax
movzbl 0x3(%rax), %edx
andl $0xf, %edx
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %ecx
sarl $0x4, %ecx
movq -0x10(%rbp), %rax
movzbl 0x4(%rax), %r8d
andl $0xf, %r8d
leaq 0x2268b(%rip), %rdi     # 0x3975f
movb $0x0, %al
callq 0x4050
cmpl $0x6, -0x14(%rbp)
jae 0x170e6
jmp 0x17e61
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x17106
leaq 0x2268a(%rip), %rdi     # 0x39789
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x17124
leaq 0x2267d(%rip), %rdi     # 0x3979a
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x17142
leaq 0x2266d(%rip), %rdi     # 0x397a8
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x17160
leaq 0x2265d(%rip), %rdi     # 0x397b6
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x1717e
leaq 0x2264d(%rip), %rdi     # 0x397c4
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x5(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1719c
leaq 0x2263c(%rip), %rdi     # 0x397d1
movb $0x0, %al
callq 0x4050
cmpl $0x7, -0x14(%rbp)
jae 0x171a7
jmp 0x17e61
movq -0x10(%rbp), %rax
movzbl 0x6(%rax), %eax
imull $0x5, %eax, %esi
leaq 0x22626(%rip), %rdi     # 0x397df
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x6(%rax), %eax
imull $0x5, %eax, %eax
cmpl $0x154, %eax            # imm = 0x154
jle 0x171e2
xorl %edi, %edi
leaq 0x22624(%rip), %rsi     # 0x397ff
movb $0x0, %al
callq 0x47d0
cmpl $0x8, -0x14(%rbp)
jae 0x171ed
jmp 0x17e61
movq -0x10(%rbp), %rax
movzbl 0x7(%rax), %eax
andl $0xf, %eax
cmpl $0x0, %eax
je 0x17289
leaq 0x2261a(%rip), %rdi     # 0x39822
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x7(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1722d
leaq 0x2261a(%rip), %rdi     # 0x39840
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x7(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x1724b
leaq 0x2260c(%rip), %rdi     # 0x39850
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x7(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x17269
leaq 0x225fb(%rip), %rdi     # 0x3985d
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movzbl 0x7(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x17287
leaq 0x225eb(%rip), %rdi     # 0x3986b
movb $0x0, %al
callq 0x4050
jmp 0x17289
movl $0x8, -0x20(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x7(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x17383
movq -0x100(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movb (%rax,%rcx), %sil
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl %ecx, %edx
xorl %ecx, %ecx
movzbl %sil, %esi
movzbl (%rax,%rdx), %edx
callq 0x16c80
movq -0x10(%rbp), %rax
movzbl 0x7(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x1737a
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movq -0x10(%rbp), %rcx
movl -0x20(%rbp), %edx
addl $0x2, %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x1733f
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movq -0x10(%rbp), %rcx
movl -0x20(%rbp), %edx
addl $0x3, %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
jne 0x1733f
movl $0x1, %edi
leaq 0x2253f(%rip), %rsi     # 0x39877
movb $0x0, %al
callq 0x47d0
movq -0x100(%rbp), %rdi
movl -0x20(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movb (%rax,%rcx), %sil
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movl %ecx, %edx
movl $0x1, %ecx
movzbl %sil, %esi
movzbl (%rax,%rdx), %edx
callq 0x16c80
movl -0x20(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x7(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
jne 0x17398
jmp 0x17e61
movb $0x0, -0x21(%rbp)
movb $0x0, -0x22(%rbp)
leaq 0x2251c(%rip), %rdi     # 0x398c3
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x173d1
leaq 0x2251b(%rip), %rdi     # 0x398e5
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0x60, %eax
cmpl $0x20, %eax
jne 0x173f6
leaq 0x2250c(%rip), %rdi     # 0x398f7
movb $0x0, %al
callq 0x4050
movb $0x1, -0x22(%rbp)
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0x60, %eax
cmpl $0x40, %eax
jne 0x1741f
leaq 0x22511(%rip), %rdi     # 0x39921
movb $0x0, %al
callq 0x4050
movb $0x1, -0x22(%rbp)
movb $0x1, -0x21(%rbp)
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0x18, %eax
movl %eax, %ecx
movq %rcx, -0x108(%rbp)
subl $0x18, %eax
ja 0x174e1
movq -0x108(%rbp), %rax
leaq 0x1e59b(%rip), %rcx     # 0x359e8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x174e1
leaq 0x224e2(%rip), %rdi     # 0x39944
movb $0x0, %al
callq 0x4050
jmp 0x174e1
leaq 0x224fe(%rip), %rdi     # 0x39970
movb $0x0, %al
callq 0x4050
jmp 0x174e1
leaq 0x2251e(%rip), %rdi     # 0x399a0
movb $0x0, %al
callq 0x4050
movq -0x100(%rbp), %rax
imull $0x5, 0x174(%rax), %ecx
movl %ecx, 0x174(%rax)
imull $0x5, 0x178(%rax), %ecx
movl %ecx, 0x178(%rax)
movl 0x174(%rax), %eax
movl $0xa, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, %esi
movq -0x100(%rbp), %rax
movl 0x178(%rax), %eax
movl $0xa, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, %edx
leaq 0x224f6(%rip), %rdi     # 0x399d0
movb $0x0, %al
callq 0x4050
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0xe0, %eax
sarl $0x5, %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0x1f, %eax
sarl $0x0, %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x18(%rbp)
je 0x176ab
leaq 0x224d2(%rip), %rdi     # 0x39a00
movb $0x0, %al
callq 0x4050
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x18(%rbp), %eax
jae 0x176a2
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
addl -0x28(%rbp), %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %al
movb %al, -0x29(%rbp)
cmpb $0x0, -0x29(%rbp)
je 0x1766c
movzbl -0x29(%rbp), %eax
cmpq $0x4, %rax
ja 0x1766c
movzbl -0x29(%rbp), %esi
leaq -0x78(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x200a0
movq -0x110(%rbp), %rdx
leaq 0x2247e(%rip), %rsi     # 0x39a12
leaq -0x58(%rbp), %rdi
callq 0x14870
jmp 0x1759f
leaq -0x78(%rbp), %rdi
callq 0x41f0
movq -0x100(%rbp), %rax
movb -0x29(%rbp), %sil
decb %sil
movl 0x2d8(%rax), %ecx
movb %sil, %dl
btsl %edx, %ecx
movl %ecx, 0x2d8(%rax)
movzbl -0x29(%rbp), %eax
leaq 0x1eac1(%rip), %rcx     # 0x36094
movzbl -0x1(%rax,%rcx), %edi
callq 0x154d0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x118(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4150
movq -0x100(%rbp), %rdi
movq -0x118(%rbp), %rdx
movq %rax, %rcx
movq %rsp, %rax
movl $0x1, (%rax)
leaq 0x1d1c5(%rip), %rsi     # 0x347db
leaq 0x1889c(%rip), %r8      # 0x2feb9
xorl %r9d, %r9d
callq 0x50c0
jmp 0x17627
leaq -0x58(%rbp), %rdi
callq 0x41f0
jmp 0x17692
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x41f0
jmp 0x17e6a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x41f0
jmp 0x17e6a
movzbl -0x29(%rbp), %esi
leaq 0x223a5(%rip), %rdi     # 0x39a1c
movb $0x0, %al
callq 0x4050
movzbl -0x29(%rbp), %edx
xorl %edi, %edi
leaq 0x223b1(%rip), %rsi     # 0x39a3c
movb $0x0, %al
callq 0x47d0
jmp 0x17694
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x1753c
movl -0x18(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x176b6
jmp 0x17e61
testb $0x1, -0x22(%rbp)
je 0x17806
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x176e3
leaq 0x22376(%rip), %rdi     # 0x39a52
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x17704
leaq 0x2237e(%rip), %rdi     # 0x39a7b
movb $0x0, %al
callq 0x4050
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x1772e
leaq 0x2237f(%rip), %rdi     # 0x39aa6
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x1774f
leaq 0x22378(%rip), %rdi     # 0x39ac0
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x17770
leaq 0x2237e(%rip), %rdi     # 0x39ae7
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x17791
leaq 0x22372(%rip), %rdi     # 0x39afc
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x177b2
leaq 0x22370(%rip), %rdi     # 0x39b1b
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x177d3
leaq 0x2236b(%rip), %rdi     # 0x39b37
movb $0x0, %al
callq 0x4050
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x177f4
leaq 0x22367(%rip), %rdi     # 0x39b54
movb $0x0, %al
callq 0x4050
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x1c(%rbp)
testb $0x1, -0x21(%rbp)
je 0x179a8
movl $0xffffffff, -0x88(%rbp) # imm = 0xFFFFFFFF
leaq 0x2234c(%rip), %rdi     # 0x39b6d
movb $0x0, %al
callq 0x4050
movl $0x0, -0x8c(%rbp)
cmpl $0x8, -0x8c(%rbp)
jae 0x178a3
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movl -0x8c(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x17890
movq -0x100(%rbp), %rdi
movl -0x8c(%rbp), %edx
leaq 0x1cf66(%rip), %rsi     # 0x347db
leaq 0x1863d(%rip), %rcx     # 0x2feb9
xorl %r8d, %r8d
callq 0x16140
movl -0x8c(%rbp), %eax
movl %eax, -0x88(%rbp)
jmp 0x17892
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x17832
movl $0x0, -0x8c(%rbp)
cmpl $0x8, -0x8c(%rbp)
jae 0x1791f
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movl -0x8c(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x1790c
movq -0x100(%rbp), %rdi
movl -0x8c(%rbp), %edx
addl $0x8, %edx
leaq 0x1ceed(%rip), %rsi     # 0x347db
leaq 0x185c4(%rip), %rcx     # 0x2feb9
xorl %r8d, %r8d
callq 0x16140
movl -0x8c(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x88(%rbp)
jmp 0x1790e
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x178ad
movq -0x100(%rbp), %rdi
movl -0x20(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x1c(%rbp)
movl -0x88(%rbp), %eax
movl %eax, -0x11c(%rbp)
addq $0x180, %rdi            # imm = 0x180
addq $0x760, %rdi            # imm = 0x760
callq 0x1ffc0
movq %rax, %rcx
movl -0x11c(%rbp), %eax
cmpl %ecx, %eax
jl 0x179a6
movq -0x100(%rbp), %rdi
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x120(%rbp)
addq $0x180, %rdi            # imm = 0x180
addq $0x760, %rdi            # imm = 0x760
callq 0x1ffc0
movl -0x120(%rbp), %edx
movq %rax, %rcx
xorl %edi, %edi
leaq 0x22205(%rip), %rsi     # 0x39ba4
movb $0x0, %al
callq 0x47d0
jmp 0x179a8
cmpl $0x0, -0x1c(%rbp)
jne 0x179b3
jmp 0x17e61
movl -0x20(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x90(%rbp)
movl $0xffffffff, -0x94(%rbp) # imm = 0xFFFFFFFF
leaq 0x22204(%rip), %rdi     # 0x39bd4
movb $0x0, %al
callq 0x4050
movl -0x20(%rbp), %eax
cmpl -0x90(%rbp), %eax
jae 0x17dec
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
sarl $0x4, %eax
movb %al, -0x95(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x4430
movzbl -0x95(%rbp), %eax
cmpl -0x94(%rbp), %eax
jle 0x17a22
movzbl -0x95(%rbp), %eax
movl %eax, -0x94(%rbp)
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0xf, %eax
movl %eax, %ecx
movq %rcx, -0x128(%rbp)
subl $0x8, %eax
ja 0x17c97
movq -0x128(%rbp), %rax
leaq 0x1dffc(%rip), %rcx     # 0x35a4c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x221a6(%rip), %rsi     # 0x39c06
leaq -0xb8(%rbp), %rdi
callq 0x4420
jmp 0x17a6e
jmp 0x17d6e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x17dde
leaq 0x22186(%rip), %rsi     # 0x39c14
leaq -0xb8(%rbp), %rdi
callq 0x4420
jmp 0x17a9c
jmp 0x17d6e
leaq 0x2217e(%rip), %rsi     # 0x39c26
leaq -0xb8(%rbp), %rdi
callq 0x4420
jmp 0x17ab6
jmp 0x17d6e
leaq 0x22175(%rip), %rsi     # 0x39c37
leaq -0xb8(%rbp), %rdi
callq 0x4420
jmp 0x17ad0
jmp 0x17d6e
leaq 0x2216f(%rip), %rsi     # 0x39c4b
leaq -0xb8(%rbp), %rdi
callq 0x4420
jmp 0x17aea
jmp 0x17d6e
leaq 0x2215f(%rip), %rsi     # 0x39c55
leaq -0xb8(%rbp), %rdi
callq 0x4420
jmp 0x17b04
jmp 0x17d6e
leaq 0x22161(%rip), %rsi     # 0x39c71
leaq -0xb8(%rbp), %rdi
callq 0x4420
jmp 0x17b1e
jmp 0x17d6e
leaq 0x22156(%rip), %rsi     # 0x39c80
leaq -0xb8(%rbp), %rdi
callq 0x4420
jmp 0x17b38
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
incl %ecx
movzbl (%rax,%rcx), %eax
shrl $0x4, %eax
movl %eax, %ecx
movq %rcx, -0x130(%rbp)
subl $0xa, %eax
ja 0x17c58
movq -0x130(%rbp), %rax
leaq 0x1df08(%rip), %rcx     # 0x35a70
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x22115(%rip), %rsi     # 0x39c8d
leaq -0xb8(%rbp), %rdi
callq 0x4300
jmp 0x17b86
jmp 0x17c92
leaq 0x2210d(%rip), %rsi     # 0x39c9f
leaq -0xb8(%rbp), %rdi
callq 0x4300
jmp 0x17ba0
jmp 0x17c92
leaq 0x22100(%rip), %rsi     # 0x39cac
leaq -0xb8(%rbp), %rdi
callq 0x4300
jmp 0x17bba
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
incl %ecx
movzbl (%rax,%rcx), %edx
shrl $0x4, %edx
leaq 0x220e8(%rip), %rsi     # 0x39cb9
xorl %edi, %edi
movb %dil, %al
callq 0x47d0
jmp 0x17bdd
jmp 0x17c92
leaq 0x220f6(%rip), %rsi     # 0x39cdf
leaq -0xb8(%rbp), %rdi
callq 0x4300
jmp 0x17bf7
jmp 0x17c92
leaq 0x220f8(%rip), %rsi     # 0x39cfb
leaq -0xb8(%rbp), %rdi
callq 0x4300
jmp 0x17c11
jmp 0x17c92
leaq 0x22100(%rip), %rsi     # 0x39d1a
leaq -0xb8(%rbp), %rdi
callq 0x4300
jmp 0x17c28
jmp 0x17c92
leaq 0x22109(%rip), %rsi     # 0x39d3a
leaq -0xb8(%rbp), %rdi
callq 0x4300
jmp 0x17c3f
jmp 0x17c92
leaq 0x22112(%rip), %rsi     # 0x39d5a
leaq -0xb8(%rbp), %rdi
callq 0x4300
jmp 0x17c56
jmp 0x17c92
leaq 0x2211c(%rip), %rsi     # 0x39d7b
leaq -0xb8(%rbp), %rdi
callq 0x4300
jmp 0x17c6d
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
incl %ecx
movzbl (%rax,%rcx), %edx
shrl $0x4, %edx
leaq 0x22102(%rip), %rsi     # 0x39d86
xorl %edi, %edi
movb %dil, %al
callq 0x47d0
jmp 0x17c90
jmp 0x17c92
jmp 0x17d6e
leaq 0x2210c(%rip), %rsi     # 0x39daa
leaq -0xb8(%rbp), %rdi
callq 0x4420
jmp 0x17cac
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %esi
andl $0xf, %esi
leaq -0xf8(%rbp), %rdi
callq 0x7530
jmp 0x17cc8
leaq 0x24c46(%rip), %rdx     # 0x3c915
leaq -0xd8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0xb4c0
jmp 0x17ce4
leaq -0xb8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x43f0
jmp 0x17cf9
leaq -0xd8(%rbp), %rdi
callq 0x41f0
leaq -0xf8(%rbp), %rdi
callq 0x41f0
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %edx
andl $0xf, %edx
leaq 0x2208e(%rip), %rsi     # 0x39db4
xorl %edi, %edi
movb %dil, %al
callq 0x47d0
jmp 0x17d32
jmp 0x17d6e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x17d60
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x41f0
leaq -0xf8(%rbp), %rdi
callq 0x41f0
jmp 0x17dde
movzbl -0x95(%rbp), %eax
movl %eax, -0x134(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x4150
movq -0x100(%rbp), %rdi
movl -0x134(%rbp), %edx
movq %rax, %rcx
leaq 0x1ca3d(%rip), %rsi     # 0x347db
xorl %r8d, %r8d
callq 0x16140
jmp 0x17da8
movq -0x10(%rbp), %rax
movl -0x20(%rbp), %ecx
movzbl (%rax,%rcx), %eax
andl $0xf, %eax
cmpl $0x8, %eax
jl 0x17dc4
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x41f0
jmp 0x179d7
leaq -0xb8(%rbp), %rdi
callq 0x41f0
jmp 0x17e6a
movq -0x100(%rbp), %rdi
movl -0x94(%rbp), %eax
movl %eax, -0x138(%rbp)
addq $0x180, %rdi            # imm = 0x180
addq $0x760, %rdi            # imm = 0x760
callq 0x1ffc0
movq %rax, %rcx
movl -0x138(%rbp), %eax
cmpl %ecx, %eax
jl 0x17e61
movq -0x100(%rbp), %rdi
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x13c(%rbp)
addq $0x180, %rdi            # imm = 0x180
addq $0x760, %rdi            # imm = 0x760
callq 0x1ffc0
movl -0x13c(%rbp), %edx
movq %rax, %rcx
xorl %edi, %edi
leaq 0x21f80(%rip), %rsi     # 0x39dda
movb $0x0, %al
callq 0x47d0
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
movq -0x80(%rbp), %rdi
callq 0x4550
nopw %cs:(%rax,%rax)