// File: rpavlik[P]edid-decode/edid-decode.cpp
// Function: print_modeline(unsigned int, timings const*, double)
static void print_modeline(unsigned indent, const struct timings *t, double refresh)
{
	unsigned offset = (!t->even_vtotal && t->interlaced) ? 1 : 0;
	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("%*sModeline \"%ux%u_%.2f%s\" %.3f  %u %u %u %u  %u %u %u %u  %cHSync",
	       indent, "",
	       t->hact, t->vact, refresh,
	       t->interlaced ? "i" : "", t->pixclk_khz / 1000.0,
	       t->hact, t->hact + hfp, t->hact + hfp + t->hsync,
	       t->hact + hfp + t->hsync + hbp,
	       t->vact, t->vact + vfp, t->vact + vfp + t->vsync,
	       t->vact + vfp + t->vsync + vbp + offset,
	       t->pos_pol_hsync ? '+' : '-');
	if (!t->no_pol_vsync)
		printf(" %cVSync", t->pos_pol_vsync ? '+' : '-');
	if (t->interlaced)
		printf(" Interlace");
	printf("\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movl %edi, -0x2c(%rbp)
movq %rsi, -0x38(%rbp)
movsd %xmm0, -0x40(%rbp)
movq -0x38(%rbp), %rcx
xorl %eax, %eax
testb $0x1, 0x44(%rcx)
movb %al, -0x55(%rbp)
jne 0x6129
movq -0x38(%rbp), %rax
movb 0x18(%rax), %al
movb %al, -0x55(%rbp)
movb -0x55(%rbp), %al
movzbl %al, %eax
andl $0x1, %eax
movl %eax, -0x44(%rbp)
movq -0x38(%rbp), %rax
movl 0x1c(%rax), %ecx
movl 0x3c(%rax), %eax
addl %ecx, %eax
movl %eax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movl 0x24(%rax), %ecx
movl 0x3c(%rax), %eax
addl %ecx, %eax
movl %eax, -0x4c(%rbp)
movq -0x38(%rbp), %rax
movl 0x2c(%rax), %ecx
movl 0x40(%rax), %eax
addl %ecx, %eax
movl %eax, -0x50(%rbp)
movq -0x38(%rbp), %rax
movl 0x34(%rax), %ecx
movl 0x40(%rax), %eax
addl %ecx, %eax
movl %eax, -0x54(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x9c(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %ecx
movl %ecx, -0x98(%rbp)
movl 0x4(%rax), %ecx
movl %ecx, -0x94(%rbp)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movb 0x18(%rax), %sil
leaq 0x2920e(%rip), %rdx     # 0x2f3b5
leaq 0x29d0b(%rip), %rcx     # 0x2feb9
testb $0x1, %sil
cmovneq %rdx, %rcx
movq %rcx, -0x88(%rbp)
movl 0x10(%rax), %eax
cvtsi2sd %rax, %xmm0
movsd 0x28e53(%rip), %xmm1    # 0x2f020
divsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x78(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %eax
addl -0x48(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %eax
addl -0x48(%rbp), %eax
movq -0x38(%rbp), %rcx
addl 0x20(%rcx), %eax
movl %eax, -0x70(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %eax
addl -0x48(%rbp), %eax
movq -0x38(%rbp), %rcx
addl 0x20(%rcx), %eax
addl -0x4c(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x38(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x68(%rbp)
movq -0x38(%rbp), %rax
movl 0x4(%rax), %eax
addl -0x50(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x38(%rbp), %rax
movl 0x4(%rax), %eax
addl -0x50(%rbp), %eax
movq -0x38(%rbp), %rcx
addl 0x30(%rcx), %eax
movl %eax, -0x60(%rbp)
movq -0x38(%rbp), %rax
movl 0x4(%rax), %eax
addl -0x50(%rbp), %eax
movq -0x38(%rbp), %rcx
addl 0x30(%rcx), %eax
addl -0x54(%rbp), %eax
addl -0x44(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x38(%rbp), %rax
movb 0x28(%rax), %cl
movb $0x2b, %al
movb $0x2d, %dl
movb %dl, -0x57(%rbp)
testb $0x1, %cl
movb %al, -0x56(%rbp)
jne 0x6275
movb -0x57(%rbp), %al
movb %al, -0x56(%rbp)
movl -0x60(%rbp), %r11d
movl -0x64(%rbp), %ebx
movl -0x68(%rbp), %r14d
movl -0x6c(%rbp), %r15d
movl -0x70(%rbp), %r12d
movl -0x74(%rbp), %r13d
movl -0x78(%rbp), %r10d
movsd -0x80(%rbp), %xmm1
movq -0x88(%rbp), %r9
movsd -0x90(%rbp), %xmm0
movl -0x94(%rbp), %r8d
movl -0x98(%rbp), %ecx
movl -0x9c(%rbp), %esi
movb -0x56(%rbp), %al
movsbl %al, %eax
leaq 0x298b4(%rip), %rdi     # 0x2fb78
leaq 0x29bee(%rip), %rdx     # 0x2feb9
movl %r10d, (%rsp)
movl -0x5c(%rbp), %r10d
movl %r13d, 0x8(%rsp)
movl %r12d, 0x10(%rsp)
movl %r15d, 0x18(%rsp)
movl %r14d, 0x20(%rsp)
movl %ebx, 0x28(%rsp)
movl %r11d, 0x30(%rsp)
movl %r10d, 0x38(%rsp)
movl %eax, 0x40(%rsp)
movb $0x2, %al
callq 0x4050
movq -0x38(%rbp), %rax
testb $0x1, 0x45(%rax)
jne 0x6349
movq -0x38(%rbp), %rax
movb 0x38(%rax), %cl
movb $0x2b, %al
movb $0x2d, %dl
movb %dl, -0x9e(%rbp)
testb $0x1, %cl
movb %al, -0x9d(%rbp)
jne 0x6332
movb -0x9e(%rbp), %al
movb %al, -0x9d(%rbp)
movb -0x9d(%rbp), %al
movsbl %al, %esi
leaq 0x29879(%rip), %rdi     # 0x2fbbb
movb $0x0, %al
callq 0x4050
movq -0x38(%rbp), %rax
testb $0x1, 0x18(%rax)
je 0x6361
leaq 0x2986a(%rip), %rdi     # 0x2fbc4
movb $0x0, %al
callq 0x4050
leaq 0x295a1(%rip), %rdi     # 0x2f909
movb $0x0, %al
callq 0x4050
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)