// File: /workspace/github_cpp_makefile_star2_O3/rpavlik[P]edid-decode/parse-cta-block.cpp
// Function: edid_state::hdmi_latency(unsigned char, unsigned char, bool)
void edid_state::hdmi_latency(unsigned char vid_lat, unsigned char aud_lat,
			      bool is_ilaced)
{
	const char *vid = is_ilaced ? "Interlaced video" : "Video";
	const char *aud = is_ilaced ? "Interlaced audio" : "Audio";

	printf("    %s latency: %s\n", vid, hdmi_latency2s(vid_lat, true).c_str());
	printf("    %s latency: %s\n", aud, hdmi_latency2s(aud_lat, false).c_str());

	if (vid_lat > 251 && vid_lat != 0xff)
		fail("Invalid %s latency value %u.\n", vid, vid_lat);
	if (aud_lat > 251 && aud_lat != 0xff)
		fail("Invalid %s latency value %u.\n", aud, aud_lat);

	if (!vid_lat || vid_lat > 251)
		return;
	if (!aud_lat || aud_lat > 251)
		return;

	unsigned vid_ms = 1 + 2 * vid_lat;
	unsigned aud_ms = 1 + 2 * aud_lat;

	// HDMI 2.0 latency checks for devices without HDMI output
	if (aud_ms < vid_ms)
		warn("%s latency < %s latency (%u ms < %u ms). This is discouraged for devices without HDMI output.\n",
		     aud, vid, aud_ms, vid_ms);
	else if (vid_ms + 20 < aud_ms)
		warn("%s latency + 20 < %s latency (%u + 20 ms < %u ms). This is forbidden for devices without HDMI output.\n",
		     vid, aud, vid_ms, aud_ms);
	else if (vid_ms < aud_ms)
		warn("%s latency < %s latency (%u ms < %u ms). This is discouraged for devices without HDMI output.\n",
		     vid, aud, vid_ms, aud_ms);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebp
movl %esi, %r12d
leaq 0x1b0c5(%rip), %rax     # 0x2a1df
leaq 0x1b0cf(%rip), %r14     # 0x2a1f0
testl %ecx, %ecx
cmovneq %rax, %r14
leaq 0x1b0c8(%rip), %rax     # 0x2a1f6
leaq 0x1dffb(%rip), %rbx     # 0x2d130
cmovneq %rax, %rbx
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movl $0x1, %edx
callq 0xf298
movq (%r15), %rdx
leaq 0x1b0b2(%rip), %rdi     # 0x2a207
movq %r14, %rsi
xorl %eax, %eax
callq 0x3030
movq (%r15), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xf179
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3260
movzbl %bpl, %r15d
leaq 0x8(%rsp), %r13
movq %r13, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0xf298
movq (%r13), %rdx
leaq 0x1b06d(%rip), %rdi     # 0x2a207
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3030
movq (%r13), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0xf1bf
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3260
movzbl %r12b, %r12d
leal 0x4(%r12), %r13d
cmpb $0x2, %r13b
ja 0xf1e4
leaq 0x1b046(%rip), %rsi     # 0x2a21b
xorl %edi, %edi
movq %r14, %rdx
movl %r12d, %ecx
xorl %eax, %eax
callq 0x37cc
addb $0x4, %bpl
cmpb $0x2, %bpl
ja 0xf209
leaq 0x1b026(%rip), %rsi     # 0x2a21b
xorl %edi, %edi
movq %rbx, %rdx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x37cc
jmp 0xf289
cmpb $0x5, %r13b
setb %al
cmpb $0x5, %bpl
setb %cl
orb %al, %cl
jne 0xf289
movl %r12d, %eax
addl %r12d, %r12d
leal 0x1(,%rax,2), %r9d
movl %r15d, %eax
addl %r15d, %r15d
leal 0x1(,%rax,2), %eax
cmpl %r12d, %r15d
jae 0xf252
leaq 0x1aff7(%rip), %rsi     # 0x2a239
movl $0x1, %edi
movq %rbx, %rdx
movq %r14, %rcx
movl %eax, %r8d
jmp 0xf282
leal 0x15(%r12), %ecx
cmpl %r15d, %ecx
jbe 0xf26a
cmpl %r15d, %r12d
jae 0xf289
leaq 0x1afd1(%rip), %rsi     # 0x2a239
jmp 0xf271
leaq 0x1b027(%rip), %rsi     # 0x2a298
movl $0x1, %edi
movq %r14, %rdx
movq %rbx, %rcx
movl %r9d, %r8d
movl %eax, %r9d
xorl %eax, %eax
callq 0x37cc
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq