// File: rpavlik[P]edid-decode/edid-decode.cpp
// Function: print_fbmode(unsigned int, timings const*, double, double)
static void print_fbmode(unsigned indent, const struct timings *t,
			 double refresh, double hor_freq_khz)
{
	printf("%*smode \"%ux%u-%u%s\"\n",
	       indent, "",
	       t->hact, t->vact,
	       (unsigned)(0.5 + (t->interlaced ? refresh / 2.0 : refresh)),
	       t->interlaced ? "-lace" : "");
	printf("%*s# D: %.2f MHz, H: %.3f kHz, V: %.2f Hz\n",
	       indent + 8, "",
	       t->pixclk_khz / 1000.0, hor_freq_khz, refresh);
	printf("%*sgeometry %u %u %u %u 32\n",
	       indent + 8, "",
	       t->hact, t->vact, t->hact, t->vact);
	unsigned mult = t->interlaced ? 2 : 1;
	unsigned offset = !t->even_vtotal && t->interlaced;
	unsigned hfp = t->hborder + t->hfp;
	unsigned hbp = t->hborder + t->hbp;
	unsigned vfp = t->vborder + t->vfp;
	unsigned vbp = t->vborder + t->vbp;
	printf("%*stimings %llu %d %d %d %u %u %u\n",
	       indent + 8, "",
	       (unsigned long long)(1000000000.0 / (double)(t->pixclk_khz) + 0.5),
	       hbp, hfp, mult * vbp, mult * vfp + offset, t->hsync, mult * t->vsync);
	if (t->interlaced)
		printf("%*slaced true\n", indent + 8, "");
	if (t->pos_pol_hsync)
		printf("%*shsync high\n", indent + 8, "");
	if (t->pos_pol_vsync)
		printf("%*svsync high\n", indent + 8, "");
	printf("%*sendmode\n", indent, "");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x78, %rsp
movl %edi, -0xc(%rbp)
movq %rsi, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movsd %xmm1, -0x28(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rax
testb $0x1, 0x18(%rax)
je 0x63e5
movsd -0x20(%rbp), %xmm0
movsd 0x28c36(%rip), %xmm1    # 0x2f010
divsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x63ef
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movl -0x44(%rbp), %r8d
movl -0x48(%rbp), %ecx
movl -0x4c(%rbp), %esi
movsd -0x58(%rbp), %xmm0
movsd 0x28c12(%rip), %xmm1    # 0x2f018
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, %r9d
movq -0x18(%rbp), %rax
movb 0x18(%rax), %dil
leaq 0x297c4(%rip), %rax     # 0x2fbe5
leaq 0x29a91(%rip), %rdx     # 0x2feb9
testb $0x1, %dil
movq %rdx, %rdi
cmovneq %rax, %rdi
movq %rsp, %rax
movq %rdi, (%rax)
leaq 0x2978f(%rip), %rdi     # 0x2fbcf
xorl %eax, %eax
callq 0x4050
movl -0xc(%rbp), %esi
addl $0x8, %esi
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
cvtsi2sd %rax, %xmm0
movsd 0x28bbf(%rip), %xmm1    # 0x2f020
divsd %xmm1, %xmm0
movsd -0x28(%rbp), %xmm1
movsd -0x20(%rbp), %xmm2
leaq 0x29775(%rip), %rdi     # 0x2fbeb
leaq 0x29a3c(%rip), %rdx     # 0x2feb9
movb $0x3, %al
callq 0x4050
movl -0xc(%rbp), %esi
addl $0x8, %esi
movq -0x18(%rbp), %rax
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movl 0x4(%rax), %r8d
movq -0x18(%rbp), %rax
movl (%rax), %r9d
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
leaq 0x29769(%rip), %rdi     # 0x2fc16
leaq 0x29a05(%rip), %rdx     # 0x2feb9
movl %eax, (%rsp)
movb $0x0, %al
callq 0x4050
movq -0x18(%rbp), %rax
movb 0x18(%rax), %dl
movl $0x1, %eax
movl $0x2, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rcx
xorl %eax, %eax
testb $0x1, 0x44(%rcx)
movb %al, -0x59(%rbp)
jne 0x64f1
movq -0x18(%rbp), %rax
movb 0x18(%rax), %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
movzbl %al, %eax
andl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movl 0x1c(%rax), %ecx
movl 0x3c(%rax), %eax
addl %ecx, %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movl 0x24(%rax), %ecx
movl 0x3c(%rax), %eax
addl %ecx, %eax
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movl 0x2c(%rax), %ecx
movl 0x40(%rax), %eax
addl %ecx, %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rax
movl 0x34(%rax), %ecx
movl 0x40(%rax), %eax
addl %ecx, %eax
movl %eax, -0x40(%rbp)
movl -0xc(%rbp), %esi
addl $0x8, %esi
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
cvtsi2sd %rax, %xmm1
movsd 0x28ad5(%rip), %xmm0    # 0x2f028
divsd %xmm1, %xmm0
movsd 0x28ab9(%rip), %xmm1    # 0x2f018
addsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
movsd 0x28ab6(%rip), %xmm1    # 0x2f030
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
andq %rdx, %rax
orq %rax, %rcx
movl -0x38(%rbp), %r8d
movl -0x34(%rbp), %r9d
movl -0x2c(%rbp), %ebx
imull -0x40(%rbp), %ebx
movl -0x2c(%rbp), %r11d
imull -0x3c(%rbp), %r11d
addl -0x30(%rbp), %r11d
movq -0x18(%rbp), %rax
movl 0x20(%rax), %r10d
movl -0x2c(%rbp), %eax
movq -0x18(%rbp), %rdx
imull 0x30(%rdx), %eax
leaq 0x29673(%rip), %rdi     # 0x2fc32
leaq 0x298f3(%rip), %rdx     # 0x2feb9
movl %ebx, (%rsp)
movl %r11d, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movb $0x0, %al
callq 0x4050
movq -0x18(%rbp), %rax
testb $0x1, 0x18(%rax)
je 0x6603
movl -0xc(%rbp), %esi
addl $0x8, %esi
leaq 0x29660(%rip), %rdi     # 0x2fc55
leaq 0x298bd(%rip), %rdx     # 0x2feb9
movb $0x0, %al
callq 0x4050
movq -0x18(%rbp), %rax
testb $0x1, 0x28(%rax)
je 0x6628
movl -0xc(%rbp), %esi
addl $0x8, %esi
leaq 0x2964a(%rip), %rdi     # 0x2fc64
leaq 0x29898(%rip), %rdx     # 0x2feb9
movb $0x0, %al
callq 0x4050
movq -0x18(%rbp), %rax
testb $0x1, 0x38(%rax)
je 0x664d
movl -0xc(%rbp), %esi
addl $0x8, %esi
leaq 0x29634(%rip), %rdi     # 0x2fc73
leaq 0x29873(%rip), %rdx     # 0x2feb9
movb $0x0, %al
callq 0x4050
movl -0xc(%rbp), %esi
leaq 0x2962b(%rip), %rdi     # 0x2fc82
leaq 0x2985b(%rip), %rdx     # 0x2feb9
movb $0x0, %al
callq 0x4050
addq $0x78, %rsp
popq %rbx
popq %rbp
retq
nopl (%rax)