// File: /workspace/github_cpp_makefile_star2_O2/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)
andl $0x0, 0x5c(%rsp)
cmpb $0x1, %dl
ja 0x8864
movl %edx, %eax
xorb $0x1, %al
movl %ecx, %esi
xorb $0x1, %sil
orb %al, %sil
je 0x8aae
movzbl %cl, %ecx
leaq 0x16056(%rip), %rsi     # 0x1e8a5
xorl %edi, %edi
xorl %eax, %eax
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x362c
movq %rsi, %r14
movq %rdi, %rbx
movl %edx, %eax
shll $0x8, %eax
movzbl %cl, %ebp
orl %ebp, %eax
xorl %esi, %esi
leaq 0x13cf3(%rip), %rcx     # 0x1c570
leaq 0x60(%rsi), %rdi
cmpq $0x2160, %rdi           # imm = 0x2160
je 0x88d5
cmpl %eax, 0x4(%rsi,%rcx)
movq %rdi, %rsi
jne 0x887d
leaq (%rdi,%rcx), %r15
addq $-0x54, %r15
movzbl -0xc(%r15), %edx
leaq 0x12038(%rip), %rsi     # 0x1a8df
leaq 0x60(%rsp), %r12
movq %r12, %rdi
xorl %eax, %eax
callq 0x3070
movl $0x1, (%rsp)
leaq 0x123c5(%rip), %r8      # 0x1ac89
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
jmp 0x8aa6
leal 0xf8(,%rdx,8), %edx
movl %ebp, %eax
shrl $0x6, %eax
leaq 0x13bd8(%rip), %rcx     # 0x1c4c0
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
pushq $0x10
popq %rcx
pushq $0x1
popq %rax
cmovnel %ecx, %eax
jmp 0x892c
pushq $0x5
popq %rax
pushq $0x4
jmp 0x892b
pushq $0x10
popq %rax
pushq $0x9
jmp 0x892b
pushq $0x4
popq %rax
pushq $0x3
popq %rsi
movl %esi, %ecx
imull %edx, %ecx
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 0x8998
leaq 0xc(%rsp), %r15
movq %rbx, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x197da
movl $0x1, (%rsp)
leaq 0x15f7d(%rip), %rcx     # 0x1e900
leaq 0x122ff(%rip), %r8      # 0x1ac89
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
jmp 0x8aa6
movl 0x88(%rbx), %edi
cmpl $0x4, %edi
setae %r8b
orb %r9b, %r8b
cmpb $0x1, %r8b
jne 0x89bc
testb %r9b, %r9b
je 0x8a13
leaq 0x122cf(%rip), %r15     # 0x1ac89
jmp 0x8a23
cmpl $0x2, %edi
jae 0x8963
movl %esi, (%rsp)
leaq 0x15f4e(%rip), %rdi     # 0x1e919
movq %r14, %rsi
movl %ebp, %r8d
movl %eax, %r9d
xorl %eax, %eax
callq 0x3030
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 0x8aae
cmpb $0x1, 0xb8(%rbx)
jne 0x8a57
leaq 0x15ecd(%rip), %r15     # 0x1e8f0
leaq 0xc(%rsp), %r12
movq %rbx, %rdi
movl %ebp, %esi
movq %r12, %rdx
callq 0x19e2a
movl $0x1, (%rsp)
leaq 0x15ea4(%rip), %rcx     # 0x1e8e7
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %r8
xorl %r9d, %r9d
callq 0x3af0
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movl %ebp, %esi
callq 0x197da
cmpb $0x1, 0xb8(%rbx)
jne 0x8a86
movl $0x1, (%rsp)
leaq 0x15e83(%rip), %rcx     # 0x1e900
leaq 0x15e85(%rip), %r8      # 0x1e909
jmp 0x8a9b
movl $0x1, (%rsp)
leaq 0x15e6c(%rip), %rcx     # 0x1e900
leaq 0x121ee(%rip), %r8      # 0x1ac89
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %r9d, %r9d
callq 0x3af0
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop