// File: /workspace/github_cpp_makefile_star2_O3/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 $0x70, %rsp
xorpd %xmm0, %xmm0
movupd %xmm0, 0x4c(%rsp)
movupd %xmm0, 0x3c(%rsp)
movupd %xmm0, 0x2c(%rsp)
movupd %xmm0, 0x1c(%rsp)
movl $0x0, 0x5c(%rsp)
cmpb $0x1, %dl
ja 0xa08b
movl %edx, %eax
xorb $0x1, %al
movl %ecx, %esi
xorb $0x1, %sil
orb %al, %sil
je 0xa2e1
movzbl %cl, %ecx
leaq 0x1a82f(%rip), %rsi     # 0x248a5
xorl %edi, %edi
xorl %eax, %eax
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x37cc
movq %rsi, %r14
movq %rdi, %rbx
movl %edx, %eax
shll $0x8, %eax
movzbl %cl, %ebp
orl %ebp, %eax
movl $0x58, %ecx
leaq 0x184d5(%rip), %r15     # 0x2257c
cmpl %eax, -0x8(%r15)
je 0xa0fd
addq $0x60, %r15
decq %rcx
jne 0xa0a7
leal 0xf8(,%rdx,8), %edx
movl %ebp, %eax
shrl $0x6, %eax
leaq 0x183f7(%rip), %rcx     # 0x224c0
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 0xa159
movzbl -0xc(%r15), %edx
leaq 0x167d6(%rip), %rsi     # 0x208df
leaq 0x60(%rsp), %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x3070
movl $0x1, (%rsp)
leaq 0x16b63(%rip), %r8      # 0x20c89
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
jmp 0xa2d9
movl $0x5, %eax
movl $0x4, %esi
jmp 0xa159
movl $0x10, %eax
movl $0x9, %esi
jmp 0xa159
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, 0xc(%rsp)
movl %ecx, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movl %esi, 0x18(%rsp)
testb %r8b, %r8b
je 0xa1c8
leaq 0xc(%rsp), %r15
movq %rbx, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x1f2ea
movl $0x1, (%rsp)
leaq 0x1a74d(%rip), %rcx     # 0x24900
leaq 0x16acf(%rip), %r8      # 0x20c89
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
jmp 0xa2d9
movl 0x88(%rbx), %edi
cmpl $0x4, %edi
setae %r8b
orb %r9b, %r8b
cmpb $0x1, %r8b
jne 0xa1ec
testb %r9b, %r9b
je 0xa246
leaq 0x16a9f(%rip), %r15     # 0x20c89
jmp 0xa256
cmpl $0x2, %edi
jae 0xa193
movl %esi, (%rsp)
leaq 0x1a71e(%rip), %rdi     # 0x24919
movq %r14, %rsi
movl %ebp, %r8d
movl %eax, %r9d
xorl %eax, %eax
callq 0x3030
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movupd 0x60(%rbx), %xmm1
movapd %xmm1, %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
movapd %xmm1, %xmm3
cvtsi2sd %ebp, %xmm3
cmpltpd %xmm3, %xmm2
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
andpd %xmm2, %xmm1
andnpd %xmm0, %xmm2
orpd %xmm1, %xmm2
movupd %xmm2, 0x60(%rbx)
jmp 0xa2e1
cmpb $0x1, 0xb8(%rbx)
jne 0xa28a
leaq 0x1a69a(%rip), %r15     # 0x248f0
leaq 0xc(%rsp), %r12
movq %rbx, %rdi
movl %ebp, %esi
movq %r12, %rdx
callq 0x1f964
movl $0x1, (%rsp)
leaq 0x1a671(%rip), %rcx     # 0x248e7
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %r8
xorl %r9d, %r9d
callq 0x3e8c
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1f2ea
cmpb $0x1, 0xb8(%rbx)
jne 0xa2b9
movl $0x1, (%rsp)
leaq 0x1a650(%rip), %rcx     # 0x24900
leaq 0x1a652(%rip), %r8      # 0x24909
jmp 0xa2ce
movl $0x1, (%rsp)
leaq 0x1a639(%rip), %rcx     # 0x24900
leaq 0x169bb(%rip), %r8      # 0x20c89
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %r9d, %r9d
callq 0x3e8c
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq