// File: /workspace/github_cpp_makefile_star2_O1/rpavlik[P]edid-decode/parse-base-block.cpp
// Function: edid_state::print_standard_timing(char const*, unsigned char, unsigned char, bool, bool)
void edid_state::print_standard_timing(const char *prefix, unsigned char b1, unsigned char b2,
				       bool gtf_only, bool show_both)
{
	const struct timings *t;
	struct timings formula = {};
	unsigned hratio, vratio;
	unsigned hact, vact, refresh;
	unsigned char dmt_id = 0;

	if (b1 <= 0x01) {
		if (b1 != 0x01 || b2 != 0x01)
			fail("Use 0x0101 as the invalid Standard Timings code, not 0x%02x%02x.\n", b1, b2);
		return;
	}

	t = find_std_id((b1 << 8) | b2, dmt_id);
	if (t) {
		char type[16];
		sprintf(type, "DMT 0x%02x", dmt_id);
		print_timings(prefix, t, type);
		return;
	}
	hact = (b1 + 31) * 8;
	switch ((b2 >> 6) & 0x3) {
	case 0x00:
		if (gtf_only || show_both || base.edid_minor >= 3) {
			hratio = 16;
			vratio = 10;
		} else {
			hratio = 1;
			vratio = 1;
		}
		break;
	case 0x01:
		hratio = 4;
		vratio = 3;
		break;
	case 0x02:
		hratio = 5;
		vratio = 4;
		break;
	case 0x03:
		hratio = 16;
		vratio = 9;
		break;
	}
	vact = (double)hact * vratio / hratio;
	vact = 8 * ((vact + 7) / 8);
	refresh = (b2 & 0x3f) + 60;

	formula.hact = hact;
	formula.vact = vact;
	formula.hratio = hratio;
	formula.vratio = vratio;

	if (!gtf_only && (show_both || base.edid_minor >= 4)) {
		if (show_both || base.supports_cvt) {
			edid_cvt_mode(refresh, formula);
			print_timings(prefix, &formula, "CVT     ",
				      show_both ? "" : "EDID 1.4 source");
		}
		/*
		 * An EDID 1.3 source will assume GTF, so both GTF and CVT
		 * have to be supported.
		 */
		edid_gtf_mode(refresh, formula);
		if (base.supports_cvt)
			print_timings(prefix, &formula, "GTF     ", "EDID 1.3 source");
		else
			print_timings(prefix, &formula, "GTF     ");
	} else if (gtf_only || base.edid_minor >= 2) {
		edid_gtf_mode(refresh, formula);
		print_timings(prefix, &formula, "GTF     ");
	} else {
		printf("%sUnknown : %5ux%-5u %3u.000 Hz %3u:%u\n",
		       prefix, hact, vact, refresh, hratio, vratio);
		min_vert_freq_hz = min(min_vert_freq_hz, refresh);
		max_vert_freq_hz = max(max_vert_freq_hz, refresh);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x80, %rsp
xorpd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
movapd %xmm0, 0x40(%rsp)
movapd %xmm0, 0x30(%rsp)
movapd %xmm0, 0x20(%rsp)
movapd %xmm0, 0x10(%rsp)
movl $0x0, 0x60(%rsp)
cmpb $0x1, %dl
ja 0xa2c5
movl %edx, %eax
xorb $0x1, %al
movl %ecx, %esi
xorb $0x1, %sil
orb %al, %sil
je 0xa521
movzbl %cl, %ecx
leaq 0x1a5a8(%rip), %rsi     # 0x24855
xorl %edi, %edi
xorl %eax, %eax
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x37ec
movq %rsi, %r14
movq %rdi, %rbx
movl %edx, %eax
shll $0x8, %eax
movzbl %cl, %ebp
orl %ebp, %eax
movl $0x58, %ecx
leaq 0x1828b(%rip), %r15     # 0x2256c
cmpl %eax, -0x8(%r15)
je 0xa2f7
addq $0x60, %r15
decq %rcx
jne 0xa2e1
xorl %eax, %eax
xorl %r15d, %r15d
jmp 0xa2fc
movzbl -0xc(%r15), %eax
testq %r15, %r15
je 0xa338
leaq 0x165c7(%rip), %rsi     # 0x208cf
leaq 0x70(%rsp), %r12
movq %r12, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x3070
movl $0x1, (%rsp)
leaq 0x16952(%rip), %r8      # 0x20c79
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
jmp 0xa519
leal 0xf8(,%rdx,8), %edx
movl %ebp, %eax
shrl $0x6, %eax
leaq 0x18165(%rip), %rcx     # 0x224b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl %r8d, %eax
orb %r9b, %al
cmpl $0x3, 0x88(%rbx)
setae %cl
orb %al, %cl
movzbl %cl, %eax
leal (%rax,%rax,8), %esi
incl %esi
testb %al, %al
movl $0x10, %ecx
movl $0x1, %eax
cmovnel %ecx, %eax
jmp 0xa3a1
movl $0x5, %eax
movl $0x4, %esi
jmp 0xa3a1
movl $0x10, %eax
movl $0x9, %esi
jmp 0xa3a1
movl $0x4, %eax
movl $0x3, %esi
movl %esi, %ecx
imull %edx, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
addl $0x7, %ecx
andl $-0x8, %ecx
andl $0x3f, %ebp
addl $0x3c, %ebp
movl %edx, 0x10(%rsp)
movl %ecx, 0x14(%rsp)
movl %eax, 0x18(%rsp)
movl %esi, 0x1c(%rsp)
testb %r8b, %r8b
je 0xa410
leaq 0x10(%rsp), %r15
movq %rbx, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x1f6b0
movl $0x1, (%rsp)
leaq 0x1a4b5(%rip), %rcx     # 0x248b0
leaq 0x16877(%rip), %r8      # 0x20c79
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
jmp 0xa519
movl 0x88(%rbx), %edi
cmpl $0x4, %edi
setae %r10b
orb %r9b, %r10b
cmpb $0x1, %r10b
jne 0xa434
testb %r9b, %r9b
je 0xa486
leaq 0x16847(%rip), %r15     # 0x20c79
jmp 0xa496
cmpl $0x2, %edi
setae %dil
orb %dil, %r8b
cmpb $0x1, %r8b
je 0xa3db
movl %esi, (%rsp)
leaq 0x1a47b(%rip), %rdi     # 0x248c9
movq %r14, %rsi
movl %ebp, %r8d
movl %eax, %r9d
xorl %eax, %eax
callq 0x3030
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movsd 0x60(%rbx), %xmm1
movsd 0x68(%rbx), %xmm2
minsd %xmm0, %xmm1
movsd %xmm1, 0x60(%rbx)
maxsd %xmm0, %xmm2
movsd %xmm2, 0x68(%rbx)
jmp 0xa521
cmpb $0x1, 0xb8(%rbx)
jne 0xa4ca
leaq 0x1a40a(%rip), %r15     # 0x248a0
leaq 0x10(%rsp), %r12
movq %rbx, %rdi
movl %ebp, %esi
movq %r12, %rdx
callq 0x1fd24
movl $0x1, (%rsp)
leaq 0x1a3e1(%rip), %rcx     # 0x24897
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %r8
xorl %r9d, %r9d
callq 0x3ebe
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1f6b0
cmpb $0x1, 0xb8(%rbx)
jne 0xa4f9
movl $0x1, (%rsp)
leaq 0x1a3c0(%rip), %rcx     # 0x248b0
leaq 0x1a3c2(%rip), %r8      # 0x248b9
jmp 0xa50e
movl $0x1, (%rsp)
leaq 0x1a3a9(%rip), %rcx     # 0x248b0
leaq 0x1676b(%rip), %r8      # 0x20c79
leaq 0x10(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %r9d, %r9d
callq 0x3ebe
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop